summaryrefslogtreecommitdiffstats
path: root/Modules/FindThreads.cmake
diff options
context:
space:
mode:
authorRolf Eike Beer <eike@sf-mail.de>2015-09-22 03:46:56 (GMT)
committerBrad King <brad.king@kitware.com>2015-09-25 14:08:05 (GMT)
commit0b38424cf26fea866c54b75347de0c5c8a8d15d3 (patch)
tree550c298e80b7987c21c26254c5f884655c35ba65 /Modules/FindThreads.cmake
parent9924a212f671dfcc2b20d2a29da23bc440247f19 (diff)
downloadCMake-0b38424cf26fea866c54b75347de0c5c8a8d15d3.zip
CMake-0b38424cf26fea866c54b75347de0c5c8a8d15d3.tar.gz
CMake-0b38424cf26fea866c54b75347de0c5c8a8d15d3.tar.bz2
FindThreads: make the call to try_run() work also if only C++ is enabled
This isn't enough to make the whole module work with only C++ enabled.
Diffstat (limited to 'Modules/FindThreads.cmake')
-rw-r--r--Modules/FindThreads.cmake9
1 files changed, 8 insertions, 1 deletions
diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake
index 88da7c5..c607923 100644
--- a/Modules/FindThreads.cmake
+++ b/Modules/FindThreads.cmake
@@ -91,11 +91,18 @@ macro(_check_pthreads_flag)
# If we did not found -lpthread, -lpthread, or -lthread, look for -pthread
if(NOT DEFINED THREADS_HAVE_PTHREAD_ARG)
message(STATUS "Check if compiler accepts -pthread")
+ if(CMAKE_C_COMPILER_LOADED)
+ set(_threads_src ${CMAKE_CURRENT_LIST_DIR}/CheckForPthreads.c)
+ elseif(CMAKE_CXX_COMPILER_LOADED)
+ 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
${CMAKE_BINARY_DIR}
- ${CMAKE_CURRENT_LIST_DIR}/CheckForPthreads.c
+ ${_threads_src}
CMAKE_FLAGS -DLINK_LIBRARIES:STRING=-pthread
COMPILE_OUTPUT_VARIABLE OUTPUT)
+ unset(_threads_src)
if(THREADS_HAVE_PTHREAD_ARG)
if(THREADS_PTHREAD_ARG STREQUAL "2")