Skip to content

Commit 44b06d7

Browse files
committed
CMake: Link Threads the old-style
If linked against Threads::Threads target while building static libraries, cmake cannot find the threads library while trying to use the installed target afterwards
1 parent eee07e6 commit 44b06d7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

simdjson-flags.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ endif()
7373
option(SIMDJSON_ENABLE_THREADS "Enable threaded operation" ON)
7474
if(SIMDJSON_ENABLE_THREADS)
7575
find_package(Threads REQUIRED)
76-
target_link_libraries(simdjson-flags INTERFACE Threads::Threads)
76+
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
77+
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
78+
target_link_libraries(simdjson-flags INTERFACE ${CMAKE_THREAD_LIBS_INIT} )
7779
endif()
7880

7981
option(SIMDJSON_SANITIZE "Sanitize addresses" OFF)

0 commit comments

Comments
 (0)