Skip to content

[wasm][build] Guard libdispatch and Threads usage with HAS_LIBDISPATCH_API #4866

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ set(CF_DEPLOYMENT_SWIFT YES CACHE BOOL "Build for Swift" FORCE)

set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG OFF)
find_package(Threads REQUIRED)
if(HAS_LIBDISPATCH_API)
find_package(Threads REQUIRED)
endif()

set(SAVED_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
set(BUILD_SHARED_LIBS NO)
Expand Down
36 changes: 23 additions & 13 deletions CoreFoundation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ set(CMAKE_POSITION_INDEPENDENT_CODE YES)

set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG OFF)
find_package(Threads REQUIRED)
if(HAS_LIBDISPATCH_API)
find_package(Threads REQUIRED)
endif()

if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
find_package(LibXml2 REQUIRED)
Expand Down Expand Up @@ -385,10 +387,15 @@ target_include_directories(CoreFoundation
PRIVATE
${PROJECT_SOURCE_DIR})
target_link_libraries(CoreFoundation PRIVATE
Threads::Threads
${CMAKE_DL_LIBS}
BlocksRuntime
dispatch)
BlocksRuntime)

if(HAS_LIBDISPATCH_API)
target_link_libraries(CoreFoundation PRIVATE
Threads::Threads
dispatch)
endif()

if(CMAKE_SYSTEM_NAME STREQUAL Android)
target_link_libraries(CoreFoundation PRIVATE
log)
Expand Down Expand Up @@ -504,15 +511,18 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL Windows AND NOT CMAKE_SYSTEM_NAME STREQUAL Dar
PRIVATE
m)
endif()
target_link_libraries(CoreFoundation
PRIVATE
dispatch)
target_link_libraries(CFURLSessionInterface
PRIVATE
dispatch)
target_link_libraries(CFXMLInterface
PRIVATE
dispatch)

if(HAS_LIBDISPATCH_API)
target_link_libraries(CoreFoundation
PRIVATE
dispatch)
target_link_libraries(CFURLSessionInterface
PRIVATE
dispatch)
target_link_libraries(CFXMLInterface
PRIVATE
dispatch)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
target_link_libraries(CoreFoundation
PRIVATE
Expand Down