summaryrefslogtreecommitdiff
path: root/Modules/FindThreads.cmake
diff options
context:
space:
mode:
authorSteffen Dettmer <steffen.dettmer@gmail.com>2017-08-07 15:30:33 +0200
committerBrad King <brad.king@kitware.com>2017-08-30 11:15:26 -0400
commitd4e551a90b6bf6ea4e18fa408f40f39df6ad6fb4 (patch)
treee4cee46c80dc73ac13894598d50ddc3b7ff2e693 /Modules/FindThreads.cmake
parentf4aa346538433f4c89a9963d74ea5d3f9bd60390 (diff)
downloadcmake-d4e551a90b6bf6ea4e18fa408f40f39df6ad6fb4.tar.gz
FindThreads: Drop try_run to improve cross-compiling support
Use `try_compile` instead of `try_run`. It is not clear why `try_run` was ever needed, and it does not work during cross-compiling. Update the check's source file to remove code associated with actually running things. Also remove the ancient `__CLASSIC_C__` code path and use a simple `int main(void)` as in `Modules/CheckIncludeFile.c.in`. Fixes: #16920
Diffstat (limited to 'Modules/FindThreads.cmake')
-rw-r--r--Modules/FindThreads.cmake15
1 files changed, 4 insertions, 11 deletions
diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake
index 2c6a58bebb..a0148dd900 100644
--- a/Modules/FindThreads.cmake
+++ b/Modules/FindThreads.cmake
@@ -86,23 +86,16 @@ macro(_check_pthreads_flag)
set(_threads_src ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindThreads/CheckForPthreads.cxx)
configure_file(${CMAKE_CURRENT_LIST_DIR}/CheckForPthreads.c "${_threads_src}" COPYONLY)
endif()
- try_run(THREADS_PTHREAD_ARG THREADS_HAVE_PTHREAD_ARG
+ try_compile(THREADS_HAVE_PTHREAD_ARG
${CMAKE_BINARY_DIR}
${_threads_src}
CMAKE_FLAGS -DLINK_LIBRARIES:STRING=-pthread
- COMPILE_OUTPUT_VARIABLE OUTPUT)
+ OUTPUT_VARIABLE OUTPUT)
unset(_threads_src)
if(THREADS_HAVE_PTHREAD_ARG)
- if(THREADS_PTHREAD_ARG STREQUAL "2")
- set(Threads_FOUND TRUE)
- message(STATUS "Check if compiler accepts -pthread - yes")
- else()
- message(STATUS "Check if compiler accepts -pthread - no")
- file(APPEND
- ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
- "Determining if compiler accepts -pthread returned ${THREADS_PTHREAD_ARG} instead of 2. The compiler had the following output:\n${OUTPUT}\n\n")
- endif()
+ set(Threads_FOUND TRUE)
+ message(STATUS "Check if compiler accepts -pthread - yes")
else()
message(STATUS "Check if compiler accepts -pthread - no")
file(APPEND