diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 1460cf9..28eebaf 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -17,6 +17,9 @@ add_checked_subdirectory(crash_reports) if (LINUX AND NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION) add_checked_subdirectory(dbusmenu_qt) endif() +if (LINUX) + add_checked_subdirectory(dispatch) +endif() add_checked_subdirectory(expected) if (LINUX AND NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION) add_checked_subdirectory(fcitx_qt5) diff --git a/external/dispatch/CMakeLists.txt b/external/dispatch/CMakeLists.txt new file mode 100644 index 0000000..2acfba9 --- /dev/null +++ b/external/dispatch/CMakeLists.txt @@ -0,0 +1,63 @@ +# This file is part of Desktop App Toolkit, +# a set of libraries for developing nice desktop applications. +# +# For license and copyright information please follow this link: +# https://github.com/desktop-app/legal/blob/master/LEGAL + +add_library(external_dispatch INTERFACE IMPORTED GLOBAL) +add_library(desktop-app::external_dispatch ALIAS external_dispatch) + +if (DESKTOP_APP_USE_PACKAGED) + find_library(DISPATCH_LIBRARIES dispatch) + find_path(DISPATCH_INCLUDE_DIRS dispatch/dispatch.h) + + if (DISPATCH_LIBRARIES AND DISPATCH_INCLUDE_DIRS) + target_include_directories(external_dispatch SYSTEM INTERFACE ${DISPATCH_INCLUDE_DIRS}) + target_link_libraries(external_dispatch INTERFACE ${DISPATCH_LIBRARIES}) + return() + endif() +endif() + +add_library(external_dispatch_bundled STATIC IMPORTED) + +set(dispatch_loc ${third_party_loc}/dispatch) +set(dispatch_prefix ${CMAKE_CURRENT_BINARY_DIR}/dispatch-prefix) +set(dispatch_binary_dir ${dispatch_prefix}/src/dispatch-build) + +include(ExternalProject) +ExternalProject_Add(dispatch + SOURCE_DIR ${dispatch_loc} + CMAKE_GENERATOR Ninja + CMAKE_ARGS + -DCMAKE_BUILD_TYPE=Release + -DCMAKE_C_COMPILER=clang + -DCMAKE_CXX_COMPILER=clang++ + -DBUILD_SHARED_LIBS=OFF + -DBUILD_TESTING=OFF + INSTALL_COMMAND : + BUILD_BYPRODUCTS + ${dispatch_binary_dir}/src/libdispatch.a + ${dispatch_binary_dir}/src/BlocksRuntime/libBlocksRuntime.a +) + +set_target_properties(external_dispatch_bundled PROPERTIES + IMPORTED_LOCATION "${dispatch_binary_dir}/src/libdispatch.a" +) + +target_include_directories(external_dispatch_bundled SYSTEM +INTERFACE + ${dispatch_loc} +) + +target_link_libraries(external_dispatch_bundled +INTERFACE + ${dispatch_binary_dir}/src/BlocksRuntime/libBlocksRuntime.a + pthread +) + +add_dependencies(external_dispatch_bundled dispatch) + +target_link_libraries(external_dispatch +INTERFACE + external_dispatch_bundled +)