Merge branch 'cmake-thread' of https://github.com/MaartenBent/wxWidgets
CMake: Link thread library only when necessary. This also fixes finding threads under Android. See #24356.
This commit is contained in:
commit
9f43a717d8
4 changed files with 14 additions and 14 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()
|
||||
|
|
|
|||
|
|
@ -330,7 +330,14 @@ if(wxUSE_INTL AND NOT wxUSE_FILE)
|
|||
endif()
|
||||
|
||||
if(wxUSE_THREADS)
|
||||
if(ANDROID)
|
||||
# Android has pthreads but FindThreads fails due to missing pthread_cancel
|
||||
set(CMAKE_USE_PTHREADS_INIT 1)
|
||||
set(CMAKE_THREAD_LIBS_INIT "")
|
||||
set(Threads_FOUND TRUE)
|
||||
else()
|
||||
find_package(Threads REQUIRED)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(wxUSE_LIBLZMA)
|
||||
|
|
|
|||
|
|
@ -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