diff --git a/CMakeLists.txt b/CMakeLists.txt index fc5eb7a31..5b2e52c1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,13 +39,12 @@ option (WITH_GFLAGS "Use gflags" ON) option (WITH_GTEST "Use Google Test" ON) option (WITH_PKGCONFIG "Enable pkg-config support" OFF) option (WITH_SYMBOLIZE "Enable symbolize module" ON) -option (WITH_THREADS "Enable multithreading support" ON) +option (WITH_TLS "Enable Thread Local Storage (TLS) support" ON) set (WITH_UNWIND libunwind CACHE STRING "unwind driver") set_property (CACHE WITH_UNWIND PROPERTY STRINGS none unwind libunwind) cmake_dependent_option (WITH_GMOCK "Use Google Mock" ON WITH_GTEST OFF) -cmake_dependent_option (WITH_TLS "Enable Thread Local Storage (TLS) support" ON WITH_THREADS OFF) set (WITH_FUZZING none CACHE STRING "Fuzzing engine") set_property (CACHE WITH_FUZZING PROPERTY STRINGS none libfuzzer ossfuzz) @@ -58,10 +57,6 @@ if (NOT WITH_GTEST) set (CMAKE_DISABLE_FIND_PACKAGE_GTest ON) endif (NOT WITH_GTEST) -if (NOT WITH_THREADS) - set (CMAKE_DISABLE_FIND_PACKAGE_Threads ON) -endif (NOT WITH_THREADS) - set (CMAKE_C_VISIBILITY_PRESET hidden) set (CMAKE_CXX_VISIBILITY_PRESET hidden) set (CMAKE_POSITION_INDEPENDENT_CODE ON) @@ -88,7 +83,7 @@ if (WITH_GFLAGS) endif (gflags_FOUND) endif (WITH_GFLAGS) -find_package (Threads) +find_package (Threads REQUIRED) find_package (Unwind) if (Unwind_FOUND) @@ -288,14 +283,6 @@ check_cxx_symbol_exists (localtime_r "cstdlib;ctime" HAVE_LOCALTIME_R) set (SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P}) -if (WITH_THREADS AND Threads_FOUND) - if (CMAKE_USE_PTHREADS_INIT) - set (HAVE_PTHREAD 1) - endif (CMAKE_USE_PTHREADS_INIT) -else (WITH_THREADS AND Threads_FOUND) - set (NO_THREADS 1) -endif (WITH_THREADS AND Threads_FOUND) - # fopen/open on Cygwin can not handle unix-type paths like /home/.... # therefore we translate TEST_SRC_DIR to windows-path. if (CYGWIN) @@ -434,15 +421,11 @@ if (HAVE_DBGHELP) set (glog_libraries_options_for_static_linking "${glog_libraries_options_for_static_linking} -ldbghelp") endif (HAVE_DBGHELP) -if (HAVE_PTHREAD) - target_link_libraries (glog PRIVATE Threads::Threads) - - set (Threads_DEPENDENCY "find_dependency (Threads)") +target_link_libraries (glog PRIVATE Threads::Threads) - if (CMAKE_THREAD_LIBS_INIT) - set (glog_libraries_options_for_static_linking "${glog_libraries_options_for_static_linking} ${CMAKE_THREAD_LIBS_INIT}") - endif (CMAKE_THREAD_LIBS_INIT) -endif (HAVE_PTHREAD) +if (CMAKE_THREAD_LIBS_INIT) + set (glog_libraries_options_for_static_linking "${glog_libraries_options_for_static_linking} ${CMAKE_THREAD_LIBS_INIT}") +endif (CMAKE_THREAD_LIBS_INIT) if (gflags_FOUND) # Prefer the gflags target that uses double colon convention diff --git a/glog-config.cmake.in b/glog-config.cmake.in index 36e38c4c8..7d985257b 100644 --- a/glog-config.cmake.in +++ b/glog-config.cmake.in @@ -7,8 +7,9 @@ endif (CMAKE_VERSION VERSION_LESS @glog_CMake_VERSION@) include (CMakeFindDependencyMacro) include (${CMAKE_CURRENT_LIST_DIR}/glog-modules.cmake) +find_dependency (Threads) + @gflags_DEPENDENCY@ -@Threads_DEPENDENCY@ @Unwind_DEPENDENCY@ include (${CMAKE_CURRENT_LIST_DIR}/glog-targets.cmake) diff --git a/src/config.h.cmake.in b/src/config.h.cmake.in index b02bc0dbe..1aec46119 100644 --- a/src/config.h.cmake.in +++ b/src/config.h.cmake.in @@ -28,9 +28,6 @@ /* define if you have dbghelp library */ #cmakedefine HAVE_DBGHELP -/* define to disable multithreading support. */ -#cmakedefine NO_THREADS - /* Define if you have the 'pread' function */ #cmakedefine HAVE_PREAD