ERR: Reorganize to try to fix the -pthread problem on some systems
This commit is contained in:
parent
a413160fec
commit
21ec23413e
|
@ -9,14 +9,46 @@
|
||||||
INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
|
INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
|
||||||
INCLUDE (${CMAKE_ROOT}/Modules/CheckLibraryExists.cmake)
|
INCLUDE (${CMAKE_ROOT}/Modules/CheckLibraryExists.cmake)
|
||||||
|
|
||||||
|
# Do we have sproc?
|
||||||
IF(CMAKE_SYSTEM MATCHES IRIX)
|
IF(CMAKE_SYSTEM MATCHES IRIX)
|
||||||
CHECK_INCLUDE_FILE("sys/prctl.h" CMAKE_HAVE_SPROC_H)
|
CHECK_INCLUDE_FILE("sys/prctl.h" CMAKE_HAVE_SPROC_H)
|
||||||
ENDIF(CMAKE_SYSTEM MATCHES IRIX)
|
ENDIF(CMAKE_SYSTEM MATCHES IRIX)
|
||||||
|
|
||||||
CHECK_INCLUDE_FILE("pthread.h" CMAKE_HAVE_PTHREAD_H)
|
IF(CMAKE_HAVE_SPROC_H)
|
||||||
IF(CMAKE_HAVE_PTHREAD_H)
|
# We have sproc
|
||||||
IF(NOT CMAKE_HAVE_SPROC_H)
|
SET(CMAKE_USE_SPROC_INIT 1)
|
||||||
IF(NOT APPLE)
|
ELSE(CMAKE_HAVE_SPROC_H)
|
||||||
|
# Do we have pthreads?
|
||||||
|
CHECK_INCLUDE_FILE("pthread.h" CMAKE_HAVE_PTHREAD_H)
|
||||||
|
IF(CMAKE_HAVE_PTHREAD_H)
|
||||||
|
# We have pthread.h
|
||||||
|
# Let's check for the library now.
|
||||||
|
SET(CMAKE_HAVE_THREADS_LIBRARY)
|
||||||
|
IF(NOT THREADS_HAVE_PTHREAD_ARG)
|
||||||
|
# Do we have -lpthreads
|
||||||
|
CHECK_LIBRARY_EXISTS(pthreads pthread_create "" CMAKE_HAVE_PTHREADS_CREATE)
|
||||||
|
IF(CMAKE_HAVE_PTHREADS_CREATE)
|
||||||
|
SET(CMAKE_THREAD_LIBS_INIT "-lpthreads")
|
||||||
|
SET(CMAKE_HAVE_THREADS_LIBRARY 1)
|
||||||
|
ENDIF(CMAKE_HAVE_PTHREADS_CREATE)
|
||||||
|
# Ok, how about -lpthread
|
||||||
|
CHECK_LIBRARY_EXISTS(pthread pthread_create "" CMAKE_HAVE_PTHREAD_CREATE)
|
||||||
|
IF(CMAKE_HAVE_PTHREAD_CREATE)
|
||||||
|
SET(CMAKE_THREAD_LIBS_INIT "-lpthread")
|
||||||
|
SET(CMAKE_HAVE_THREADS_LIBRARY 1)
|
||||||
|
ENDIF(CMAKE_HAVE_PTHREAD_CREATE)
|
||||||
|
IF(CMAKE_SYSTEM MATCHES "SunOS.*")
|
||||||
|
# On sun also check for -lthread
|
||||||
|
CHECK_LIBRARY_EXISTS(thread thr_create "" CMAKE_HAVE_THR_CREATE)
|
||||||
|
IF(CMAKE_HAVE_THR_CREATE)
|
||||||
|
SET(CMAKE_THREAD_LIBS_INIT "-lthread")
|
||||||
|
SET(CMAKE_HAVE_THREADS_LIBRARY 1)
|
||||||
|
ENDIF(CMAKE_HAVE_THR_CREATE)
|
||||||
|
ENDIF(CMAKE_SYSTEM MATCHES "SunOS.*")
|
||||||
|
ENDIF(NOT THREADS_HAVE_PTHREAD_ARG)
|
||||||
|
|
||||||
|
IF(NOT CMAKE_HAVE_THREADS_LIBRARY)
|
||||||
|
# If we did not found -lpthread, -lpthread, or -lthread, look for -pthread
|
||||||
IF("THREADS_HAVE_PTHREAD_ARG" MATCHES "^THREADS_HAVE_PTHREAD_ARG")
|
IF("THREADS_HAVE_PTHREAD_ARG" MATCHES "^THREADS_HAVE_PTHREAD_ARG")
|
||||||
MESSAGE(STATUS "Check if compiler accepts -pthread")
|
MESSAGE(STATUS "Check if compiler accepts -pthread")
|
||||||
TRY_RUN(THREADS_PTHREAD_ARG THREADS_HAVE_PTHREAD_ARG
|
TRY_RUN(THREADS_PTHREAD_ARG THREADS_HAVE_PTHREAD_ARG
|
||||||
|
@ -38,31 +70,14 @@ IF(CMAKE_HAVE_PTHREAD_H)
|
||||||
"Determining if compiler accepts -pthread failed with the following output:\n${OUTPUT}\n\n")
|
"Determining if compiler accepts -pthread failed with the following output:\n${OUTPUT}\n\n")
|
||||||
ENDIF(THREADS_HAVE_PTHREAD_ARG)
|
ENDIF(THREADS_HAVE_PTHREAD_ARG)
|
||||||
ENDIF("THREADS_HAVE_PTHREAD_ARG" MATCHES "^THREADS_HAVE_PTHREAD_ARG")
|
ENDIF("THREADS_HAVE_PTHREAD_ARG" MATCHES "^THREADS_HAVE_PTHREAD_ARG")
|
||||||
ENDIF(NOT APPLE)
|
IF(THREADS_HAVE_PTHREAD_ARG)
|
||||||
IF(THREADS_HAVE_PTHREAD_ARG)
|
SET(CMAKE_THREAD_LIBS_INIT "-pthread")
|
||||||
SET(CMAKE_THREAD_LIBS_INIT "-pthread")
|
ELSE(THREADS_HAVE_PTHREAD_ARG)
|
||||||
ELSE(THREADS_HAVE_PTHREAD_ARG)
|
ENDIF(THREADS_HAVE_PTHREAD_ARG)
|
||||||
CHECK_LIBRARY_EXISTS(pthreads pthread_create "" CMAKE_HAVE_PTHREADS_CREATE)
|
ENDIF(NOT CMAKE_HAVE_THREADS_LIBRARY)
|
||||||
IF(CMAKE_HAVE_PTHREADS_CREATE)
|
ENDIF(CMAKE_HAVE_PTHREAD_H)
|
||||||
SET(CMAKE_THREAD_LIBS_INIT "-lpthreads")
|
|
||||||
ENDIF(CMAKE_HAVE_PTHREADS_CREATE)
|
|
||||||
CHECK_LIBRARY_EXISTS(pthread pthread_create "" CMAKE_HAVE_PTHREAD_CREATE)
|
|
||||||
IF(CMAKE_HAVE_PTHREAD_CREATE)
|
|
||||||
SET(CMAKE_THREAD_LIBS_INIT "-lpthread")
|
|
||||||
ENDIF(CMAKE_HAVE_PTHREAD_CREATE)
|
|
||||||
IF(CMAKE_SYSTEM MATCHES "SunOS.*")
|
|
||||||
CHECK_LIBRARY_EXISTS(thread thr_create "" CMAKE_HAVE_THR_CREATE)
|
|
||||||
IF(CMAKE_HAVE_THR_CREATE)
|
|
||||||
SET(CMAKE_THREAD_LIBS_INIT "-lthread")
|
|
||||||
ENDIF(CMAKE_HAVE_THR_CREATE)
|
|
||||||
ENDIF(CMAKE_SYSTEM MATCHES "SunOS.*")
|
|
||||||
ENDIF(THREADS_HAVE_PTHREAD_ARG)
|
|
||||||
ENDIF(NOT CMAKE_HAVE_SPROC_H)
|
|
||||||
ENDIF(CMAKE_HAVE_PTHREAD_H)
|
|
||||||
|
|
||||||
IF(CMAKE_HAVE_SPROC_H)
|
|
||||||
SET(CMAKE_USE_SPROC_INIT 1)
|
|
||||||
ENDIF(CMAKE_HAVE_SPROC_H)
|
ENDIF(CMAKE_HAVE_SPROC_H)
|
||||||
|
|
||||||
IF(CMAKE_THREAD_LIBS_INIT)
|
IF(CMAKE_THREAD_LIBS_INIT)
|
||||||
SET(CMAKE_USE_PTHREADS_INIT 1)
|
SET(CMAKE_USE_PTHREADS_INIT 1)
|
||||||
ENDIF(CMAKE_THREAD_LIBS_INIT)
|
ENDIF(CMAKE_THREAD_LIBS_INIT)
|
||||||
|
|
18
bootstrap
18
bootstrap
|
@ -218,12 +218,14 @@ cmake_try_run ()
|
||||||
# Run a make test. First argument is the make interpreter.
|
# Run a make test. First argument is the make interpreter.
|
||||||
cmake_try_make ()
|
cmake_try_make ()
|
||||||
{
|
{
|
||||||
MAKE_PROC=$1
|
MAKE_PROC="$1"
|
||||||
|
MAKE_FLAGS="$2"
|
||||||
echo "Try: ${MAKE_PROC}"
|
echo "Try: ${MAKE_PROC}"
|
||||||
${MAKE_PROC}
|
"${MAKE_PROC}" ${MAKE_FLAGS}
|
||||||
RES=$?
|
RES=$?
|
||||||
if [ "${RES}" -ne "0" ]; then
|
if [ "${RES}" -ne "0" ]; then
|
||||||
echo "${MAKE_PROC} does not work";return 1
|
echo "${MAKE_PROC} does not work"
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
if [ ! -f "test" ] && [ ! -f "test.exe" ]; then
|
if [ ! -f "test" ] && [ ! -f "test.exe" ]; then
|
||||||
echo "${COMPILER} does not produce output"
|
echo "${COMPILER} does not produce output"
|
||||||
|
@ -397,6 +399,7 @@ echo "C++ compiler on this system is: ${cmake_cxx_compiler} ${cmake_cxx_flags}"
|
||||||
# Test Make
|
# Test Make
|
||||||
|
|
||||||
cmake_make_processor=
|
cmake_make_processor=
|
||||||
|
cmake_make_flags=
|
||||||
|
|
||||||
# If MAKE is set, use that for make processor, otherwise use list of known make
|
# If MAKE is set, use that for make processor, otherwise use list of known make
|
||||||
if [ -n "${MAKE}" ]; then
|
if [ -n "${MAKE}" ]; then
|
||||||
|
@ -411,14 +414,17 @@ mkdir "${cmake_bootstrap_dir}/${TMPFILE}"
|
||||||
cd "${cmake_bootstrap_dir}/${TMPFILE}"
|
cd "${cmake_bootstrap_dir}/${TMPFILE}"
|
||||||
cat>"Makefile"<<EOF
|
cat>"Makefile"<<EOF
|
||||||
test: test.c
|
test: test.c
|
||||||
${cmake_c_compiler} -o test test.c
|
"${cmake_c_compiler}" -o test test.c
|
||||||
EOF
|
EOF
|
||||||
cat>"test.c"<<EOF
|
cat>"test.c"<<EOF
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
int main(){ printf("1\n"); return 0; }
|
int main(){ printf("1\n"); return 0; }
|
||||||
EOF
|
EOF
|
||||||
|
if [ "x${cmake_parallel_make}" != "x" ]; then
|
||||||
|
cmake_make_flags="${cmake_make_flags} -j ${cmake_parallel_make}"
|
||||||
|
fi
|
||||||
for a in ${cmake_make_processors}; do
|
for a in ${cmake_make_processors}; do
|
||||||
if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" >> cmake_bootstrap.log 2>&1; then
|
if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> cmake_bootstrap.log 2>&1; then
|
||||||
cmake_make_processor="${a}"
|
cmake_make_processor="${a}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -680,7 +686,7 @@ echo "---------------------------------------------"
|
||||||
|
|
||||||
# Run make to build bootstrap cmake
|
# Run make to build bootstrap cmake
|
||||||
if [ "x${cmake_parallel_make}" != "x" ]; then
|
if [ "x${cmake_parallel_make}" != "x" ]; then
|
||||||
${cmake_make_processor} -j ${cmake_parallel_make}
|
${cmake_make_processor} ${cmake_make_flags}
|
||||||
else
|
else
|
||||||
${cmake_make_processor}
|
${cmake_make_processor}
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue