mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-18 00:02:21 +08:00
FindThreads: Reduce amount of false positive error logging
When a CMake based project fails, users start looking at CMakeError.log and think that the FindThread output is the problem, but it is a false positive. Now FindThreads only logs to `CMakeError.log` when it fails to find a suitable flag, reducing the amount of false positives in `CMakeError.log`. Fixes #16540, Fixes #19344
This commit is contained in:
@@ -119,7 +119,10 @@ macro(_check_pthreads_flag)
|
|||||||
${CMAKE_BINARY_DIR}
|
${CMAKE_BINARY_DIR}
|
||||||
${_threads_src}
|
${_threads_src}
|
||||||
CMAKE_FLAGS -DLINK_LIBRARIES:STRING=-pthread
|
CMAKE_FLAGS -DLINK_LIBRARIES:STRING=-pthread
|
||||||
OUTPUT_VARIABLE OUTPUT)
|
OUTPUT_VARIABLE _cmake_check_pthreads_output)
|
||||||
|
|
||||||
|
string(APPEND _cmake_find_threads_output "${_cmake_check_pthreads_output}")
|
||||||
|
unset(_cmake_check_pthreads_output)
|
||||||
unset(_threads_src)
|
unset(_threads_src)
|
||||||
|
|
||||||
if(THREADS_HAVE_PTHREAD_ARG)
|
if(THREADS_HAVE_PTHREAD_ARG)
|
||||||
@@ -127,9 +130,6 @@ macro(_check_pthreads_flag)
|
|||||||
message(CHECK_PASS "yes")
|
message(CHECK_PASS "yes")
|
||||||
else()
|
else()
|
||||||
message(CHECK_FAIL "no")
|
message(CHECK_FAIL "no")
|
||||||
file(APPEND
|
|
||||||
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
|
||||||
"Determining if compiler accepts -pthread failed with the following output:\n${OUTPUT}\n\n")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
@@ -249,4 +249,10 @@ if(THREADS_FOUND AND NOT TARGET Threads::Threads)
|
|||||||
if(CMAKE_THREAD_LIBS_INIT)
|
if(CMAKE_THREAD_LIBS_INIT)
|
||||||
set_property(TARGET Threads::Threads PROPERTY INTERFACE_LINK_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}")
|
set_property(TARGET Threads::Threads PROPERTY INTERFACE_LINK_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}")
|
||||||
endif()
|
endif()
|
||||||
|
elseif(NOT THREADS_FOUND AND _cmake_find_threads_output)
|
||||||
|
file(APPEND
|
||||||
|
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
||||||
|
"Determining if compiler accepts -pthread failed with the following output:\n${_cmake_find_threads_output}\n\n")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
unset(_cmake_find_threads_output)
|
||||||
|
Reference in New Issue
Block a user