diff options
author | Brad King <brad.king@kitware.com> | 2022-04-14 17:04:43 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-04-26 17:54:53 (GMT) |
commit | cbe7550d998def869d297b2bf6e3d9b8689e33de (patch) | |
tree | feace4db65a9c3a53e0c4b891d3d022d51cf1255 /Modules/FindThreads.cmake | |
parent | 1ee8c545ddb270c282f896157616e91c41c80880 (diff) | |
download | CMake-cbe7550d998def869d297b2bf6e3d9b8689e33de.zip CMake-cbe7550d998def869d297b2bf6e3d9b8689e33de.tar.gz CMake-cbe7550d998def869d297b2bf6e3d9b8689e33de.tar.bz2 |
FindThreads: Remove unnecessary condition
The `THREADS_HAVE_PTHREAD_ARG` cache entry cannot be defined unless
FindThreads has already been executed, perhaps by a previous run of
CMake, or a previous `find_package(Threads)` call. In that case, the
other alternatives will also already have been checked and results
cached.
Diffstat (limited to 'Modules/FindThreads.cmake')
-rw-r--r-- | Modules/FindThreads.cmake | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake index 13c8c5c..ed0bb8b 100644 --- a/Modules/FindThreads.cmake +++ b/Modules/FindThreads.cmake @@ -152,33 +152,32 @@ if(CMAKE_HAVE_PTHREAD_H) # We have pthread.h # Let's check for the library now. # - if(NOT THREADS_HAVE_PTHREAD_ARG) - # Check if pthread functions are in normal C library. - # We list some pthread functions in PTHREAD_C_CXX_TEST_SOURCE test code. - # If the pthread functions already exist in C library, we could just use - # them instead of linking to the additional pthread library. - if(CMAKE_C_COMPILER_LOADED) - CHECK_C_SOURCE_COMPILES("${PTHREAD_C_CXX_TEST_SOURCE}" CMAKE_HAVE_LIBC_PTHREAD) - elseif(CMAKE_CXX_COMPILER_LOADED) - CHECK_CXX_SOURCE_COMPILES("${PTHREAD_C_CXX_TEST_SOURCE}" CMAKE_HAVE_LIBC_PTHREAD) - endif() - if(CMAKE_HAVE_LIBC_PTHREAD) - set(CMAKE_THREAD_LIBS_INIT "") - set(Threads_FOUND TRUE) - else() - # Check for -pthread first if enabled. This is the recommended - # way, but not backwards compatible as one must also pass -pthread - # as compiler flag then. - if (THREADS_PREFER_PTHREAD_FLAG) - _threads_check_flag_pthread() - endif () - - if(CMAKE_SYSTEM MATCHES "GHS-MULTI") - _threads_check_lib(posix pthread_create CMAKE_HAVE_PTHREADS_CREATE) - endif() - _threads_check_lib(pthreads pthread_create CMAKE_HAVE_PTHREADS_CREATE) - _threads_check_lib(pthread pthread_create CMAKE_HAVE_PTHREAD_CREATE) + + # Check if pthread functions are in normal C library. + # We list some pthread functions in PTHREAD_C_CXX_TEST_SOURCE test code. + # If the pthread functions already exist in C library, we could just use + # them instead of linking to the additional pthread library. + if(CMAKE_C_COMPILER_LOADED) + CHECK_C_SOURCE_COMPILES("${PTHREAD_C_CXX_TEST_SOURCE}" CMAKE_HAVE_LIBC_PTHREAD) + elseif(CMAKE_CXX_COMPILER_LOADED) + CHECK_CXX_SOURCE_COMPILES("${PTHREAD_C_CXX_TEST_SOURCE}" CMAKE_HAVE_LIBC_PTHREAD) + endif() + if(CMAKE_HAVE_LIBC_PTHREAD) + set(CMAKE_THREAD_LIBS_INIT "") + set(Threads_FOUND TRUE) + else() + # Check for -pthread first if enabled. This is the recommended + # way, but not backwards compatible as one must also pass -pthread + # as compiler flag then. + if (THREADS_PREFER_PTHREAD_FLAG) + _threads_check_flag_pthread() + endif () + + if(CMAKE_SYSTEM MATCHES "GHS-MULTI") + _threads_check_lib(posix pthread_create CMAKE_HAVE_PTHREADS_CREATE) endif() + _threads_check_lib(pthreads pthread_create CMAKE_HAVE_PTHREADS_CREATE) + _threads_check_lib(pthread pthread_create CMAKE_HAVE_PTHREAD_CREATE) endif() _threads_check_flag_pthread() |