summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Cedilnik <andy.cedilnik@kitware.com>2003-08-22 13:52:05 (GMT)
committerAndy Cedilnik <andy.cedilnik@kitware.com>2003-08-22 13:52:05 (GMT)
commit21ec23413e1bc722f2ede890c0afff01fbe6bbcf (patch)
treeaf4a83e6c67c79692fa9fbf0662c02a82b8260fd
parenta413160fecc73bf61fccff9b74d6e18349eeb861 (diff)
downloadCMake-21ec23413e1bc722f2ede890c0afff01fbe6bbcf.zip
CMake-21ec23413e1bc722f2ede890c0afff01fbe6bbcf.tar.gz
CMake-21ec23413e1bc722f2ede890c0afff01fbe6bbcf.tar.bz2
ERR: Reorganize to try to fix the -pthread problem on some systems
-rw-r--r--Modules/FindThreads.cmake71
-rwxr-xr-xbootstrap18
2 files changed, 55 insertions, 34 deletions
diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake
index 403f98f..c183f42 100644
--- a/Modules/FindThreads.cmake
+++ b/Modules/FindThreads.cmake
@@ -9,14 +9,46 @@
INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
INCLUDE (${CMAKE_ROOT}/Modules/CheckLibraryExists.cmake)
+# Do we have sproc?
IF(CMAKE_SYSTEM MATCHES IRIX)
CHECK_INCLUDE_FILE("sys/prctl.h" CMAKE_HAVE_SPROC_H)
ENDIF(CMAKE_SYSTEM MATCHES IRIX)
-CHECK_INCLUDE_FILE("pthread.h" CMAKE_HAVE_PTHREAD_H)
-IF(CMAKE_HAVE_PTHREAD_H)
- IF(NOT CMAKE_HAVE_SPROC_H)
- IF(NOT APPLE)
+IF(CMAKE_HAVE_SPROC_H)
+ # We have sproc
+ SET(CMAKE_USE_SPROC_INIT 1)
+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")
MESSAGE(STATUS "Check if compiler accepts -pthread")
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")
ENDIF(THREADS_HAVE_PTHREAD_ARG)
ENDIF("THREADS_HAVE_PTHREAD_ARG" MATCHES "^THREADS_HAVE_PTHREAD_ARG")
- ENDIF(NOT APPLE)
- IF(THREADS_HAVE_PTHREAD_ARG)
- SET(CMAKE_THREAD_LIBS_INIT "-pthread")
- ELSE(THREADS_HAVE_PTHREAD_ARG)
- CHECK_LIBRARY_EXISTS(pthreads pthread_create "" CMAKE_HAVE_PTHREADS_CREATE)
- IF(CMAKE_HAVE_PTHREADS_CREATE)
- 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)
+ IF(THREADS_HAVE_PTHREAD_ARG)
+ SET(CMAKE_THREAD_LIBS_INIT "-pthread")
+ ELSE(THREADS_HAVE_PTHREAD_ARG)
+ ENDIF(THREADS_HAVE_PTHREAD_ARG)
+ ENDIF(NOT CMAKE_HAVE_THREADS_LIBRARY)
+ ENDIF(CMAKE_HAVE_PTHREAD_H)
ENDIF(CMAKE_HAVE_SPROC_H)
+
IF(CMAKE_THREAD_LIBS_INIT)
SET(CMAKE_USE_PTHREADS_INIT 1)
ENDIF(CMAKE_THREAD_LIBS_INIT)
diff --git a/bootstrap b/bootstrap
index 8e793bd..3403929 100755
--- a/bootstrap
+++ b/bootstrap
@@ -218,12 +218,14 @@ cmake_try_run ()
# Run a make test. First argument is the make interpreter.
cmake_try_make ()
{
- MAKE_PROC=$1
+ MAKE_PROC="$1"
+ MAKE_FLAGS="$2"
echo "Try: ${MAKE_PROC}"
- ${MAKE_PROC}
+ "${MAKE_PROC}" ${MAKE_FLAGS}
RES=$?
if [ "${RES}" -ne "0" ]; then
- echo "${MAKE_PROC} does not work";return 1
+ echo "${MAKE_PROC} does not work"
+ return 1
fi
if [ ! -f "test" ] && [ ! -f "test.exe" ]; then
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
cmake_make_processor=
+cmake_make_flags=
# If MAKE is set, use that for make processor, otherwise use list of known make
if [ -n "${MAKE}" ]; then
@@ -411,14 +414,17 @@ mkdir "${cmake_bootstrap_dir}/${TMPFILE}"
cd "${cmake_bootstrap_dir}/${TMPFILE}"
cat>"Makefile"<<EOF
test: test.c
- ${cmake_c_compiler} -o test test.c
+ "${cmake_c_compiler}" -o test test.c
EOF
cat>"test.c"<<EOF
#include <stdio.h>
int main(){ printf("1\n"); return 0; }
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
- 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}"
fi
done
@@ -680,7 +686,7 @@ echo "---------------------------------------------"
# Run make to build bootstrap cmake
if [ "x${cmake_parallel_make}" != "x" ]; then
- ${cmake_make_processor} -j ${cmake_parallel_make}
+ ${cmake_make_processor} ${cmake_make_flags}
else
${cmake_make_processor}
fi