CMake: Link thread library only when necessary
Use CMAKE_THREAD_LIBS_INIT instead of always linking -pthread.
This commit is contained in:
parent
bf971fb0a8
commit
d8d393e4b8
3 changed files with 6 additions and 13 deletions
|
|
@ -178,12 +178,8 @@ function(wx_write_config)
|
|||
|
||||
set(CC ${CMAKE_C_COMPILER})
|
||||
set(CXX ${CMAKE_CXX_COMPILER})
|
||||
set(WXCONFIG_CFLAGS)
|
||||
set(WXCONFIG_LDFLAGS)
|
||||
if(CMAKE_USE_PTHREADS_INIT)
|
||||
set(WXCONFIG_CFLAGS "-pthread")
|
||||
set(WXCONFIG_LDFLAGS "-pthread")
|
||||
endif()
|
||||
set(WXCONFIG_CFLAGS ${CMAKE_THREAD_LIBS_INIT})
|
||||
set(WXCONFIG_LDFLAGS ${CMAKE_THREAD_LIBS_INIT})
|
||||
set(WXCONFIG_CPPFLAGS)
|
||||
if(wxBUILD_SHARED)
|
||||
wx_string_append(WXCONFIG_CPPFLAGS " -DWXUSINGDLL")
|
||||
|
|
|
|||
|
|
@ -177,12 +177,9 @@ function(wx_set_common_target_properties target_name)
|
|||
target_compile_definitions(${target_name} PUBLIC "-D_FILE_OFFSET_BITS=64")
|
||||
endif()
|
||||
|
||||
if(CMAKE_USE_PTHREADS_INIT)
|
||||
target_compile_options(${target_name} PRIVATE "-pthread")
|
||||
# clang++.exe: warning: argument unused during compilation: '-pthread' [-Wunused-command-line-argument]
|
||||
if(NOT (WIN32 AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"))
|
||||
set_target_properties(${target_name} PROPERTIES LINK_FLAGS "-pthread")
|
||||
endif()
|
||||
if(CMAKE_THREAD_LIBS_INIT)
|
||||
target_compile_options(${target_name} PRIVATE ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries(${target_name} PUBLIC ${CMAKE_THREAD_LIBS_INIT})
|
||||
endif()
|
||||
wx_set_source_groups()
|
||||
endfunction()
|
||||
|
|
|
|||
|
|
@ -403,7 +403,7 @@ endif(UNIX)
|
|||
|
||||
if(CMAKE_USE_PTHREADS_INIT)
|
||||
cmake_push_check_state(RESET)
|
||||
set(CMAKE_REQUIRED_LIBRARIES pthread)
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
|
||||
wx_check_cxx_source_compiles("
|
||||
void *p;
|
||||
pthread_cleanup_push(ThreadCleanupFunc, p);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue