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(CC ${CMAKE_C_COMPILER})
|
||||||
set(CXX ${CMAKE_CXX_COMPILER})
|
set(CXX ${CMAKE_CXX_COMPILER})
|
||||||
set(WXCONFIG_CFLAGS)
|
set(WXCONFIG_CFLAGS ${CMAKE_THREAD_LIBS_INIT})
|
||||||
set(WXCONFIG_LDFLAGS)
|
set(WXCONFIG_LDFLAGS ${CMAKE_THREAD_LIBS_INIT})
|
||||||
if(CMAKE_USE_PTHREADS_INIT)
|
|
||||||
set(WXCONFIG_CFLAGS "-pthread")
|
|
||||||
set(WXCONFIG_LDFLAGS "-pthread")
|
|
||||||
endif()
|
|
||||||
set(WXCONFIG_CPPFLAGS)
|
set(WXCONFIG_CPPFLAGS)
|
||||||
if(wxBUILD_SHARED)
|
if(wxBUILD_SHARED)
|
||||||
wx_string_append(WXCONFIG_CPPFLAGS " -DWXUSINGDLL")
|
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")
|
target_compile_definitions(${target_name} PUBLIC "-D_FILE_OFFSET_BITS=64")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_USE_PTHREADS_INIT)
|
if(CMAKE_THREAD_LIBS_INIT)
|
||||||
target_compile_options(${target_name} PRIVATE "-pthread")
|
target_compile_options(${target_name} PRIVATE ${CMAKE_THREAD_LIBS_INIT})
|
||||||
# clang++.exe: warning: argument unused during compilation: '-pthread' [-Wunused-command-line-argument]
|
target_link_libraries(${target_name} PUBLIC ${CMAKE_THREAD_LIBS_INIT})
|
||||||
if(NOT (WIN32 AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"))
|
|
||||||
set_target_properties(${target_name} PROPERTIES LINK_FLAGS "-pthread")
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
wx_set_source_groups()
|
wx_set_source_groups()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
|
||||||
|
|
@ -403,7 +403,7 @@ endif(UNIX)
|
||||||
|
|
||||||
if(CMAKE_USE_PTHREADS_INIT)
|
if(CMAKE_USE_PTHREADS_INIT)
|
||||||
cmake_push_check_state(RESET)
|
cmake_push_check_state(RESET)
|
||||||
set(CMAKE_REQUIRED_LIBRARIES pthread)
|
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
|
||||||
wx_check_cxx_source_compiles("
|
wx_check_cxx_source_compiles("
|
||||||
void *p;
|
void *p;
|
||||||
pthread_cleanup_push(ThreadCleanupFunc, p);
|
pthread_cleanup_push(ThreadCleanupFunc, p);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue