Skip to content

Commit d641b6b

Browse files
authored
Limit use of Posix threads to Unix (#4140)
Posix threads are available only on Unix (and unix like) platforms. Wrap the dependency accordingly so builds don't fail on other platforms. Signed-off-by: HS <[email protected]>
1 parent 90c4433 commit d641b6b

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

runtime/Cpp/runtime/CMakeLists.txt

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,18 @@ if (ANTLR_BUILD_STATIC)
3939
add_library(antlr4_static STATIC ${libantlrcpp_SRC})
4040
endif()
4141

42-
# Make sure to link against threads (pthreads) library in order to be able to
43-
# make use of std::call_once in the code without producing runtime errors
44-
# (see also https://github.com/antlr/antlr4/issues/3708 and/or https://stackoverflow.com/q/51584960).
45-
find_package(Threads REQUIRED)
42+
if (CMAKE_HOST_UNIX)
43+
# Make sure to link against threads (pthreads) library in order to be able to
44+
# make use of std::call_once in the code without producing runtime errors
45+
# (see also https://github.com/antlr/antlr4/issues/3708 and/or https://stackoverflow.com/q/51584960).
46+
find_package(Threads REQUIRED)
4647

47-
if (TARGET antlr4_shared)
48-
target_link_libraries(antlr4_shared Threads::Threads)
49-
endif()
50-
if (TARGET antlr4_static)
51-
target_link_libraries(antlr4_static Threads::Threads)
48+
if (TARGET antlr4_shared)
49+
target_link_libraries(antlr4_shared Threads::Threads)
50+
endif()
51+
if (TARGET antlr4_static)
52+
target_link_libraries(antlr4_static Threads::Threads)
53+
endif()
5254
endif()
5355

5456
IF(TRACE_ATN)

0 commit comments

Comments
 (0)