Skip to content

Commit fe46778

Browse files
authored
fix: threads are always enabled (#1036)
1 parent 6d23649 commit fe46778

File tree

3 files changed

+8
-27
lines changed

3 files changed

+8
-27
lines changed

CMakeLists.txt

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,12 @@ option (WITH_GFLAGS "Use gflags" ON)
3939
option (WITH_GTEST "Use Google Test" ON)
4040
option (WITH_PKGCONFIG "Enable pkg-config support" OFF)
4141
option (WITH_SYMBOLIZE "Enable symbolize module" ON)
42-
option (WITH_THREADS "Enable multithreading support" ON)
42+
option (WITH_TLS "Enable Thread Local Storage (TLS) support" ON)
4343

4444
set (WITH_UNWIND libunwind CACHE STRING "unwind driver")
4545
set_property (CACHE WITH_UNWIND PROPERTY STRINGS none unwind libunwind)
4646

4747
cmake_dependent_option (WITH_GMOCK "Use Google Mock" ON WITH_GTEST OFF)
48-
cmake_dependent_option (WITH_TLS "Enable Thread Local Storage (TLS) support" ON WITH_THREADS OFF)
4948

5049
set (WITH_FUZZING none CACHE STRING "Fuzzing engine")
5150
set_property (CACHE WITH_FUZZING PROPERTY STRINGS none libfuzzer ossfuzz)
@@ -58,10 +57,6 @@ if (NOT WITH_GTEST)
5857
set (CMAKE_DISABLE_FIND_PACKAGE_GTest ON)
5958
endif (NOT WITH_GTEST)
6059

61-
if (NOT WITH_THREADS)
62-
set (CMAKE_DISABLE_FIND_PACKAGE_Threads ON)
63-
endif (NOT WITH_THREADS)
64-
6560
set (CMAKE_C_VISIBILITY_PRESET hidden)
6661
set (CMAKE_CXX_VISIBILITY_PRESET hidden)
6762
set (CMAKE_POSITION_INDEPENDENT_CODE ON)
@@ -88,7 +83,7 @@ if (WITH_GFLAGS)
8883
endif (gflags_FOUND)
8984
endif (WITH_GFLAGS)
9085

91-
find_package (Threads)
86+
find_package (Threads REQUIRED)
9287
find_package (Unwind)
9388

9489
if (Unwind_FOUND)
@@ -288,14 +283,6 @@ check_cxx_symbol_exists (localtime_r "cstdlib;ctime" HAVE_LOCALTIME_R)
288283

289284
set (SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P})
290285

291-
if (WITH_THREADS AND Threads_FOUND)
292-
if (CMAKE_USE_PTHREADS_INIT)
293-
set (HAVE_PTHREAD 1)
294-
endif (CMAKE_USE_PTHREADS_INIT)
295-
else (WITH_THREADS AND Threads_FOUND)
296-
set (NO_THREADS 1)
297-
endif (WITH_THREADS AND Threads_FOUND)
298-
299286
# fopen/open on Cygwin can not handle unix-type paths like /home/....
300287
# therefore we translate TEST_SRC_DIR to windows-path.
301288
if (CYGWIN)
@@ -434,15 +421,11 @@ if (HAVE_DBGHELP)
434421
set (glog_libraries_options_for_static_linking "${glog_libraries_options_for_static_linking} -ldbghelp")
435422
endif (HAVE_DBGHELP)
436423

437-
if (HAVE_PTHREAD)
438-
target_link_libraries (glog PRIVATE Threads::Threads)
439-
440-
set (Threads_DEPENDENCY "find_dependency (Threads)")
424+
target_link_libraries (glog PRIVATE Threads::Threads)
441425

442-
if (CMAKE_THREAD_LIBS_INIT)
443-
set (glog_libraries_options_for_static_linking "${glog_libraries_options_for_static_linking} ${CMAKE_THREAD_LIBS_INIT}")
444-
endif (CMAKE_THREAD_LIBS_INIT)
445-
endif (HAVE_PTHREAD)
426+
if (CMAKE_THREAD_LIBS_INIT)
427+
set (glog_libraries_options_for_static_linking "${glog_libraries_options_for_static_linking} ${CMAKE_THREAD_LIBS_INIT}")
428+
endif (CMAKE_THREAD_LIBS_INIT)
446429

447430
if (gflags_FOUND)
448431
# Prefer the gflags target that uses double colon convention

glog-config.cmake.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ endif (CMAKE_VERSION VERSION_LESS @glog_CMake_VERSION@)
77
include (CMakeFindDependencyMacro)
88
include (${CMAKE_CURRENT_LIST_DIR}/glog-modules.cmake)
99

10+
find_dependency (Threads)
11+
1012
@gflags_DEPENDENCY@
11-
@Threads_DEPENDENCY@
1213
@Unwind_DEPENDENCY@
1314

1415
include (${CMAKE_CURRENT_LIST_DIR}/glog-targets.cmake)

src/config.h.cmake.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@
2828
/* define if you have dbghelp library */
2929
#cmakedefine HAVE_DBGHELP
3030

31-
/* define to disable multithreading support. */
32-
#cmakedefine NO_THREADS
33-
3431
/* Define if you have the 'pread' function */
3532
#cmakedefine HAVE_PREAD
3633

0 commit comments

Comments
 (0)