From 0b38424cf26fea866c54b75347de0c5c8a8d15d3 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Tue, 22 Sep 2015 05:46:56 +0200 Subject: 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. --- Modules/FindThreads.cmake | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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") -- cgit v0.12