diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..3d3dbe7 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "external/glib/cppgir"] + path = external/glib/cppgir + url = https://gitlab.com/mnauw/cppgir.git +[submodule "external/Implib.so"] + path = external/Implib.so + url = https://github.com/yugr/Implib.so.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 465f5f7..44954c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,17 +5,6 @@ # https://github.com/desktop-app/legal/blob/master/LEGAL add_subdirectory(external) -if (LINUX) - add_subdirectory(linux_jemalloc_helper) -endif() -if (LINUX AND NOT DESKTOP_APP_USE_PACKAGED) - add_subdirectory(linux_xcb_helper) -endif() -if (LINUX - AND NOT DESKTOP_APP_USE_PACKAGED - AND NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) - add_subdirectory(linux_wayland_helper) -endif() if (DESKTOP_APP_USE_ALLOCATION_TRACER) add_subdirectory(linux_allocation_tracer) endif() diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 0922a66..34181cc 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -13,19 +13,20 @@ endmacro() add_checked_subdirectory(angle) add_checked_subdirectory(auto_updates) +add_checked_subdirectory(boost) +if (add_cld3_library) + add_checked_subdirectory(cld3) +endif() add_checked_subdirectory(crash_reports) 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) - if (NOT DESKTOP_APP_DISABLE_X11_INTEGRATION) - add_checked_subdirectory(fcitx5_qt) - endif() +if (LINUX AND TARGET Qt::DBus AND NOT DESKTOP_APP_DISABLE_X11_INTEGRATION) + add_checked_subdirectory(fcitx5_qt) endif() add_checked_subdirectory(ffmpeg) -if (LINUX AND NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION) +if (LINUX) add_checked_subdirectory(glib) add_checked_subdirectory(glibmm) endif() @@ -37,13 +38,9 @@ if (add_hunspell_library) add_checked_subdirectory(hunspell) endif() add_checked_subdirectory(iconv) -if (LINUX) - add_checked_subdirectory(jemalloc) -endif() add_checked_subdirectory(jpeg) -if (LINUX AND NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) - add_checked_subdirectory(kwayland) -endif() +add_checked_subdirectory(kcoreaddons) +add_checked_subdirectory(kimageformats) add_checked_subdirectory(lz4) add_checked_subdirectory(minizip) if (LINUX) @@ -57,9 +54,15 @@ add_checked_subdirectory(qr_code_generator) add_checked_subdirectory(ranges) add_checked_subdirectory(rlottie) add_checked_subdirectory(rnnoise) +if (LINUX AND NOT DESKTOP_APP_DISABLE_SCUDO) + add_checked_subdirectory(scudo) +endif() add_checked_subdirectory(ton) add_checked_subdirectory(variant) add_checked_subdirectory(vpx) +if (LINUX AND NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) + add_checked_subdirectory(wayland_client) +endif() add_checked_subdirectory(webrtc) if (LINUX AND NOT DESKTOP_APP_DISABLE_X11_INTEGRATION) add_checked_subdirectory(xcb) diff --git a/external/Implib.so b/external/Implib.so new file mode 160000 index 0000000..0ddaa71 --- /dev/null +++ b/external/Implib.so @@ -0,0 +1 @@ +Subproject commit 0ddaa715d2572b100f8248c0fa4450fbf895be14 diff --git a/external/boost/CMakeLists.txt b/external/boost/CMakeLists.txt new file mode 100644 index 0000000..7a4e811 --- /dev/null +++ b/external/boost/CMakeLists.txt @@ -0,0 +1,25 @@ +# 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_boost_regex INTERFACE IMPORTED GLOBAL) +add_library(desktop-app::external_boost_regex ALIAS external_boost_regex) + +target_compile_definitions(external_boost_regex +INTERFACE + BOOST_NO_INTRINSIC_WCHAR_T + BOOST_REGEX_NO_W32 +) + +if (DESKTOP_APP_USE_PACKAGED OR LINUX) + find_package(Boost COMPONENTS regex REQUIRED) + target_link_libraries(external_boost_regex INTERFACE Boost::regex) + return() +endif() + +target_include_directories(external_boost_regex SYSTEM +INTERFACE + ${libs_loc}/regex/include +) diff --git a/external/cld3/CMakeLists.txt b/external/cld3/CMakeLists.txt new file mode 100644 index 0000000..1da1aef --- /dev/null +++ b/external/cld3/CMakeLists.txt @@ -0,0 +1,112 @@ +# 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_cld3 INTERFACE IMPORTED GLOBAL) +add_library(desktop-app::external_cld3 ALIAS external_cld3) + +add_library(external_cld3_bundled STATIC) +init_target(external_cld3_bundled "(external)") + +set(cld3_loc ${third_party_loc}/cld3) +set(cld3_src ${cld3_loc}/src) + +set(gen_loc ${cld3_loc}/build/gen) +set(gen_dst ${gen_loc}/cld_3/protos) + +if (DESKTOP_APP_USE_PACKAGED) + find_package(Protobuf) + if (NOT Protobuf_FOUND) + find_package(protobuf REQUIRED CONFIG) + endif() + set(protoc_executable protobuf::protoc) + set(protobuf_lib protobuf::libprotobuf-lite) +elseif (WIN32) + set(build_loc ${libs_loc}/protobuf/build/$,Debug,Release>) + set(protoc_executable ${build_loc}/protoc.exe) + set(protobuf_lib ${build_loc}/libprotobuf-lite.lib) +else() + set(protoc_executable ${libs_loc}/protobuf/build/protoc) + set(protobuf_lib ${libs_loc}/protobuf/build/libprotobuf-lite.a) + if (LINUX) + target_compile_options(external_cld3_bundled PRIVATE -Wno-implicit-fallthrough) + endif() +endif() +if (PROTOBUF_PROTOC_EXECUTABLE) + set(protoc_executable ${PROTOBUF_PROTOC_EXECUTABLE}) +endif() + +include(generate_protobuf.cmake) + +function(generate protobuf_name) + generate_single_protobuf( + external_cld3_bundled + ${gen_dst} + ${protobuf_name} + ${protoc_executable}) +endfunction() + +generate(feature_extractor.proto) +generate(sentence.proto) +generate(task_spec.proto) + +nice_target_sources(external_cld3_bundled ${cld3_src} +PRIVATE + feature_extractor.proto + sentence.proto + task_spec.proto + + base.cc + embedding_feature_extractor.cc + embedding_network.cc + feature_extractor.cc + feature_extractor.h + feature_types.cc + fml_parser.cc + language_identifier_features.cc + lang_id_nn_params.cc + nnet_language_identifier.cc + registry.cc + relevant_script_feature.cc + sentence_features.cc + task_context.cc + task_context_params.cc + unicodetext.cc + utils.cc + workspace.cc + + script_span/generated_entities.cc + script_span/getonescriptspan.cc + script_span/getonescriptspan.h + script_span/utf8statetable.cc + script_span/offsetmap.cc + script_span/text_processing.cc + script_span/text_processing.h + script_span/fixunicodevalue.cc +) + +target_include_directories(external_cld3_bundled +PUBLIC + ${cld3_src} + ${gen_loc} +) + +if (NOT DESKTOP_APP_USE_PACKAGED) + target_include_directories(external_cld3_bundled + PUBLIC + ${libs_loc}/protobuf/src + ${libs_loc}/protobuf/third_party/abseil-cpp + ) +endif() + +target_link_libraries(external_cld3_bundled +PRIVATE + ${protobuf_lib} +) + +target_link_libraries(external_cld3 +INTERFACE + external_cld3_bundled +) diff --git a/external/cld3/generate_protobuf.cmake b/external/cld3/generate_protobuf.cmake new file mode 100644 index 0000000..3c8544b --- /dev/null +++ b/external/cld3/generate_protobuf.cmake @@ -0,0 +1,58 @@ +function(generate_single_protobuf target_name gen_dst protobuf_name executable) + file(MAKE_DIRECTORY ${gen_dst}) + + # Copied from myprotobuf.cmake. + if (PROTOBUF_GENERATE_CPP_APPEND_PATH) + # Create an include path for each file specified + set(FIL ${cld3_src}/${protobuf_name}) + get_filename_component(ABS_FIL ${FIL} ABSOLUTE) + get_filename_component(ABS_PATH ${ABS_FIL} PATH) + list(FIND _protobuf_include_path ${ABS_PATH} _contains_already) + if (${_contains_already} EQUAL -1) + list(APPEND _protobuf_include_path -I ${ABS_PATH}) + endif() + else() + set(_protobuf_include_path -I ${cld3_src}) + endif() + + if (DEFINED PROTOBUF_IMPORT_DIRS) + foreach (DIR ${PROTOBUF_IMPORT_DIRS}) + get_filename_component(ABS_PATH ${DIR} ABSOLUTE) + list(FIND _protobuf_include_path ${ABS_PATH} _contains_already) + if (${_contains_already} EQUAL -1) + list(APPEND _protobuf_include_path -I ${ABS_PATH}) + endif() + endforeach() + endif() + # + + get_filename_component(protobuf_name_we ${protobuf_name} NAME_WE) + + set(gen_timestamp ${gen_dst}/${protobuf_name}.timestamp) + set(gen_files + ${gen_dst}/${protobuf_name_we}.pb.cc + ${gen_dst}/${protobuf_name_we}.pb.h + ) + + set(gen_src ${cld3_src}/${protobuf_name}) + add_custom_command( + OUTPUT + ${gen_timestamp} + BYPRODUCTS + ${gen_files} + COMMAND + ${executable} + --cpp_out + ${gen_dst} + ${_protobuf_include_path} + ${gen_src} + COMMAND + echo 1> ${gen_timestamp} + COMMENT "Generating protobuf ${protobuf_name} (${target_name})" + DEPENDS + ${executable} + ${gen_src} + VERBATIM + ) + generate_target(${target_name} ${protobuf_name} ${gen_timestamp} "${gen_files}" ${gen_dst}) +endfunction() diff --git a/external/crash_reports/breakpad/CMakeLists.txt b/external/crash_reports/breakpad/CMakeLists.txt index d57a17e..1a36e06 100644 --- a/external/crash_reports/breakpad/CMakeLists.txt +++ b/external/crash_reports/breakpad/CMakeLists.txt @@ -7,10 +7,19 @@ add_library(external_breakpad INTERFACE IMPORTED GLOBAL) add_library(desktop-app::external_breakpad ALIAS external_breakpad) -target_include_directories(external_breakpad SYSTEM -INTERFACE - ${libs_loc}/breakpad/src -) +if (LINUX) + find_package(PkgConfig REQUIRED) + pkg_check_modules(BREAKPAD REQUIRED breakpad) + target_include_directories(external_breakpad SYSTEM + INTERFACE + ${BREAKPAD_INCLUDE_DIRS} + ) +else() + target_include_directories(external_breakpad SYSTEM + INTERFACE + ${libs_loc}/breakpad/src + ) +endif() if (build_win64) set(breakpad_config_add _x64) diff --git a/external/dispatch/CMakeLists.txt b/external/dispatch/CMakeLists.txt index b6bba91..91f5b45 100644 --- a/external/dispatch/CMakeLists.txt +++ b/external/dispatch/CMakeLists.txt @@ -9,24 +9,37 @@ set(dispatch_prefix ${CMAKE_CURRENT_BINARY_DIR}/dispatch-prefix) set(dispatch_binary_dir ${dispatch_prefix}/src/dispatch-build) if (DESKTOP_APP_USE_PACKAGED) - find_library(DISPATCH_LIBRARIES dispatch) - find_path(DISPATCH_INCLUDE_DIRS dispatch/dispatch.h) + find_library(DESKTOP_APP_DISPATCH_LIBRARIES dispatch) + find_path(DESKTOP_APP_DISPATCH_INCLUDE_DIRS dispatch/dispatch.h) endif() -if (NOT DISPATCH_LIBRARIES OR NOT DISPATCH_INCLUDE_DIRS) +if (NOT DESKTOP_APP_DISPATCH_LIBRARIES OR NOT DESKTOP_APP_DISPATCH_INCLUDE_DIRS) + if (NOT DESKTOP_APP_USE_PACKAGED OR DESKTOP_APP_SPECIAL_TARGET) + set(dispatch_extra_args + -DCMAKE_BUILD_TYPE=Release + "-DCMAKE_C_FLAGS=-g -pipe -fPIC -fno-omit-frame-pointer -fstack-protector-all -fstack-clash-protection -fcf-protection -D_FORTIFY_SOURCE=3 -D_GLIBCXX_ASSERTIONS" + "-DCMAKE_CXX_FLAGS=-g -pipe -fPIC -fno-omit-frame-pointer -fstack-protector-all -fstack-clash-protection -fcf-protection -D_FORTIFY_SOURCE=3 -D_GLIBCXX_ASSERTIONS" + ) + elseif (DEFINED CMAKE_BUILD_TYPE) + set(dispatch_extra_args + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + ) + else() + set(dispatch_extra_args) + endif() execute_process( COMMAND ${CMAKE_COMMAND} ${dispatch_loc} -B ${dispatch_binary_dir} -GNinja - -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF + ${dispatch_extra_args} ) execute_process( - COMMAND ${CMAKE_COMMAND} --build ${dispatch_binary_dir} + COMMAND ${CMAKE_COMMAND} --build ${dispatch_binary_dir} --parallel ) if (NOT EXISTS ${dispatch_binary_dir}/src/libdispatch.a) @@ -41,9 +54,9 @@ endif() add_library(external_dispatch INTERFACE IMPORTED GLOBAL) add_library(desktop-app::external_dispatch ALIAS external_dispatch) -if (DESKTOP_APP_USE_PACKAGED AND DISPATCH_LIBRARIES AND DISPATCH_INCLUDE_DIRS) - target_include_directories(external_dispatch SYSTEM INTERFACE ${DISPATCH_INCLUDE_DIRS}) - target_link_libraries(external_dispatch INTERFACE ${DISPATCH_LIBRARIES}) +if (DESKTOP_APP_USE_PACKAGED AND DESKTOP_APP_DISPATCH_LIBRARIES AND DESKTOP_APP_DISPATCH_INCLUDE_DIRS) + target_include_directories(external_dispatch SYSTEM INTERFACE ${DESKTOP_APP_DISPATCH_INCLUDE_DIRS}) + target_link_libraries(external_dispatch INTERFACE ${DESKTOP_APP_DISPATCH_LIBRARIES}) return() endif() diff --git a/external/fcitx5_qt/CMakeLists.txt b/external/fcitx5_qt/CMakeLists.txt index 8827162..c8801a5 100644 --- a/external/fcitx5_qt/CMakeLists.txt +++ b/external/fcitx5_qt/CMakeLists.txt @@ -15,31 +15,26 @@ add_library(desktop-app::external_fcitx5_qt ALIAS external_fcitx5_qt) init_target(external_fcitx5_qt "(external)") set(fcitx5_qt_loc ${third_party_loc}/fcitx5-qt) - -if (DESKTOP_APP_QT6) - set(fcitx5_qt_src ${fcitx5_qt_loc}/qt6/platforminputcontext) -else() - set(fcitx5_qt_src ${fcitx5_qt_loc}/qt5/platforminputcontext) -endif() +set(fcitx5_qt_src ${fcitx5_qt_loc}/qt${QT_VERSION_MAJOR}/platforminputcontext) set_target_properties(external_fcitx5_qt PROPERTIES AUTOMOC ON) -set(FCITX5_QT_EXTRA_PLUGIN_NAME "") +set(FCITX5_QT_EXTRA_PLUGIN_NAME "\"fcitx\",") configure_file("${fcitx5_qt_src}/fcitx5.json.in" "${CMAKE_CURRENT_BINARY_DIR}/fcitx5.json") nice_target_sources(external_fcitx5_qt ${fcitx5_qt_src} PRIVATE + fcitx4watcher.cpp + fcitx4inputcontextproxy.cpp + fcitx4inputcontextproxyimpl.cpp + fcitx4inputmethodproxy.cpp + hybridinputcontext.cpp qfcitxplatforminputcontext.cpp - qfcitxplatforminputcontext.h fcitxcandidatewindow.cpp - fcitxcandidatewindow.h fcitxtheme.cpp - fcitxtheme.h font.cpp - font.h qtkey.cpp main.cpp - main.h ) target_include_directories(external_fcitx5_qt @@ -84,3 +79,23 @@ else() xkbcommon ) endif() + +add_library(external_fcitx5_qt_init OBJECT) +add_library(desktop-app::external_fcitx5_qt_init ALIAS external_fcitx5_qt_init) +init_target(external_fcitx5_qt_init "(external)") + +nice_target_sources(external_fcitx5_qt_init ${CMAKE_CURRENT_SOURCE_DIR} +PRIVATE + init.cpp +) + +target_link_libraries(external_fcitx5_qt_init +PRIVATE + desktop-app::external_qt +) + +target_link_libraries(external_fcitx5_qt +INTERFACE + external_fcitx5_qt_init + $ +) diff --git a/external/fcitx5_qt/fcitx5_qt_dbusaddons/CMakeLists.txt b/external/fcitx5_qt/fcitx5_qt_dbusaddons/CMakeLists.txt index 53370f1..c8e3ce1 100644 --- a/external/fcitx5_qt/fcitx5_qt_dbusaddons/CMakeLists.txt +++ b/external/fcitx5_qt/fcitx5_qt_dbusaddons/CMakeLists.txt @@ -15,12 +15,7 @@ add_library(desktop-app::external_fcitx5_qt_dbusaddons ALIAS external_fcitx5_qt_ init_target(external_fcitx5_qt_dbusaddons "(external)") set(fcitx5_qt_loc ${third_party_loc}/fcitx5-qt) - -if (DESKTOP_APP_QT6) - set(fcitx5_qt_dbusaddons_src ${fcitx5_qt_loc}/qt6/dbusaddons) -else() - set(fcitx5_qt_dbusaddons_src ${fcitx5_qt_loc}/qt5/dbusaddons) -endif() +set(fcitx5_qt_dbusaddons_src ${fcitx5_qt_loc}/qt${QT_VERSION_MAJOR}/dbusaddons) set_target_properties(external_fcitx5_qt_dbusaddons PROPERTIES AUTOMOC ON) @@ -40,12 +35,7 @@ PRIVATE ) include(GenerateExportHeader) - -if (DESKTOP_APP_QT6) - generate_export_header(external_fcitx5_qt_dbusaddons BASE_NAME Fcitx5Qt6DBusAddons) -else() - generate_export_header(external_fcitx5_qt_dbusaddons BASE_NAME Fcitx5Qt5DBusAddons) -endif() +generate_export_header(external_fcitx5_qt_dbusaddons BASE_NAME Fcitx5Qt${QT_VERSION_MAJOR}DBusAddons) target_include_directories(external_fcitx5_qt_dbusaddons PUBLIC @@ -53,7 +43,7 @@ PUBLIC "${CMAKE_CURRENT_BINARY_DIR}" ) -if (NOT DESKTOP_APP_QT6) +if (QT_VERSION_MAJOR EQUAL 5) target_compile_definitions(external_fcitx5_qt_dbusaddons PRIVATE FCITX5QT5DBUSADDONS_STATIC_DEFINE diff --git a/external/fcitx5_qt/init.cpp b/external/fcitx5_qt/init.cpp new file mode 100644 index 0000000..d8adcf1 --- /dev/null +++ b/external/fcitx5_qt/init.cpp @@ -0,0 +1,10 @@ +/* +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 +*/ +#include + +Q_IMPORT_PLUGIN(QFcitx5PlatformInputContextPlugin) diff --git a/external/fcitx_qt5/CMakeLists.txt b/external/fcitx_qt5/CMakeLists.txt deleted file mode 100644 index 6cc0312..0000000 --- a/external/fcitx_qt5/CMakeLists.txt +++ /dev/null @@ -1,89 +0,0 @@ -# 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 - -if (DESKTOP_APP_USE_PACKAGED AND NOT DESKTOP_APP_USE_PACKAGED_LAZY) - add_library(external_fcitx_qt5 INTERFACE IMPORTED GLOBAL) - add_library(desktop-app::external_fcitx_qt5 ALIAS external_fcitx_qt5) - return() -endif() - -add_library(external_fcitx_qt5 STATIC) -add_library(desktop-app::external_fcitx_qt5 ALIAS external_fcitx_qt5) -init_target(external_fcitx_qt5 "(external)") - -set(fcitx_qt5_loc ${third_party_loc}/fcitx-qt5) - -if (DESKTOP_APP_QT6) - set(fcitx_qt5_src ${fcitx_qt5_loc}/qt6/platforminputcontext) -else() - set(fcitx_qt5_src ${fcitx_qt5_loc}/qt5/platforminputcontext) -endif() - -set_target_properties(external_fcitx_qt5 PROPERTIES AUTOMOC ON) - -nice_target_sources(external_fcitx_qt5 ${fcitx_qt5_src} -PRIVATE - fcitxinputcontextproxy.cpp - fcitxqtdbustypes.cpp - fcitxwatcher.cpp - qfcitxplatforminputcontext.cpp - main.cpp - qtkey.cpp -) - -set_source_files_properties(${fcitx_qt5_src}/org.fcitx.Fcitx.InputContext.xml PROPERTIES -INCLUDE ${fcitx_qt5_src}/fcitxqtdbustypes.h) -set_source_files_properties(${fcitx_qt5_src}/org.fcitx.Fcitx.InputContext1.xml PROPERTIES -INCLUDE ${fcitx_qt5_src}/fcitxqtdbustypes.h) -set_source_files_properties(${fcitx_qt5_src}/org.fcitx.Fcitx.InputMethod.xml PROPERTIES -INCLUDE ${fcitx_qt5_src}/fcitxqtdbustypes.h) -set_source_files_properties(${fcitx_qt5_src}/org.fcitx.Fcitx.InputMethod1.xml PROPERTIES -INCLUDE ${fcitx_qt5_src}/fcitxqtdbustypes.h) - -if (DESKTOP_APP_QT6) - qt6_add_dbus_interface(fcitx_qt5_adaptors ${fcitx_qt5_src}/org.fcitx.Fcitx.InputContext.xml inputcontextproxy) - qt6_add_dbus_interface(fcitx_qt5_adaptors ${fcitx_qt5_src}/org.fcitx.Fcitx.InputContext1.xml inputcontext1proxy) - qt6_add_dbus_interface(fcitx_qt5_adaptors ${fcitx_qt5_src}/org.fcitx.Fcitx.InputMethod.xml inputmethodproxy) - qt6_add_dbus_interface(fcitx_qt5_adaptors ${fcitx_qt5_src}/org.fcitx.Fcitx.InputMethod1.xml inputmethod1proxy) -else() - qt5_add_dbus_interface(fcitx_qt5_adaptors ${fcitx_qt5_src}/org.fcitx.Fcitx.InputContext.xml inputcontextproxy) - qt5_add_dbus_interface(fcitx_qt5_adaptors ${fcitx_qt5_src}/org.fcitx.Fcitx.InputContext1.xml inputcontext1proxy) - qt5_add_dbus_interface(fcitx_qt5_adaptors ${fcitx_qt5_src}/org.fcitx.Fcitx.InputMethod.xml inputmethodproxy) - qt5_add_dbus_interface(fcitx_qt5_adaptors ${fcitx_qt5_src}/org.fcitx.Fcitx.InputMethod1.xml inputmethod1proxy) -endif() - -target_sources(external_fcitx_qt5 PRIVATE ${fcitx_qt5_adaptors}) - -target_include_directories(external_fcitx_qt5 -PRIVATE - ${fcitx_qt5_src} - "${CMAKE_CURRENT_BINARY_DIR}" -) - -target_compile_definitions(external_fcitx_qt5 -PRIVATE - QT_STATICPLUGIN -) - -target_link_libraries(external_fcitx_qt5 -PRIVATE - desktop-app::external_qt -) - -if (DESKTOP_APP_USE_PACKAGED) - find_package(PkgConfig REQUIRED) - pkg_check_modules(XKBCOMMON REQUIRED IMPORTED_TARGET xkbcommon) - - target_link_libraries(external_fcitx_qt5 - PRIVATE - PkgConfig::XKBCOMMON - ) -else() - target_link_static_libraries(external_fcitx_qt5 - PRIVATE - xkbcommon - ) -endif() diff --git a/external/ffmpeg/CMakeLists.txt b/external/ffmpeg/CMakeLists.txt index 39f0a36..2c941dc 100644 --- a/external/ffmpeg/CMakeLists.txt +++ b/external/ffmpeg/CMakeLists.txt @@ -10,43 +10,111 @@ add_library(desktop-app::external_ffmpeg ALIAS external_ffmpeg) if (DESKTOP_APP_USE_PACKAGED) find_package(PkgConfig REQUIRED) - pkg_check_modules(AVCODEC REQUIRED IMPORTED_TARGET libavcodec) + pkg_check_modules(AVFILTER REQUIRED IMPORTED_TARGET libavfilter) pkg_check_modules(AVFORMAT REQUIRED IMPORTED_TARGET libavformat) + pkg_check_modules(AVCODEC REQUIRED IMPORTED_TARGET libavcodec) pkg_check_modules(AVUTIL REQUIRED IMPORTED_TARGET libavutil) pkg_check_modules(SWSCALE REQUIRED IMPORTED_TARGET libswscale) pkg_check_modules(SWRESAMPLE REQUIRED IMPORTED_TARGET libswresample) target_link_libraries(external_ffmpeg INTERFACE - PkgConfig::AVCODEC + PkgConfig::AVFILTER PkgConfig::AVFORMAT + PkgConfig::AVCODEC PkgConfig::AVUTIL PkgConfig::SWSCALE PkgConfig::SWRESAMPLE ) -else() - target_include_directories(external_ffmpeg SYSTEM - INTERFACE - ${libs_loc}/ffmpeg - ) + return() +endif() + +set(ffmpeg_lib_list) + +if (LINUX) + list(APPEND ffmpeg_lib_list + -lavfilter + -lavformat + -lavcodec + -lswresample + -lswscale + -lavutil + ) +else() set(ffmpeg_lib_loc ${libs_loc}/ffmpeg) - target_link_libraries(external_ffmpeg + target_include_directories(external_ffmpeg SYSTEM INTERFACE + ${ffmpeg_lib_loc} + ) + + list(APPEND ffmpeg_lib_list + ${ffmpeg_lib_loc}/libavfilter/libavfilter.a ${ffmpeg_lib_loc}/libavformat/libavformat.a ${ffmpeg_lib_loc}/libavcodec/libavcodec.a ${ffmpeg_lib_loc}/libswresample/libswresample.a ${ffmpeg_lib_loc}/libswscale/libswscale.a ${ffmpeg_lib_loc}/libavutil/libavutil.a - $ - $ - $ - $ ) - if (APPLE) - target_link_libraries(external_ffmpeg INTERFACE bz2) - elseif (LINUX) - target_link_static_libraries(external_ffmpeg INTERFACE lzma) - endif() endif() + +list(APPEND ffmpeg_lib_list + $ + $ +) + +if (WIN32) + list(APPEND ffmpeg_lib_list + ${libs_loc}/dav1d/builddir-$,debug,release>/src/libdav1d.a + ) +elseif (APPLE) + list(APPEND ffmpeg_lib_list + bz2 + ) +elseif (LINUX) + list(APPEND ffmpeg_lib_list + -ldav1d + -llzma + $ + $ + $ + $ + $ + -lXv + -lXext + ) +endif() + +# Workaround cmake's random order on Linux... +if (LINUX) + generate_implib( + vdpau + va-x11 + va-drm + va + drm + ) + list(JOIN ffmpeg_lib_list , ffmpeg_lib_link) + target_link_libraries(external_ffmpeg + INTERFACE + -Wl,--push-state,-Bstatic,${ffmpeg_lib_link},--pop-state + $ + $ + $ + $ + $ + X11 + ) +else() + target_link_libraries(external_ffmpeg + INTERFACE + ${ffmpeg_lib_list} + ) +endif() + +target_link_libraries(external_ffmpeg +INTERFACE + $ + $ +) diff --git a/external/glib/CMakeLists.txt b/external/glib/CMakeLists.txt index def4376..3c6fe4b 100644 --- a/external/glib/CMakeLists.txt +++ b/external/glib/CMakeLists.txt @@ -7,33 +7,27 @@ add_library(external_glib INTERFACE IMPORTED GLOBAL) add_library(desktop-app::external_glib ALIAS external_glib) +function(add_cppgir) # isolate scope + set(BUILD_TESTING OFF) + set(BUILD_DOC OFF) + set(BUILD_EXAMPLES OFF) + add_subdirectory(cppgir EXCLUDE_FROM_ALL) +endfunction() +add_cppgir() + +include(generate_cppgir.cmake) +generate_cppgir(external_glib Gio-2.0) + find_package(PkgConfig REQUIRED) -pkg_check_modules(GLIB2 REQUIRED IMPORTED_TARGET glib-2.0) -pkg_check_modules(GOBJECT REQUIRED IMPORTED_TARGET gobject-2.0) -pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) -pkg_check_modules(GIO_UNIX REQUIRED IMPORTED_TARGET gio-unix-2.0) +pkg_check_modules(GLIB2 REQUIRED IMPORTED_TARGET glib-2.0 gobject-2.0 gio-2.0 gio-unix-2.0) -if (DESKTOP_APP_USE_PACKAGED) - target_link_libraries(external_glib - INTERFACE - PkgConfig::GIO_UNIX - PkgConfig::GIO - PkgConfig::GOBJECT - PkgConfig::GLIB2 - ) -else() - target_include_directories(external_glib SYSTEM - INTERFACE - ${GIO_UNIX_INCLUDE_DIRS} - ${GIO_INCLUDE_DIRS} - ${GOBJECT_INCLUDE_DIRS} - ${GLIB2_INCLUDE_DIRS} - ) +target_link_libraries(external_glib +INTERFACE + PkgConfig::GLIB2 +) - target_link_libraries(external_glib - INTERFACE - gio-2.0 - gobject-2.0 - glib-2.0 - ) -endif() +target_compile_definitions(external_glib +INTERFACE + GLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_56 + GLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_56 +) diff --git a/external/glib/cppgir b/external/glib/cppgir new file mode 160000 index 0000000..83d9474 --- /dev/null +++ b/external/glib/cppgir @@ -0,0 +1 @@ +Subproject commit 83d94749d94fdb9b9e97a3e942f73a587a6ef253 diff --git a/external/glib/generate_cppgir.cmake b/external/glib/generate_cppgir.cmake new file mode 100644 index 0000000..c15d3f9 --- /dev/null +++ b/external/glib/generate_cppgir.cmake @@ -0,0 +1,59 @@ +# 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 + +function(generate_cppgir target_name gir) + set(cppgir_loc ${cmake_helpers_loc}/external/glib/cppgir) + + # cppgir generates all the dependent headers everytime, better to have a global folder + set(gen_dst ${CMAKE_BINARY_DIR}/gen) + file(MAKE_DIRECTORY ${gen_dst}) + + set(gen_timestamp ${gen_dst}/${target_name}_cppgir.timestamp) + + set(ignore_files + ${cppgir_loc}/data/cppgir.ignore + ${cppgir_loc}/data/cppgir_unix.ignore + ) + + set(gir_path) + if (IS_ABSOLUTE "${gir}") + set(gir_path ${gir}) + endif() + + add_custom_command( + OUTPUT + ${gen_timestamp} + COMMAND + CppGir::cppgir + --debug + 1 + --class + --class-full + --expected + --ignore + "$" + --output + ${gen_dst} + ${gir} + COMMAND + echo 1> ${gen_timestamp} + COMMENT "Generating C++ wrapper for ${gir} (${target_name})" + DEPENDS + CppGir::cppgir + ${ignore_files} + ${gir_path} + ) + generate_target(${target_name} cppgir ${gen_timestamp} "" ${gen_dst}) + + get_target_property(target_type ${target_name} TYPE) + if (${target_type} STREQUAL "INTERFACE_LIBRARY") + target_link_libraries(${target_name} INTERFACE CppGir::gi) + target_compile_definitions(${target_name} INTERFACE GI_INLINE) + else() + target_link_libraries(${target_name} PUBLIC CppGir::gi) + target_compile_definitions(${target_name} PUBLIC GI_INLINE) + endif() +endfunction() diff --git a/external/glib/generate_dbus.cmake b/external/glib/generate_dbus.cmake new file mode 100644 index 0000000..869cbd1 --- /dev/null +++ b/external/glib/generate_dbus.cmake @@ -0,0 +1,64 @@ +# 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 + +include(${cmake_helpers_loc}/external/glib/generate_gir.cmake) +include(${cmake_helpers_loc}/external/glib/generate_cppgir.cmake) + +function(generate_dbus target_name interface_prefix namespace interface_file) + find_program(DESKTOP_APP_GDBUSCODEGEN gdbus-codegen REQUIRED) + + set(gen_loc ${CMAKE_CURRENT_BINARY_DIR}/gen) + set(gen_dst ${gen_loc}/dbus) + file(MAKE_DIRECTORY ${gen_dst}) + + set(gen_timestamp ${gen_dst}/${target_name}_${namespace}_dbus.timestamp) + set(gen_files + ${gen_dst}/${target_name}_${namespace}_dbus.c + ${gen_dst}/${target_name}_${namespace}_dbus.h + ) + + add_custom_command( + OUTPUT + ${gen_timestamp} + BYPRODUCTS + ${gen_files} + COMMAND + ${DESKTOP_APP_GDBUSCODEGEN} + --interface-prefix + ${interface_prefix} + --generate-c-code + ${gen_dst}/${target_name}_${namespace}_dbus + --c-namespace + ${namespace} + --c-generate-object-manager + ${interface_file} + COMMAND + echo 1> ${gen_timestamp} + COMMENT "Generating D-Bus C code for ${namespace} (${target_name})" + DEPENDS + ${DESKTOP_APP_GDBUSCODEGEN} + ${interface_file} + ) + + add_library(${target_name}_${namespace}_dbus STATIC) + init_target(${target_name}_${namespace}_dbus "(gen)") + target_link_libraries(${target_name}_${namespace}_dbus PUBLIC desktop-app::external_glib) + generate_target(${target_name}_${namespace}_dbus timestamp ${gen_timestamp} "${gen_files}" ${gen_loc}) + + add_library(${target_name}_${namespace} INTERFACE) + init_target_folder(${target_name}_${namespace} "(gen)") + target_link_libraries(${target_name}_${namespace} INTERFACE ${target_name}_${namespace}_dbus) + generate_gir(${target_name}_${namespace} ${namespace} Gio-2.0 ${target_name}_${namespace}_dbus) + generate_cppgir(${target_name}_${namespace} ${CMAKE_CURRENT_BINARY_DIR}/gen/${target_name}_${namespace}.gir) + add_dependencies(${target_name}_${namespace}_cppgir ${target_name}_${namespace}_gir) + + get_target_property(target_type ${target_name} TYPE) + if (${target_type} STREQUAL "INTERFACE_LIBRARY") + target_link_libraries(${target_name} INTERFACE ${target_name}_${namespace}) + else() + target_link_libraries(${target_name} PUBLIC ${target_name}_${namespace}) + endif() +endfunction() diff --git a/external/glib/generate_gir.cmake b/external/glib/generate_gir.cmake new file mode 100644 index 0000000..643d049 --- /dev/null +++ b/external/glib/generate_gir.cmake @@ -0,0 +1,46 @@ +# 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 + +function(generate_gir target_name namespace deps src_target_name) + find_program(DESKTOP_APP_GIRSCANNER g-ir-scanner REQUIRED) + + set(gen_dst ${CMAKE_CURRENT_BINARY_DIR}/gen) + file(MAKE_DIRECTORY ${gen_dst}) + + set(gen_timestamp ${gen_dst}/${target_name}_gir.timestamp) + set(gen_file ${gen_dst}/${target_name}.gir) + + add_custom_command( + OUTPUT + ${gen_timestamp} + BYPRODUCTS + ${gen_file} + COMMAND + ${DESKTOP_APP_GIRSCANNER} + --quiet + -n + ${namespace} + --nsversion + 1.0 + -l + $ + --c-include + "$,INCLUDE,\\.h$>,$--c-include>" + -i + "$-i>" + -o + ${gen_file} + "$" + COMMAND + echo 1> ${gen_timestamp} + COMMAND_EXPAND_LISTS + COMMENT "Generating GIR (${target_name})" + DEPENDS + ${DESKTOP_APP_GIRSCANNER} + ${src_target_name} + ) + generate_target(${target_name} gir ${gen_timestamp} "${gen_file}" ${gen_dst}) +endfunction() diff --git a/external/glibmm/CMakeLists.txt b/external/glibmm/CMakeLists.txt index d9d2ce7..1251d88 100644 --- a/external/glibmm/CMakeLists.txt +++ b/external/glibmm/CMakeLists.txt @@ -8,8 +8,8 @@ add_library(external_glibmm INTERFACE IMPORTED GLOBAL) add_library(desktop-app::external_glibmm ALIAS external_glibmm) find_package(PkgConfig REQUIRED) -pkg_check_modules(GLIBMM REQUIRED IMPORTED_TARGET glibmm-2.4) -pkg_check_modules(GIOMM REQUIRED IMPORTED_TARGET giomm-2.4) +pkg_check_modules(GLIBMM REQUIRED IMPORTED_TARGET glibmm-2.68>=2.77) +pkg_check_modules(GIOMM REQUIRED IMPORTED_TARGET giomm-2.68>=2.77) if (DESKTOP_APP_USE_PACKAGED) target_link_libraries(external_glibmm @@ -26,9 +26,9 @@ else() target_link_static_libraries(external_glibmm INTERFACE - giomm-2.4 - glibmm-2.4 - sigc-2.0 + giomm-2.68 + glibmm-2.68 + sigc-3.0 ) target_link_libraries(external_glibmm diff --git a/external/gsl/CMakeLists.txt b/external/gsl/CMakeLists.txt index 1bfab92..8eaf19c 100644 --- a/external/gsl/CMakeLists.txt +++ b/external/gsl/CMakeLists.txt @@ -7,11 +7,12 @@ add_library(external_gsl INTERFACE IMPORTED GLOBAL) add_library(desktop-app::external_gsl ALIAS external_gsl) +#[[ if (DESKTOP_APP_USE_PACKAGED) if (DESKTOP_APP_USE_PACKAGED_LAZY) - find_package(Microsoft.GSL QUIET) + find_package(Microsoft.GSL 4.0.0 QUIET) else() - find_package(Microsoft.GSL) + find_package(Microsoft.GSL 4.0.0) endif() if (Microsoft.GSL_FOUND) @@ -19,6 +20,12 @@ if (DESKTOP_APP_USE_PACKAGED) return() endif() endif() +]] + +# https://gitlab.kitware.com/cmake/cmake/-/issues/25222 +if (NOT EXISTS ${third_party_loc}/GSL/include) + message(FATAL_ERROR "Guidelines Support Library is not found") +endif() target_include_directories(external_gsl SYSTEM INTERFACE diff --git a/external/hime_qt/CMakeLists.txt b/external/hime_qt/CMakeLists.txt index 869b10f..6f8d744 100644 --- a/external/hime_qt/CMakeLists.txt +++ b/external/hime_qt/CMakeLists.txt @@ -43,3 +43,23 @@ PRIVATE desktop-app::external_hime_im_client desktop-app::external_qt ) + +add_library(external_hime_qt_init OBJECT) +add_library(desktop-app::external_hime_qt_init ALIAS external_hime_qt_init) +init_target(external_hime_qt_init "(external)") + +nice_target_sources(external_hime_qt_init ${CMAKE_CURRENT_SOURCE_DIR} +PRIVATE + init.cpp +) + +target_link_libraries(external_hime_qt_init +PRIVATE + desktop-app::external_qt +) + +target_link_libraries(external_hime_qt +INTERFACE + external_hime_qt_init + $ +) diff --git a/external/hime_qt/hime_im_client/CMakeLists.txt b/external/hime_qt/hime_im_client/CMakeLists.txt index a5017c3..90aafb4 100644 --- a/external/hime_qt/hime_im_client/CMakeLists.txt +++ b/external/hime_qt/hime_im_client/CMakeLists.txt @@ -27,6 +27,11 @@ PUBLIC ${hime_im_client_src} ) +target_link_libraries(external_hime_im_client +PRIVATE + desktop-app::lib_base +) + find_package(PkgConfig REQUIRED) pkg_check_modules(X11 REQUIRED x11) diff --git a/external/hime_qt/hime_im_client/hime_im_client_helper.cpp b/external/hime_qt/hime_im_client/hime_im_client_helper.cpp index 7ad8ed6..ffb1a95 100644 --- a/external/hime_qt/hime_im_client/hime_im_client_helper.cpp +++ b/external/hime_qt/hime_im_client/hime_im_client_helper.cpp @@ -4,13 +4,10 @@ // For license and copyright information please follow this link: // https://github.com/desktop-app/legal/blob/master/LEGAL // -#include +#include "base/platform/linux/base_linux_library.h" + #include #include -#include -#include - -#define LOAD_SYMBOL(handle, func) LoadSymbol(handle, #func, func) namespace HimeHelper { namespace { @@ -50,51 +47,25 @@ void (*hime_im_client_set_client_window)( const Window win); void (*hime_im_client_set_window)(HIME_client_handle *handle, Window win); -struct HandleDeleter { - void operator()(void *handle) { - dlclose(handle); - } -}; - -using Handle = std::unique_ptr; - -bool LoadLibrary(Handle &handle, const char *name) { - handle = Handle(dlopen(name, RTLD_LAZY | RTLD_NODELETE)); - if (handle) { - return true; - } - std::cerr << dlerror() << std::endl; - return false; -} - -template -inline bool LoadSymbol(const Handle &handle, const char *name, Function &func) { - func = handle - ? reinterpret_cast(dlsym(handle.get(), name)) - : nullptr; - if (const auto error = dlerror()) { - std::cerr << error << std::endl; - } - return (func != nullptr); -} - bool Resolve() { static const auto loaded = [&] { - auto lib = Handle(); - return LoadLibrary(lib, "libhime-im-client.so.1") - && LOAD_SYMBOL(lib, hime_im_client_close) - && LOAD_SYMBOL(lib, hime_im_client_focus_in) - && LOAD_SYMBOL(lib, hime_im_client_focus_out) - && LOAD_SYMBOL(lib, hime_im_client_focus_out2) - && LOAD_SYMBOL(lib, hime_im_client_forward_key_press) - && LOAD_SYMBOL(lib, hime_im_client_forward_key_release) - && LOAD_SYMBOL(lib, hime_im_client_get_preedit) - && LOAD_SYMBOL(lib, hime_im_client_open) - && LOAD_SYMBOL(lib, hime_im_client_reset) - && LOAD_SYMBOL(lib, hime_im_client_set_cursor_location) - && LOAD_SYMBOL(lib, hime_im_client_set_flags) - && (LOAD_SYMBOL(lib, hime_im_client_set_client_window) - || LOAD_SYMBOL(lib, hime_im_client_set_window)); + const auto lib = base::Platform::LoadLibrary( + "libhime-im-client.so.1", + RTLD_NODELETE); + return lib + && LOAD_LIBRARY_SYMBOL(lib, hime_im_client_close) + && LOAD_LIBRARY_SYMBOL(lib, hime_im_client_focus_in) + && LOAD_LIBRARY_SYMBOL(lib, hime_im_client_focus_out) + && LOAD_LIBRARY_SYMBOL(lib, hime_im_client_focus_out2) + && LOAD_LIBRARY_SYMBOL(lib, hime_im_client_forward_key_press) + && LOAD_LIBRARY_SYMBOL(lib, hime_im_client_forward_key_release) + && LOAD_LIBRARY_SYMBOL(lib, hime_im_client_get_preedit) + && LOAD_LIBRARY_SYMBOL(lib, hime_im_client_open) + && LOAD_LIBRARY_SYMBOL(lib, hime_im_client_reset) + && LOAD_LIBRARY_SYMBOL(lib, hime_im_client_set_cursor_location) + && LOAD_LIBRARY_SYMBOL(lib, hime_im_client_set_flags) + && (LOAD_LIBRARY_SYMBOL(lib, hime_im_client_set_client_window) + || LOAD_LIBRARY_SYMBOL(lib, hime_im_client_set_window)); }(); return loaded; } diff --git a/external/hime_qt/init.cpp b/external/hime_qt/init.cpp new file mode 100644 index 0000000..d7b9784 --- /dev/null +++ b/external/hime_qt/init.cpp @@ -0,0 +1,10 @@ +/* +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 +*/ +#include + +Q_IMPORT_PLUGIN(QHimePlatformInputContextPlugin) diff --git a/external/hunspell/CMakeLists.txt b/external/hunspell/CMakeLists.txt index eac7373..aad7dbc 100644 --- a/external/hunspell/CMakeLists.txt +++ b/external/hunspell/CMakeLists.txt @@ -56,6 +56,7 @@ PRIVATE target_include_directories(external_hunspell_bundled PUBLIC ${hunspell_src} + ${hunspell_src}/hunspell ) target_compile_definitions(external_hunspell_bundled diff --git a/external/jemalloc/CMakeLists.txt b/external/jemalloc/CMakeLists.txt deleted file mode 100644 index f9d2775..0000000 --- a/external/jemalloc/CMakeLists.txt +++ /dev/null @@ -1,61 +0,0 @@ -# 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_jemalloc INTERFACE IMPORTED GLOBAL) -add_library(desktop-app::external_jemalloc ALIAS external_jemalloc) - -if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") - return() -endif() - -if (DESKTOP_APP_USE_PACKAGED) - find_package(PkgConfig REQUIRED) - pkg_check_modules(JEMALLOC jemalloc) - - if (JEMALLOC_FOUND) - target_include_directories(external_jemalloc SYSTEM - INTERFACE - ${JEMALLOC_INCLUDE_DIRS} - ) - - target_link_libraries(external_jemalloc - INTERFACE - -Wl,--push-state,--no-as-needed,${JEMALLOC_LINK_LIBRARIES},--pop-state - ) - - return() - endif() -endif() - -include(ExternalProject) -ExternalProject_Add(jemalloc - URL ${third_party_loc}/jemalloc - CONFIGURE_COMMAND env - CC=clang - CXX=clang++ - "EXTRA_CFLAGS=-fstack-protector-all -D_FORTIFY_SOURCE=2" - "EXTRA_CXXFLAGS=-fstack-protector-all -D_FORTIFY_SOURCE=2" - ./autogen.sh --disable-shared - BUILD_IN_SOURCE 1 - STEP_TARGETS build - EXCLUDE_FROM_ALL TRUE - BUILD_BYPRODUCTS /lib/libjemalloc_pic.a -) - -ExternalProject_Get_property(jemalloc SOURCE_DIR) -file(MAKE_DIRECTORY "${SOURCE_DIR}/include") - -target_include_directories(external_jemalloc SYSTEM -INTERFACE - ${SOURCE_DIR}/include -) - -target_link_libraries(external_jemalloc -INTERFACE - -Wl,--push-state,--whole-archive,${SOURCE_DIR}/lib/libjemalloc_pic.a,--pop-state -) - -add_dependencies(external_jemalloc jemalloc-build) diff --git a/external/jpeg/CMakeLists.txt b/external/jpeg/CMakeLists.txt index 5ed56cf..cfa4c26 100644 --- a/external/jpeg/CMakeLists.txt +++ b/external/jpeg/CMakeLists.txt @@ -4,17 +4,32 @@ # For license and copyright information please follow this link: # https://github.com/desktop-app/legal/blob/master/LEGAL -add_library(external_jpeg INTERFACE IMPORTED GLOBAL) +if (DESKTOP_APP_USE_PACKAGED) + add_library(external_jpeg INTERFACE IMPORTED GLOBAL) + add_library(desktop-app::external_jpeg ALIAS external_jpeg) + + find_package(JPEG REQUIRED) + target_link_libraries(external_jpeg INTERFACE JPEG::JPEG) + return() +endif() + +add_library(external_jpeg STATIC IMPORTED GLOBAL) add_library(desktop-app::external_jpeg ALIAS external_jpeg) -if (DESKTOP_APP_USE_PACKAGED) - find_package(JPEG) - target_link_libraries(external_jpeg INTERFACE JPEG::JPEG) -elseif (WIN32) - target_include_directories(external_jpeg SYSTEM INTERFACE ${libs_loc}/mozjpeg) - target_link_libraries(external_jpeg INTERFACE ${libs_loc}/mozjpeg/$,Debug,Release>/jpeg-static.lib) +if (WIN32) + set(jpeg_lib_loc ${libs_loc}/mozjpeg) + target_include_directories(external_jpeg SYSTEM INTERFACE ${jpeg_lib_loc}) + set_target_properties(external_jpeg PROPERTIES + IMPORTED_LOCATION "${jpeg_lib_loc}/Release/jpeg-static.lib" + IMPORTED_LOCATION_DEBUG "${jpeg_lib_loc}/Debug/jpeg-static.lib" + ) elseif (APPLE) - target_link_libraries(external_jpeg INTERFACE ${libs_loc}/local/lib/libjpeg.a) + set_target_properties(external_jpeg PROPERTIES + IMPORTED_LOCATION ${libs_loc}/local/lib/libjpeg.a + ) else() - target_link_static_libraries(external_jpeg INTERFACE jpeg) + find_library(DESKTOP_APP_JPEG_LIBRARIES libjpeg.a REQUIRED) + set_target_properties(external_jpeg PROPERTIES + IMPORTED_LOCATION "${DESKTOP_APP_JPEG_LIBRARIES}" + ) endif() diff --git a/external/kcoreaddons/CMakeLists.txt b/external/kcoreaddons/CMakeLists.txt new file mode 100644 index 0000000..6913f13 --- /dev/null +++ b/external/kcoreaddons/CMakeLists.txt @@ -0,0 +1,94 @@ +# 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_kcoreaddons INTERFACE IMPORTED GLOBAL) +add_library(desktop-app::external_kcoreaddons ALIAS external_kcoreaddons) + +if (DESKTOP_APP_USE_PACKAGED) + if (DESKTOP_APP_USE_PACKAGED_LAZY) + find_package(KF${QT_VERSION_MAJOR}CoreAddons QUIET) + else() + find_package(KF${QT_VERSION_MAJOR}CoreAddons) + endif() + + if (KF${QT_VERSION_MAJOR}CoreAddons_FOUND) + target_link_libraries(external_kcoreaddons INTERFACE KF${QT_VERSION_MAJOR}::CoreAddons) + return() + endif() +endif() + +add_library(external_kcoreaddons_bundled STATIC) +init_target(external_kcoreaddons_bundled "(external)") + +set(kcoreaddons_loc ${third_party_loc}/kcoreaddons) +set(kcoreaddons_src ${kcoreaddons_loc}/src/lib) + +nice_target_sources(external_kcoreaddons_bundled ${kcoreaddons_src} +PRIVATE + io/kurlmimedata.cpp + io/kurlmimedata.h + util/ksandbox.cpp + util/ksandbox.h + util/kshell.cpp + util/kshell.h + util/kshell_p.h + util/kshell_unix.cpp + util/kuser.h + util/kuser_unix.cpp +) + +if (NOT LINUX) + remove_target_sources(external_kcoreaddons_bundled ${kcoreaddons_src} + util/kshell.cpp + util/kshell.h + util/kshell_p.h + util/kshell_unix.cpp + util/kuser.h + util/kuser_unix.cpp + ) +endif() + +if (LINUX AND TARGET Qt::DBus) + set_source_files_properties(${kcoreaddons_src}/io/org.freedesktop.portal.FileTransfer.xml PROPERTIES INCLUDE ${kcoreaddons_src}/io/dbustypes_p.h) + qt_add_dbus_interface(_dbus_SRCS ${kcoreaddons_src}/io/org.freedesktop.portal.FileTransfer.xml org.freedesktop.portal.FileTransfer) + + set_source_files_properties(${kcoreaddons_src}/io/org.kde.KIOFuse.VFS.xml PROPERTIES NO_NAMESPACE TRUE) + qt_add_dbus_interface(_dbus_SRCS ${kcoreaddons_src}/io/org.kde.KIOFuse.VFS.xml org.kde.KIOFuse.VFS) + + target_sources(external_kcoreaddons_bundled PRIVATE ${_dbus_SRCS}) + + target_compile_definitions(external_kcoreaddons_bundled + PRIVATE + HAVE_QTDBUS + ) +endif() + +target_compile_definitions(external_kcoreaddons_bundled +PUBLIC + KCOREADDONS_EXPORT= +PRIVATE + ACCOUNTS_SERVICE_ICON_DIR="/var/lib/AccountsService/icons" +) + +target_include_directories(external_kcoreaddons_bundled SYSTEM +PUBLIC + ${kcoreaddons_src}/io + ${kcoreaddons_src}/util + ${CMAKE_CURRENT_SOURCE_DIR}/headers/public +PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/headers/private + ${CMAKE_CURRENT_BINARY_DIR} +) + +target_link_libraries(external_kcoreaddons_bundled +PRIVATE + desktop-app::external_qt +) + +target_link_libraries(external_kcoreaddons +INTERFACE + external_kcoreaddons_bundled +) diff --git a/external/kcoreaddons/headers/private/config-kdirwatch.h b/external/kcoreaddons/headers/private/config-kdirwatch.h new file mode 100644 index 0000000..e69de29 diff --git a/external/kcoreaddons/headers/private/config-util.h b/external/kcoreaddons/headers/private/config-util.h new file mode 100644 index 0000000..e69de29 diff --git a/external/kcoreaddons/headers/private/kcoreaddons_debug.h b/external/kcoreaddons/headers/private/kcoreaddons_debug.h new file mode 100644 index 0000000..07f2692 --- /dev/null +++ b/external/kcoreaddons/headers/private/kcoreaddons_debug.h @@ -0,0 +1,3 @@ +#pragma once +#include +static const QLoggingCategory KCOREADDONS_DEBUG("kf.coreaddons", QtInfoMsg); diff --git a/external/kcoreaddons/headers/public/kcoreaddons_export.h b/external/kcoreaddons/headers/public/kcoreaddons_export.h new file mode 100644 index 0000000..4342bb0 --- /dev/null +++ b/external/kcoreaddons/headers/public/kcoreaddons_export.h @@ -0,0 +1 @@ +#define KCOREADDONS_ENABLE_DEPRECATED_SINCE(major, minor) 0 diff --git a/external/kimageformats/CMakeLists.txt b/external/kimageformats/CMakeLists.txt new file mode 100644 index 0000000..f930d62 --- /dev/null +++ b/external/kimageformats/CMakeLists.txt @@ -0,0 +1,140 @@ +# 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 + +if (DESKTOP_APP_USE_PACKAGED AND NOT DESKTOP_APP_USE_PACKAGED_LAZY) + add_library(external_kimageformats INTERFACE IMPORTED GLOBAL) + add_library(desktop-app::external_kimageformats ALIAS external_kimageformats) + return() +endif() + +add_library(external_kimageformats STATIC) +add_library(desktop-app::external_kimageformats ALIAS external_kimageformats) +init_target(external_kimageformats "(external)") + +set(kimageformats_loc ${third_party_loc}/kimageformats) +set(kimageformats_src ${kimageformats_loc}/src/imageformats) + +set_target_properties(external_kimageformats PROPERTIES AUTOMOC ON) + +nice_target_sources(external_kimageformats ${kimageformats_src} +PRIVATE + avif.cpp + heif.cpp + jxl.cpp + qoi.cpp +) + +target_compile_definitions(external_kimageformats +PRIVATE + QT_STATICPLUGIN +) + +target_link_libraries(external_kimageformats +PRIVATE + desktop-app::external_qt +) + +if (DESKTOP_APP_USE_PACKAGED) + find_package(libavif REQUIRED) + find_package(PkgConfig REQUIRED) + pkg_check_modules(LIBHEIF REQUIRED IMPORTED_TARGET libheif) + pkg_check_modules(LIBJXL REQUIRED IMPORTED_TARGET libjxl) + pkg_check_modules(LIBJXL_THREADS REQUIRED IMPORTED_TARGET libjxl_threads) + + target_link_libraries(external_kimageformats + PRIVATE + avif + PkgConfig::LIBHEIF + PkgConfig::LIBJXL + PkgConfig::LIBJXL_THREADS + ) +elseif (WIN32) + target_compile_definitions(external_kimageformats + PRIVATE + JXL_STATIC_DEFINE + JXL_THREADS_STATIC_DEFINE + LIBHEIF_STATIC_BUILD + ) + + target_include_directories(external_kimageformats SYSTEM + PRIVATE + ${libs_loc}/local/include + ) + + target_link_libraries(external_kimageformats + PRIVATE + ${libs_loc}/libavif/$,Debug,Release>/avif.lib + ${libs_loc}/libheif/libheif/$,Debug,Release>/heif.lib + ${libs_loc}/libde265/libde265/$,Debug,Release>/libde265.lib + ${libs_loc}/dav1d/builddir-$,debug,release>/src/libdav1d.a + ${libs_loc}/libjxl/lib/$,Debug,Release>/jxl-static.lib + ${libs_loc}/libjxl/lib/$,Debug,Release>/jxl_threads-static.lib + ${libs_loc}/libjxl/third_party/highway/$,Debug,Release>/hwy.lib + ${libs_loc}/libjxl/third_party/brotli/$,Debug,Release>/brotlidec-static.lib + ${libs_loc}/libjxl/third_party/brotli/$,Debug,Release>/brotlienc-static.lib + ${libs_loc}/libjxl/third_party/brotli/$,Debug,Release>/brotlicommon-static.lib + ) +elseif (APPLE) + target_compile_definitions(external_kimageformats + PRIVATE + JXL_STATIC_DEFINE + JXL_THREADS_STATIC_DEFINE + LIBHEIF_STATIC_BUILD + ) + + target_include_directories(external_kimageformats SYSTEM + PRIVATE + ${libs_loc}/local/include + ) + target_link_libraries(external_kimageformats + PRIVATE + ${libs_loc}/local/lib/libavif.a + ${libs_loc}/local/lib/libheif.a + ${libs_loc}/local/lib/libde265.a + ${libs_loc}/local/lib/libdav1d.a + ${libs_loc}/local/lib/libjxl.a + ${libs_loc}/local/lib/libjxl_threads.a + ${libs_loc}/local/lib/libhwy.a + ${libs_loc}/local/lib/libbrotlidec-static.a + ${libs_loc}/local/lib/libbrotlienc-static.a + ${libs_loc}/local/lib/libbrotlicommon-static.a + ) +else() + target_link_static_libraries(external_kimageformats + PRIVATE + avif + heif + jxl + jxl_threads + dav1d + de265 + brotlidec + brotlienc + brotlicommon + hwy + lcms2 + ) +endif() + +add_library(external_kimageformats_init OBJECT) +add_library(desktop-app::external_kimageformats_init ALIAS external_kimageformats_init) +init_target(external_kimageformats_init "(external)") + +nice_target_sources(external_kimageformats_init ${CMAKE_CURRENT_SOURCE_DIR} +PRIVATE + init.cpp +) + +target_link_libraries(external_kimageformats_init +PRIVATE + desktop-app::external_qt +) + +target_link_libraries(external_kimageformats +INTERFACE + external_kimageformats_init + $ +) diff --git a/external/kimageformats/init.cpp b/external/kimageformats/init.cpp new file mode 100644 index 0000000..9713d57 --- /dev/null +++ b/external/kimageformats/init.cpp @@ -0,0 +1,12 @@ +/* +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 +*/ +#include + +Q_IMPORT_PLUGIN(QAVIFPlugin) +Q_IMPORT_PLUGIN(HEIFPlugin) +Q_IMPORT_PLUGIN(QJpegXLPlugin) diff --git a/external/kwayland/CMakeLists.txt b/external/kwayland/CMakeLists.txt deleted file mode 100644 index 2630bc1..0000000 --- a/external/kwayland/CMakeLists.txt +++ /dev/null @@ -1,134 +0,0 @@ -# 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_kwayland INTERFACE IMPORTED GLOBAL) -add_library(desktop-app::external_kwayland ALIAS external_kwayland) - -if (DESKTOP_APP_USE_PACKAGED AND NOT DESKTOP_APP_QT6) - find_package(KF5Wayland) - - if (KF5Wayland_FOUND) - target_link_libraries(external_kwayland INTERFACE KF5::WaylandClient) - return() - endif() -endif() - -add_library(external_kwayland_bundled STATIC IMPORTED) - -include(ExternalProject) - -ExternalProject_Add(extra-cmake-modules - URL ${third_party_loc}/extra-cmake-modules - CMAKE_GENERATOR Ninja - CMAKE_ARGS - -DCMAKE_BUILD_TYPE=Release - -DCMAKE_INSTALL_PREFIX= - -DCMAKE_INSTALL_DATADIR=share - -DBUILD_TESTING=OFF - BUILD_COMMAND ${CMAKE_COMMAND} --build - COMMAND ${CMAKE_COMMAND} --install - STEP_TARGETS build - EXCLUDE_FROM_ALL TRUE - BUILD_BYPRODUCTS /share/ECM/cmake/ECMConfig.cmake -) - -ExternalProject_Get_property(extra-cmake-modules BINARY_DIR) -set(extra_cmake_modules_binary_dir ${BINARY_DIR}) - -ExternalProject_Add(wayland-protocols - URL ${third_party_loc}/wayland-protocols - CONFIGURE_COMMAND meson - --prefix= - --libdir=lib - --buildtype=release - -Dtests=false - - BUILD_COMMAND meson compile -C - COMMAND meson install -C - STEP_TARGETS build - EXCLUDE_FROM_ALL TRUE - BUILD_BYPRODUCTS /share/pkgconfig/wayland-protocols.pc -) - -ExternalProject_Get_property(wayland-protocols BINARY_DIR) -set(wayland_protocols_binary_dir ${BINARY_DIR}) - -ExternalProject_Add(plasma-wayland-protocols - URL ${third_party_loc}/plasma-wayland-protocols - CMAKE_GENERATOR Ninja - CMAKE_ARGS - -DCMAKE_BUILD_TYPE=Release - -DCMAKE_INSTALL_PREFIX= - -DCMAKE_INSTALL_LIBDIR=lib - -DECM_DIR=${extra_cmake_modules_binary_dir}/share/ECM/cmake - BUILD_COMMAND ${CMAKE_COMMAND} --build - COMMAND ${CMAKE_COMMAND} --install - STEP_TARGETS build - EXCLUDE_FROM_ALL TRUE - BUILD_BYPRODUCTS /lib/cmake/PlasmaWaylandProtocols/PlasmaWaylandProtocolsConfig.cmake -) - -ExternalProject_Add_StepDependencies(plasma-wayland-protocols configure extra-cmake-modules-build) - -ExternalProject_Get_property(plasma-wayland-protocols BINARY_DIR) -set(plasma_wayland_protocols_binary_dir ${BINARY_DIR}) - -ExternalProject_Add(kwayland - URL ${third_party_loc}/kwayland - CMAKE_GENERATOR Ninja - CMAKE_ARGS - -DCMAKE_BUILD_TYPE=Release - -DBUILD_SHARED_LIBS=OFF - -DBUILD_TESTING=OFF - -DBUILD_WITH_QT6=${DESKTOP_APP_QT6} - -DEXCLUDE_DEPRECATED_BEFORE_AND_AT=5.91.0 - -DCMAKE_PREFIX_PATH=${wayland_protocols_binary_dir} - -DECM_DIR=${extra_cmake_modules_binary_dir}/share/ECM/cmake - -DPlasmaWaylandProtocols_DIR=${plasma_wayland_protocols_binary_dir}/lib/cmake/PlasmaWaylandProtocols - STEP_TARGETS build - EXCLUDE_FROM_ALL TRUE - BUILD_BYPRODUCTS /lib/libKF5WaylandClient.a -) - -ExternalProject_Add_StepDependencies(kwayland configure extra-cmake-modules-build) -ExternalProject_Add_StepDependencies(kwayland configure wayland-protocols-build) -ExternalProject_Add_StepDependencies(kwayland configure plasma-wayland-protocols-build) - -ExternalProject_Get_property(kwayland SOURCE_DIR) -ExternalProject_Get_property(kwayland BINARY_DIR) - -file(MAKE_DIRECTORY "${SOURCE_DIR}/src/client") -file(MAKE_DIRECTORY "${BINARY_DIR}/src/client") - -set_target_properties(external_kwayland_bundled PROPERTIES - IMPORTED_LOCATION "${BINARY_DIR}/lib/libKF5WaylandClient.a" -) - -target_include_directories(external_kwayland_bundled SYSTEM -INTERFACE - ${SOURCE_DIR}/src/client - ${BINARY_DIR}/src/client -) - -target_link_libraries(external_kwayland_bundled -INTERFACE - desktop-app::external_qt -) - -if (DESKTOP_APP_USE_PACKAGED) - find_package(PkgConfig REQUIRED) - pkg_check_modules(WAYLAND_CLIENT REQUIRED IMPORTED_TARGET wayland-client) - target_link_libraries(external_kwayland_bundled INTERFACE PkgConfig::WAYLAND_CLIENT) -else() - target_link_libraries(external_kwayland_bundled INTERFACE desktop-app::linux_wayland_helper) -endif() - -add_dependencies(external_kwayland_bundled kwayland-build) - -target_link_libraries(external_kwayland -INTERFACE - external_kwayland_bundled -) diff --git a/external/minizip/CMakeLists.txt b/external/minizip/CMakeLists.txt index cf77a71..9936ca3 100644 --- a/external/minizip/CMakeLists.txt +++ b/external/minizip/CMakeLists.txt @@ -17,14 +17,6 @@ if (DESKTOP_APP_USE_PACKAGED) endif() endif() -if (WIN32) - target_include_directories(external_minizip SYSTEM - INTERFACE - ${libs_loc}/zlib/contrib/minizip - ) - return() -endif() - add_library(external_minizip_bundled STATIC) init_target(external_minizip_bundled "(external)") @@ -46,6 +38,11 @@ PUBLIC ${minizip_loc} ) +target_link_libraries(external_minizip_bundled +PRIVATE + desktop-app::external_zlib +) + target_link_libraries(external_minizip INTERFACE external_minizip_bundled diff --git a/external/nimf_qt5/CMakeLists.txt b/external/nimf_qt5/CMakeLists.txt index c409663..d4b0524 100644 --- a/external/nimf_qt5/CMakeLists.txt +++ b/external/nimf_qt5/CMakeLists.txt @@ -48,3 +48,23 @@ target_link_libraries(external_nimf_qt5 PRIVATE desktop-app::external_qt ) + +add_library(external_nimf_qt5_init OBJECT) +add_library(desktop-app::external_nimf_qt5_init ALIAS external_nimf_qt5_init) +init_target(external_nimf_qt5_init "(external)") + +nice_target_sources(external_nimf_qt5_init ${CMAKE_CURRENT_SOURCE_DIR} +PRIVATE + init.cpp +) + +target_link_libraries(external_nimf_qt5_init +PRIVATE + desktop-app::external_qt +) + +target_link_libraries(external_nimf_qt5 +INTERFACE + external_nimf_qt5_init + $ +) diff --git a/external/nimf_qt5/init.cpp b/external/nimf_qt5/init.cpp new file mode 100644 index 0000000..491fc1f --- /dev/null +++ b/external/nimf_qt5/init.cpp @@ -0,0 +1,10 @@ +/* +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 +*/ +#include + +Q_IMPORT_PLUGIN(NimfInputContextPlugin) diff --git a/external/opus/CMakeLists.txt b/external/opus/CMakeLists.txt index c9a7d8e..54da4eb 100644 --- a/external/opus/CMakeLists.txt +++ b/external/opus/CMakeLists.txt @@ -41,8 +41,8 @@ else() INTERFACE /usr/local/include/opus ) - find_library(OPUS_LIBRARY libopus.a REQUIRED) + find_library(DESKTOP_APP_OPUS_LIBRARIES libopus.a REQUIRED) set_target_properties(external_opus PROPERTIES - IMPORTED_LOCATION "${OPUS_LIBRARY}" + IMPORTED_LOCATION "${DESKTOP_APP_OPUS_LIBRARIES}" ) endif() diff --git a/external/qr_code_generator/CMakeLists.txt b/external/qr_code_generator/CMakeLists.txt index b75b7ae..74dabb1 100644 --- a/external/qr_code_generator/CMakeLists.txt +++ b/external/qr_code_generator/CMakeLists.txt @@ -8,12 +8,12 @@ add_library(external_qr_code_generator INTERFACE IMPORTED GLOBAL) add_library(desktop-app::external_qr_code_generator ALIAS external_qr_code_generator) if (DESKTOP_APP_USE_PACKAGED) - find_library(QRCODE_LIBRARIES NAMES qrcodegencpp) - find_path(QRCODE_INCLUDE_DIRS qrcodegen.hpp PATH_SUFFIXES qrcodegencpp qrcodegen) + find_library(DESKTOP_APP_QRCODE_LIBRARIES NAMES qrcodegencpp) + find_path(DESKTOP_APP_QRCODE_INCLUDE_DIRS NAMES qrcodegen.hpp QrCode.hpp PATH_SUFFIXES qrcodegencpp qrcodegen) - if (QRCODE_LIBRARIES AND QRCODE_INCLUDE_DIRS) - target_include_directories(external_qr_code_generator SYSTEM INTERFACE ${QRCODE_INCLUDE_DIRS}) - target_link_libraries(external_qr_code_generator INTERFACE ${QRCODE_LIBRARIES}) + if (DESKTOP_APP_QRCODE_LIBRARIES AND DESKTOP_APP_QRCODE_INCLUDE_DIRS) + target_include_directories(external_qr_code_generator SYSTEM INTERFACE ${DESKTOP_APP_QRCODE_INCLUDE_DIRS}) + target_link_libraries(external_qr_code_generator INTERFACE ${DESKTOP_APP_QRCODE_LIBRARIES}) return() endif() endif() diff --git a/external/qt/CMakeLists.txt b/external/qt/CMakeLists.txt index 5279fad..8a9df97 100644 --- a/external/qt/CMakeLists.txt +++ b/external/qt/CMakeLists.txt @@ -4,54 +4,30 @@ # For license and copyright information please follow this link: # https://github.com/desktop-app/legal/blob/master/LEGAL -add_subdirectory(qt_static_plugins) -if (DESKTOP_APP_QT6) - add_subdirectory(qt6) - return() -endif() - add_library(external_qt INTERFACE IMPORTED GLOBAL) add_library(desktop-app::external_qt ALIAS external_qt) +add_subdirectory(qt_static_plugins) + if (DESKTOP_APP_USE_PACKAGED) target_link_libraries(external_qt INTERFACE - Qt5::Core - Qt5::Gui - Qt5::Widgets - Qt5::Network - Qt5::Svg + Qt::Core + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + $ + Qt::Widgets + Qt::WidgetsPrivate + $ + Qt::Network + Qt::Svg + $ + $ + $ + $ ) - target_include_directories(external_qt SYSTEM - INTERFACE - ${Qt5Core_PRIVATE_INCLUDE_DIRS} - ${Qt5Gui_PRIVATE_INCLUDE_DIRS} - ${Qt5Widgets_PRIVATE_INCLUDE_DIRS} - ) - - if (Qt5DBus_FOUND) - target_link_libraries(external_qt INTERFACE Qt5::DBus) - endif() - - if (Qt5XkbCommonSupport_FOUND) - target_link_libraries(external_qt INTERFACE Qt5::XkbCommonSupport) - - target_include_directories(external_qt SYSTEM - INTERFACE - ${Qt5XkbCommonSupport_PRIVATE_INCLUDE_DIRS} - ) - endif() - - if (LINUX AND NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) - target_link_libraries(external_qt INTERFACE Qt5::WaylandClient) - - target_include_directories(external_qt SYSTEM - INTERFACE - ${Qt5WaylandClient_PRIVATE_INCLUDE_DIRS} - ) - endif() - return() endif() @@ -60,75 +36,48 @@ INTERFACE ${qt_loc}/include ${qt_loc}/include/QtCore ${qt_loc}/include/QtGui + $<$:${qt_loc}/include/QtOpenGL> ${qt_loc}/include/QtWidgets + $<$:${qt_loc}/include/QtOpenGLWidgets> ${qt_loc}/include/QtSvg + $<$:${qt_loc}/include/QtDBus> + $<$:${qt_loc}/include/QtQuick> + $<$:${qt_loc}/include/QtQuickWidgets> + $<$:${qt_loc}/include/QtWaylandCompositor> ${qt_loc}/include/QtCore/${qt_version} ${qt_loc}/include/QtGui/${qt_version} + ${qt_loc}/include/QtWidgets/${qt_version} ${qt_loc}/include/QtCore/${qt_version}/QtCore ${qt_loc}/include/QtGui/${qt_version}/QtGui + ${qt_loc}/include/QtWidgets/${qt_version}/QtWidgets ) -if (Qt5DBus_FOUND) - target_include_directories(external_qt SYSTEM - INTERFACE - ${qt_loc}/include/QtDBus - ) -endif() - -if (Qt5XkbCommonSupport_FOUND) - target_include_directories(external_qt SYSTEM - INTERFACE - ${qt_loc}/include/QtXkbCommonSupport - ${qt_loc}/include/QtXkbCommonSupport/${qt_version} - ${qt_loc}/include/QtXkbCommonSupport/${qt_version}/QtXkbCommonSupport - ) -endif() - -if (LINUX AND NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) - target_include_directories(external_qt SYSTEM - INTERFACE - ${qt_loc}/include/QtWaylandClient - ${qt_loc}/include/QtWaylandClient/${qt_version} - ${qt_loc}/include/QtWaylandClient/${qt_version}/QtWaylandClient - ) -endif() - target_compile_definitions(external_qt INTERFACE _REENTRANT QT_STATICPLUGIN QT_PLUGIN - QT_WIDGETS_LIB - QT_NETWORK_LIB - QT_GUI_LIB QT_CORE_LIB + QT_GUI_LIB + $<$:QT_OPENGL_LIB> + QT_WIDGETS_LIB + $<$:QT_OPENGLWIDGETS_LIB> + QT_NETWORK_LIB QT_SVG_LIB + $<$:QT_DBUS_LIB> + $<$:QT_QUICK_LIB> + $<$:QT_QUICKWIDGETS_LIB> + $<$:QT_WAYLANDCOMPOSITOR_LIB> ) -if (Qt5DBus_FOUND) - target_compile_definitions(external_qt - INTERFACE - QT_DBUS_LIB - ) -endif() - -if (Qt5XkbCommonSupport_FOUND) - target_compile_definitions(external_qt - INTERFACE - QT_XKBCOMMON_SUPPORT_LIB - ) -endif() - -if (LINUX AND NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) - target_compile_definitions(external_qt - INTERFACE - QT_WAYLANDCLIENT_LIB - ) -endif() - if (WIN32) set(qt_lib_prefix "") set(qt_lib_suffix $<$:d>.lib) + + target_compile_definitions(external_qt + INTERFACE + _SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING + ) else() set(qt_lib_prefix lib) if (APPLE) @@ -139,36 +88,81 @@ else() endif() set(common_qt_libs - plugins/bearer/${qt_lib_prefix}qgenericbearer plugins/imageformats/${qt_lib_prefix}qwebp plugins/imageformats/${qt_lib_prefix}qgif plugins/imageformats/${qt_lib_prefix}qjpeg - lib/${qt_lib_prefix}Qt5PrintSupport - lib/${qt_lib_prefix}Qt5AccessibilitySupport - lib/${qt_lib_prefix}Qt5FontDatabaseSupport - lib/${qt_lib_prefix}Qt5EventDispatcherSupport - lib/${qt_lib_prefix}Qt5ThemeSupport - lib/${qt_lib_prefix}Qt5Network - lib/${qt_lib_prefix}Qt5Widgets - lib/${qt_lib_prefix}Qt5Gui - lib/${qt_lib_prefix}Qt5Svg - lib/${qt_lib_prefix}qtharfbuzz - lib/${qt_lib_prefix}qtlibpng + lib/${qt_lib_prefix}Qt${QT_VERSION_MAJOR}Svg + lib/${qt_lib_prefix}Qt${QT_VERSION_MAJOR}Network + lib/${qt_lib_prefix}Qt${QT_VERSION_MAJOR}Widgets + lib/${qt_lib_prefix}Qt${QT_VERSION_MAJOR}Gui + lib/${qt_lib_prefix}Qt${QT_VERSION_MAJOR}Core ) +if (TARGET Qt::OpenGL) + list(PREPEND common_qt_libs + lib/${qt_lib_prefix}Qt${QT_VERSION_MAJOR}OpenGL + ) +endif() + +if (TARGET Qt::OpenGLWidgets) + list(PREPEND common_qt_libs + lib/${qt_lib_prefix}Qt${QT_VERSION_MAJOR}OpenGLWidgets + ) +endif() + +if (TARGET Qt::Quick) + list(PREPEND common_qt_libs + lib/${qt_lib_prefix}Qt${QT_VERSION_MAJOR}Quick + lib/${qt_lib_prefix}Qt${QT_VERSION_MAJOR}Qml + lib/${qt_lib_prefix}Qt${QT_VERSION_MAJOR}QmlBuiltins + ) +endif() + +if (TARGET Qt::QuickWidgets) + list(PREPEND common_qt_libs + lib/${qt_lib_prefix}Qt${QT_VERSION_MAJOR}QuickWidgets + ) +endif() + +if (QT_VERSION_MAJOR GREATER_EQUAL 6) + list(APPEND common_qt_libs + lib/${qt_lib_prefix}Qt${QT_VERSION_MAJOR}BundledHarfbuzz + lib/${qt_lib_prefix}Qt${QT_VERSION_MAJOR}BundledLibpng + lib/${qt_lib_prefix}Qt${QT_VERSION_MAJOR}BundledPcre2 + ) +else() + list(APPEND common_qt_libs + lib/${qt_lib_prefix}qtharfbuzz + lib/${qt_lib_prefix}qtlibpng + lib/${qt_lib_prefix}qtpcre2 + ) + +endif() + set(qt_libs_list "") +if (QT_VERSION_MAJOR GREATER_EQUAL 6) + list(APPEND qt_libs_list + $ + $ + $ + ) +endif() + if (WIN32) target_include_directories(external_qt SYSTEM INTERFACE ${qt_loc}/mkspecs/win32-msvc ) set(qt_libs + plugins/bearer/${qt_lib_prefix}qgenericbearer + lib/${qt_lib_prefix}Qt${QT_VERSION_MAJOR}AccessibilitySupport + lib/${qt_lib_prefix}Qt${QT_VERSION_MAJOR}FontDatabaseSupport + lib/${qt_lib_prefix}Qt${QT_VERSION_MAJOR}EventDispatcherSupport + lib/${qt_lib_prefix}Qt${QT_VERSION_MAJOR}ThemeSupport ${common_qt_libs} - lib/${qt_lib_prefix}Qt5Core - lib/${qt_lib_prefix}Qt5WindowsUIAutomationSupport + lib/${qt_lib_prefix}Qt${QT_VERSION_MAJOR}WindowsUIAutomationSupport lib/${qt_lib_prefix}qtmain lib/${qt_lib_prefix}qtfreetype - lib/${qt_lib_prefix}qtpcre2 plugins/platforms/${qt_lib_prefix}qwindows ) foreach (lib ${qt_libs}) @@ -186,76 +180,107 @@ elseif (APPLE) ) set(qt_libs ${common_qt_libs} - lib/${qt_lib_prefix}Qt5Core - lib/${qt_lib_prefix}Qt5GraphicsSupport - lib/${qt_lib_prefix}Qt5ClipboardSupport - lib/${qt_lib_prefix}qtfreetype - lib/${qt_lib_prefix}qtpcre2 + lib/${qt_lib_prefix}Qt${QT_VERSION_MAJOR}BundledFreetype plugins/platforms/${qt_lib_prefix}qcocoa + plugins/tls/${qt_lib_prefix}qsecuretransportbackend + plugins/networkinformation/${qt_lib_prefix}qscnetworkreachability + ) + list(APPEND qt_libs_list + $ + $ + $ + $ ) foreach (lib ${qt_libs}) list(APPEND qt_libs_list "${qt_loc}/${lib}${qt_lib_suffix}") endforeach() - target_link_libraries(external_qt - INTERFACE - cups - ) else() - set(qt_libs_dbus) - set(qt_libs_dbus_support) - set(qt_libs_dbus_plugins) - set(qt_libs_dbus_bearers) - if (Qt5DBus_FOUND) - set(qt_libs_dbus lib/${qt_lib_prefix}Qt5DBus) - set(qt_libs_dbus_support lib/${qt_lib_prefix}Qt5LinuxAccessibilitySupport) - set(qt_libs_dbus_plugins - plugins/platforminputcontexts/${qt_lib_prefix}ibusplatforminputcontextplugin - ) - set(qt_libs_dbus_bearers - plugins/bearer/${qt_lib_prefix}qconnmanbearer - plugins/bearer/${qt_lib_prefix}qnmbearer - ) - endif() - set(qt_libs_waylandclient) - set(qt_libs_waylandclient_plugins) - if (NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) - set(qt_libs_waylandclient lib/${qt_lib_prefix}Qt5WaylandClient) - set(qt_libs_waylandclient_plugins - plugins/platforms/${qt_lib_prefix}qwayland-generic - plugins/platforms/${qt_lib_prefix}qwayland-egl - plugins/wayland-graphics-integration-client/${qt_lib_prefix}qt-plugin-wayland-egl - plugins/wayland-decoration-client/${qt_lib_prefix}bradient - ) - endif() set(qt_libs - plugins/platforminputcontexts/${qt_lib_prefix}composeplatforminputcontextplugin - ${qt_libs_dbus_plugins} - ${qt_libs_waylandclient_plugins} - plugins/platformthemes/${qt_lib_prefix}qgtk3 plugins/platforms/${qt_lib_prefix}qxcb plugins/xcbglintegrations/${qt_lib_prefix}qxcb-egl-integration plugins/xcbglintegrations/${qt_lib_prefix}qxcb-glx-integration + plugins/platforminputcontexts/${qt_lib_prefix}composeplatforminputcontextplugin plugins/iconengines/${qt_lib_prefix}qsvgicon - lib/${qt_lib_prefix}Qt5XcbQpa - lib/${qt_lib_prefix}Qt5EglSupport - lib/${qt_lib_prefix}Qt5GlxSupport - lib/${qt_lib_prefix}Qt5ServiceSupport - lib/${qt_lib_prefix}Qt5EdidSupport - lib/${qt_lib_prefix}Qt5XkbCommonSupport - ${qt_libs_dbus_support} - ${qt_libs_dbus_bearers} - ${qt_libs_waylandclient} - lib/${qt_lib_prefix}Qt5ServiceSupport + plugins/platformthemes/${qt_lib_prefix}qgtk3 + plugins/tls/${qt_lib_prefix}qopensslbackend + plugins/networkinformation/${qt_lib_prefix}qglib + lib/${qt_lib_prefix}Qt${QT_VERSION_MAJOR}XcbQpa ${common_qt_libs} - ${qt_libs_dbus} - lib/${qt_lib_prefix}Qt5Core - lib/${qt_lib_prefix}qtpcre2 ) + list(APPEND qt_libs_list + $ + $ + $ + $ + $ + $ + $ + $ + ) + if (TARGET Qt::DBus) + list(PREPEND qt_libs + plugins/platforminputcontexts/${qt_lib_prefix}ibusplatforminputcontextplugin + plugins/platformthemes/${qt_lib_prefix}qxdgdesktopportal + ) + list(APPEND qt_libs + lib/${qt_lib_prefix}Qt${QT_VERSION_MAJOR}DBus + lib/${qt_lib_prefix}Qt${QT_VERSION_MAJOR}Core + ) + list(APPEND qt_libs_list + $ + $ + ) + endif() + if (TARGET Qt::WaylandClient) + list(PREPEND qt_libs + plugins/platforms/${qt_lib_prefix}qwayland-generic + plugins/platforms/${qt_lib_prefix}qwayland-egl + plugins/wayland-graphics-integration-client/${qt_lib_prefix}qt-plugin-wayland-egl + plugins/wayland-shell-integration/${qt_lib_prefix}xdg-shell + plugins/wayland-decoration-client/${qt_lib_prefix}bradient + lib/${qt_lib_prefix}Qt${QT_VERSION_MAJOR}WaylandEglClientHwIntegration + lib/${qt_lib_prefix}Qt${QT_VERSION_MAJOR}WaylandClient + ) + list(APPEND qt_libs_list + $ + $ + $ + $ + $ + ) + endif() + if (TARGET Qt::WaylandCompositor) + list(PREPEND qt_libs + plugins/wayland-graphics-integration-server/${qt_lib_prefix}qt-wayland-compositor-wayland-egl + lib/${qt_lib_prefix}Qt${QT_VERSION_MAJOR}WaylandEglCompositorHwIntegration + lib/${qt_lib_prefix}Qt${QT_VERSION_MAJOR}WaylandCompositor + ) + list(APPEND qt_libs_list + $ + $ + ) + endif() foreach (lib ${qt_libs}) list(APPEND qt_libs_list "${qt_loc}/${lib}${qt_lib_suffix}") endforeach() endif() +if (QT_VERSION_MAJOR GREATER_EQUAL 6) + list(APPEND qt_libs_list + $ + $<$:$> + $ + $ + $ + ) + + if (TARGET Qt::Quick) + list(APPEND qt_libs_list + $ + ) + endif() +endif() + target_link_libraries(external_qt INTERFACE ${qt_libs_list} @@ -263,21 +288,45 @@ INTERFACE $ $ $ + $ $ $ ) -if (LINUX) +if (WIN32) + if (build_win64) + set(libwebp_release_folder x64) + else() + set(libwebp_release_folder x86) + endif() + + set(webp_lib_loc ${libs_loc}/libwebp/out/$,debug,release>-static/${libwebp_release_folder}/lib) + + target_link_libraries(external_qt + INTERFACE + ${webp_lib_loc}/libwebp$<$:_debug>.lib + ${webp_lib_loc}/libwebpdemux$<$:_debug>.lib + ${webp_lib_loc}/libwebpmux$<$:_debug>.lib + ) +elseif (APPLE) + target_link_libraries(external_qt + INTERFACE + ${libs_loc}/local/lib/libwebp.a + ${libs_loc}/local/lib/libwebpdemux.a + ${libs_loc}/local/lib/libwebpmux.a + ${libs_loc}/local/lib/libsharpyuv.a + ) + elseif (LINUX) target_include_directories(external_qt SYSTEM INTERFACE ${qt_loc}/mkspecs/linux-g++ ) target_link_static_libraries(external_qt INTERFACE - proxy - epoxy + lcms2 xkbcommon xkbcommon-x11 + xcb-cursor xcb-glx xcb-xkb xcb-randr @@ -286,27 +335,49 @@ if (LINUX) xcb-render xcb-image xcb-xfixes - xcb-xinerama - xcb-xinput xcb-shape xcb-sync xcb-util xcb-render-util xcb-keysyms + webpmux + webpdemux + webp + sharpyuv ) - if (NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) - target_link_libraries(external_qt + if (TARGET Qt::WaylandClient) + target_link_optional_libraries(external_qt INTERFACE - desktop-app::linux_wayland_helper + wayland-egl + wayland-cursor + wayland-client ) endif() + if (TARGET Qt::WaylandCompositor) + target_link_optional_libraries(external_qt + INTERFACE + wayland-server + ) + endif() + target_link_optional_libraries(external_qt + INTERFACE + gtk-3 + gdk-3 + gdk_pixbuf-2.0 + pango-1.0 + EGL + GL + X11-xcb + xcb + ) target_link_libraries(external_qt INTERFACE - desktop-app::linux_xcb_helper fontconfig freetype - xcb X11 - X11-xcb + gio-2.0 + gobject-2.0 + glib-2.0 + rt ) endif() diff --git a/external/qt/package.cmake b/external/qt/package.cmake index 52933d5..a4283f4 100644 --- a/external/qt/package.cmake +++ b/external/qt/package.cmake @@ -5,10 +5,12 @@ # https://github.com/desktop-app/legal/blob/master/LEGAL if (NOT DESKTOP_APP_USE_PACKAGED) - if (DESKTOP_APP_QT6) - set(qt_version 6.2.2) - else() - set(qt_version 5.15.2) + if (DEFINED ENV{QT}) + set(qt_version $ENV{QT} CACHE STRING "Qt version" FORCE) + endif() + + if (NOT DEFINED qt_version) + message(FATAL_ERROR "Qt version is unknown, set `QT' environment variable") endif() if (WIN32) @@ -19,39 +21,40 @@ if (NOT DESKTOP_APP_USE_PACKAGED) set(qt_loc /usr/local/desktop-app/Qt-${qt_version}) endif() - set(CMAKE_PREFIX_PATH ${qt_loc}) + set(CMAKE_PREFIX_PATH ${qt_loc} ${libs_loc}/local) endif() -if (DESKTOP_APP_QT6) - find_package(Qt6 COMPONENTS Core Core5Compat Gui OpenGL Widgets OpenGLWidgets Network Svg REQUIRED) -else() - find_package(Qt5 COMPONENTS Core Gui Widgets Network Svg REQUIRED) +if (NOT DEFINED QT_VERSION_MAJOR) + if (NOT WIN32) + find_package(QT NAMES Qt6 COMPONENTS Core) + endif() + if (NOT QT_FOUND) + find_package(QT NAMES Qt5 COMPONENTS Core) + endif() + if (NOT QT_FOUND) + message(FATAL_ERROR "Neither Qt6 nor Qt5 is found") + endif() endif() +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets Network Svg REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} OPTIONAL_COMPONENTS Quick QuickWidgets QUIET) + +set(qt_version_6_5_or_greater 0) +if (QT_VERSION_MAJOR GREATER_EQUAL 6) + if (QT_VERSION_MAJOR GREATER 6 OR Qt6_VERSION_MINOR GREATER_EQUAL 5) + set(qt_version_6_5_or_greater 1) + endif() + find_package(Qt${QT_VERSION_MAJOR} COMPONENTS OpenGL OpenGLWidgets REQUIRED) +endif() + +# QtWaylandScanner cmake integration from Qt 6 is used +cmake_dependent_option(DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION "Disable all code for Wayland integration." OFF "LINUX; qt_version_6_5_or_greater" ON) + if (LINUX) - if (NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) - if (DESKTOP_APP_QT6) - find_package(Qt6 COMPONENTS WaylandClient REQUIRED) - else() - find_package(Qt5 COMPONENTS WaylandClient REQUIRED) - find_package(Qt5 OPTIONAL_COMPONENTS XkbCommonSupport QUIET) - endif() - endif() + find_package(Qt${QT_VERSION_MAJOR} OPTIONAL_COMPONENTS DBus WaylandClient WaylandCompositor QUIET) - if ((NOT DESKTOP_APP_USE_PACKAGED - OR (DESKTOP_APP_USE_PACKAGED AND DESKTOP_APP_USE_PACKAGED_LAZY)) - AND NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION) - if (DESKTOP_APP_QT6) - find_package(Qt6 COMPONENTS DBus REQUIRED) - else() - find_package(Qt5 COMPONENTS DBus REQUIRED) - endif() - elseif (NOT DESKTOP_APP_USE_PACKAGED) - if (DESKTOP_APP_QT6) - find_package(Qt6 OPTIONAL_COMPONENTS DBus QUIET) - else() - find_package(Qt5 OPTIONAL_COMPONENTS DBus QUIET) - endif() + if (NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) + find_package(Qt${QT_VERSION_MAJOR} COMPONENTS WaylandClient REQUIRED) endif() endif() diff --git a/external/qt/qt6/CMakeLists.txt b/external/qt/qt6/CMakeLists.txt deleted file mode 100644 index 1ea1c0e..0000000 --- a/external/qt/qt6/CMakeLists.txt +++ /dev/null @@ -1,286 +0,0 @@ -# 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_qt INTERFACE IMPORTED GLOBAL) -add_library(desktop-app::external_qt ALIAS external_qt) - -if (DESKTOP_APP_USE_PACKAGED) - target_link_libraries(external_qt - INTERFACE - Qt6::Core - Qt6::Core5Compat - Qt6::Gui - Qt6::OpenGL - Qt6::Widgets - Qt6::OpenGLWidgets - Qt6::Network - Qt6::Svg - ) - - target_include_directories(external_qt SYSTEM - INTERFACE - ${Qt6Core_PRIVATE_INCLUDE_DIRS} - ${Qt6Gui_PRIVATE_INCLUDE_DIRS} - ) - - if (Qt6DBus_FOUND) - target_link_libraries(external_qt INTERFACE Qt6::DBus) - endif() - - if (LINUX AND NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) - target_link_libraries(external_qt INTERFACE Qt6::WaylandClient) - - target_include_directories(external_qt SYSTEM - INTERFACE - ${Qt6WaylandClient_PRIVATE_INCLUDE_DIRS} - ) - endif() - - return() -endif() - -target_include_directories(external_qt SYSTEM -INTERFACE - ${qt_loc}/include - ${qt_loc}/include/QtCore - ${qt_loc}/include/QtCore5Compat - ${qt_loc}/include/QtGui - ${qt_loc}/include/QtOpenGL - ${qt_loc}/include/QtWidgets - ${qt_loc}/include/QtOpenGLWidgets - ${qt_loc}/include/QtSvg - ${qt_loc}/include/QtCore/${qt_version} - ${qt_loc}/include/QtGui/${qt_version} - ${qt_loc}/include/QtCore/${qt_version}/QtCore - ${qt_loc}/include/QtGui/${qt_version}/QtGui -) - -if (Qt6DBus_FOUND) - target_include_directories(external_qt SYSTEM - INTERFACE - ${qt_loc}/include/QtDBus - ) -endif() - -if (LINUX AND NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) - target_include_directories(external_qt SYSTEM - INTERFACE - ${qt_loc}/include/QtWaylandClient - ${qt_loc}/include/QtWaylandClient/${qt_version} - ${qt_loc}/include/QtWaylandClient/${qt_version}/QtWaylandClient - ) -endif() - -target_compile_definitions(external_qt -INTERFACE - _REENTRANT - QT_STATICPLUGIN - QT_PLUGIN - QT_SVG_LIB - QT_NETWORK_LIB - QT_OPENGLWIDGETS_LIB - QT_WIDGETS_LIB - QT_OPENGL_LIB - QT_GUI_LIB - QT_CORE5COMPAT_LIB - QT_CORE_LIB -) - -if (Qt6DBus_FOUND) - target_compile_definitions(external_qt - INTERFACE - QT_DBUS_LIB - ) -endif() - -if (LINUX AND NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) - target_compile_definitions(external_qt - INTERFACE - QT_WAYLANDCLIENT_LIB - ) -endif() - -if (WIN32) - set(qt_lib_prefix "") - set(qt_lib_suffix $<$:d>.lib) -else() - set(qt_lib_prefix lib) - if (APPLE) - set(qt_lib_suffix $<$:_debug>.a) - else() - set(qt_lib_suffix .a) - endif() -endif() - -if (LINUX) - set(qt_lib_objects objects-RelWithDebInfo) -else() - set(qt_lib_objects objects-$,Debug,RelWithDebInfo>) -endif() - -set(common_qt_libs - plugins/imageformats/${qt_lib_prefix}qwebp - plugins/imageformats/${qt_lib_prefix}qgif - plugins/imageformats/${qt_lib_prefix}qjpeg - lib/${qt_lib_prefix}Qt6Svg - lib/${qt_lib_prefix}Qt6Network - lib/${qt_lib_prefix}Qt6OpenGLWidgets - lib/${qt_lib_prefix}Qt6Widgets - lib/${qt_lib_prefix}Qt6OpenGL - lib/${qt_lib_prefix}Qt6Gui - lib/${qt_lib_prefix}Qt6Core5Compat - lib/${qt_lib_prefix}Qt6Core - lib/${qt_lib_prefix}Qt6BundledHarfbuzz - lib/${qt_lib_prefix}Qt6BundledLibpng - lib/${qt_lib_prefix}Qt6BundledPcre2 -) - -set(qt_libs_list "") -if (WIN32) - target_include_directories(external_qt SYSTEM - INTERFACE - ${qt_loc}/mkspecs/win32-msvc - ) - set(qt_libs - ${common_qt_libs} - lib/${qt_lib_prefix}Qt6WindowsUIAutomationSupport - lib/${qt_lib_prefix}qtmain - lib/${qt_lib_prefix}Qt6BundledFreetype - plugins/platforms/${qt_lib_prefix}qwindows - plugins/tls/${qt_lib_prefix}qopensslbackend - ) - foreach (lib ${qt_libs}) - list(APPEND qt_libs_list "${qt_loc}/${lib}${qt_lib_suffix}") - endforeach() - - target_link_libraries(external_qt - INTERFACE - desktop-app::external_angle - ) -elseif (APPLE) - target_include_directories(external_qt SYSTEM - INTERFACE - ${qt_loc}/mkspecs/macx-clang - ) - set(qt_libs - ${common_qt_libs} - lib/${qt_lib_prefix}Qt6BundledFreetype - plugins/platforms/${qt_lib_prefix}qcocoa - plugins/tls/${qt_lib_prefix}qsecuretransportbackend - plugins/networkinformation/${qt_lib_prefix}qscnetworkreachability - ) - foreach (lib ${qt_libs}) - list(APPEND qt_libs_list "${qt_loc}/${lib}${qt_lib_suffix}") - endforeach() - list(APPEND qt_libs_list - "${qt_loc}/lib/${qt_lib_objects}/QCocoaIntegrationPlugin_resources_1/.rcc/qrc_qcocoaresources.cpp.o" - ) -else() - set(qt_libs_dbus) - set(qt_libs_dbus_plugins) - if (Qt6DBus_FOUND) - set(qt_libs_dbus - lib/${qt_lib_prefix}Qt6DBus - lib/${qt_lib_prefix}Qt6Core - ) - set(qt_libs_dbus_plugins - plugins/platforminputcontexts/${qt_lib_prefix}ibusplatforminputcontextplugin - ) - endif() - set(qt_libs_waylandclient) - set(qt_libs_waylandclient_plugins) - if (NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) - set(qt_libs_waylandclient - lib/${qt_lib_prefix}Qt6WaylandEglClientHwIntegration - lib/${qt_lib_prefix}Qt6WaylandClient - ) - set(qt_libs_waylandclient_plugins - plugins/platforms/${qt_lib_prefix}qwayland-generic - plugins/platforms/${qt_lib_prefix}qwayland-egl - plugins/wayland-graphics-integration-client/${qt_lib_prefix}qt-plugin-wayland-egl - plugins/wayland-decoration-client/${qt_lib_prefix}bradient - ) - endif() - set(qt_libs - plugins/platforminputcontexts/${qt_lib_prefix}composeplatforminputcontextplugin - ${qt_libs_dbus_plugins} - ${qt_libs_waylandclient_plugins} - plugins/platformthemes/${qt_lib_prefix}qgtk3 - plugins/platforms/${qt_lib_prefix}qxcb - plugins/tls/${qt_lib_prefix}qopensslbackend - plugins/xcbglintegrations/${qt_lib_prefix}qxcb-egl-integration - plugins/xcbglintegrations/${qt_lib_prefix}qxcb-glx-integration - plugins/iconengines/${qt_lib_prefix}qsvgicon - lib/${qt_lib_prefix}Qt6XcbQpa - ${qt_libs_waylandclient} - ${common_qt_libs} - ${qt_libs_dbus} - ) - foreach (lib ${qt_libs}) - list(APPEND qt_libs_list "${qt_loc}/${lib}${qt_lib_suffix}") - endforeach() -endif() - -list(APPEND qt_libs_list - "${qt_loc}/lib/${qt_lib_objects}/Gui_resources_1/.rcc/qrc_qpdf.cpp.o" - "${qt_loc}/lib/${qt_lib_objects}/Widgets_resources_1/.rcc/qrc_qstyle.cpp.o" - "${qt_loc}/lib/${qt_lib_objects}/Widgets_resources_2/.rcc/qrc_qstyle1.cpp.o" - "${qt_loc}/lib/${qt_lib_objects}/Widgets_resources_3/.rcc/qrc_qmessagebox.cpp.o" -) - -target_link_libraries(external_qt -INTERFACE - ${qt_libs_list} - $ - $ - $ - $ - $ - $ -) - -if (LINUX) - target_include_directories(external_qt SYSTEM - INTERFACE - ${qt_loc}/mkspecs/linux-g++ - ) - target_link_static_libraries(external_qt - INTERFACE - proxy - epoxy - xkbcommon - xkbcommon-x11 - xcb-glx - xcb-xkb - xcb-randr - xcb-icccm - xcb-shm - xcb-render - xcb-image - xcb-xfixes - xcb-xinput - xcb-shape - xcb-sync - xcb-util - xcb-render-util - xcb-keysyms - ) - if (NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) - target_link_libraries(external_qt - INTERFACE - desktop-app::linux_wayland_helper - ) - endif() - target_link_libraries(external_qt - INTERFACE - desktop-app::linux_xcb_helper - fontconfig - freetype - xcb - X11 - X11-xcb - ) -endif() diff --git a/external/qt/qt_static_plugins/CMakeLists.txt b/external/qt/qt_static_plugins/CMakeLists.txt index 7a8651a..f6d7308 100644 --- a/external/qt/qt_static_plugins/CMakeLists.txt +++ b/external/qt/qt_static_plugins/CMakeLists.txt @@ -16,26 +16,27 @@ PRIVATE target_link_libraries(external_qt_static_plugins PUBLIC desktop-app::external_qt + desktop-app::external_kimageformats ) +if (DESKTOP_APP_USE_PACKAGED) + target_compile_definitions(external_qt_static_plugins + PRIVATE + QT_STATIC_PLUGINS_USE_PACKAGED + ) +endif() + if (LINUX) target_link_libraries(external_qt_static_plugins PUBLIC desktop-app::external_nimf_qt5 ) - if (NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION) + if (TARGET Qt::DBus AND NOT DESKTOP_APP_DISABLE_X11_INTEGRATION) target_link_libraries(external_qt_static_plugins PUBLIC - desktop-app::external_fcitx_qt5 + desktop-app::external_fcitx5_qt ) - - if (NOT DESKTOP_APP_DISABLE_X11_INTEGRATION) - target_link_libraries(external_qt_static_plugins - PUBLIC - desktop-app::external_fcitx5_qt - ) - endif() endif() if (NOT DESKTOP_APP_DISABLE_X11_INTEGRATION) diff --git a/external/qt/qt_static_plugins/qt_static_plugins.cpp b/external/qt/qt_static_plugins/qt_static_plugins.cpp index b420a52..8e6a311 100644 --- a/external/qt/qt_static_plugins/qt_static_plugins.cpp +++ b/external/qt/qt_static_plugins/qt_static_plugins.cpp @@ -7,62 +7,10 @@ https://github.com/desktop-app/legal/blob/master/LEGAL */ #include -#ifndef DESKTOP_APP_USE_PACKAGED -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - -#ifdef Q_OS_MAC -Q_IMPORT_PLUGIN(QSecureTransportBackend) -Q_IMPORT_PLUGIN(QSCNetworkReachabilityNetworkInformationBackendFactory) -#else // Q_OS_MAC -Q_IMPORT_PLUGIN(QTlsBackendOpenSSL) -#endif // Q_OS_MAC - -#else // Qt >= 6.0.0 +#if !defined QT_STATIC_PLUGINS_USE_PACKAGED && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && defined Q_OS_WIN Q_IMPORT_PLUGIN(QGenericEnginePlugin) -#endif // Qt < 6.0.0 - Q_IMPORT_PLUGIN(QWebpPlugin) Q_IMPORT_PLUGIN(QJpegPlugin) Q_IMPORT_PLUGIN(QGifPlugin) - -#ifdef Q_OS_WIN Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin) -#elif defined Q_OS_MAC // Q_OS_WIN -Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin) -#elif defined Q_OS_UNIX // Q_OS_WIN | Q_OS_MAC -Q_IMPORT_PLUGIN(QXcbIntegrationPlugin) -Q_IMPORT_PLUGIN(QXcbEglIntegrationPlugin) -Q_IMPORT_PLUGIN(QXcbGlxIntegrationPlugin) -Q_IMPORT_PLUGIN(QComposePlatformInputContextPlugin) -Q_IMPORT_PLUGIN(QSvgIconPlugin) -#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) -Q_IMPORT_PLUGIN(QConnmanEnginePlugin) -Q_IMPORT_PLUGIN(QNetworkManagerEnginePlugin) -#endif // Qt < 6.0.0 -Q_IMPORT_PLUGIN(QIbusPlatformInputContextPlugin) -#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION -#ifndef DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION -Q_IMPORT_PLUGIN(QWaylandIntegrationPlugin) -Q_IMPORT_PLUGIN(QWaylandEglPlatformIntegrationPlugin) -Q_IMPORT_PLUGIN(QWaylandEglClientBufferPlugin) -Q_IMPORT_PLUGIN(QWaylandBradientDecorationPlugin) -#endif // !DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION -Q_IMPORT_PLUGIN(QGtk3ThemePlugin) -#endif // Q_OS_WIN | Q_OS_MAC | Q_OS_UNIX -#endif // !DESKTOP_APP_USE_PACKAGED - -#if defined Q_OS_UNIX && !defined Q_OS_MAC -#if !defined DESKTOP_APP_USE_PACKAGED || defined DESKTOP_APP_USE_PACKAGED_LAZY -Q_IMPORT_PLUGIN(NimfInputContextPlugin) -#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION -Q_IMPORT_PLUGIN(QFcitxPlatformInputContextPlugin) -#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION -Q_IMPORT_PLUGIN(QFcitx5PlatformInputContextPlugin) -#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION -#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION -#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION -Q_IMPORT_PLUGIN(QHimePlatformInputContextPlugin) -#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION -#endif // !DESKTOP_APP_USE_PACKAGED || DESKTOP_APP_USE_PACKAGED_LAZY -#endif // Q_OS_UNIX && !Q_OS_MAC +#endif // !QT_STATIC_PLUGINS_USE_PACKAGED && Qt < 6.0.0 && Q_OS_WIN diff --git a/external/rnnoise/CMakeLists.txt b/external/rnnoise/CMakeLists.txt index 7d68d93..31f2d3a 100644 --- a/external/rnnoise/CMakeLists.txt +++ b/external/rnnoise/CMakeLists.txt @@ -42,8 +42,8 @@ else() INTERFACE /usr/local/include ) - find_library(RNNOISE_LIBRARY librnnoise.a REQUIRED) + find_library(DESKTOP_APP_RNNOISE_LIBRARIES librnnoise.a REQUIRED) set_target_properties(external_rnnoise PROPERTIES - IMPORTED_LOCATION "${RNNOISE_LIBRARY}" + IMPORTED_LOCATION "${DESKTOP_APP_RNNOISE_LIBRARIES}" ) endif() diff --git a/external/scudo/CMakeLists.txt b/external/scudo/CMakeLists.txt new file mode 100644 index 0000000..3fc79fb --- /dev/null +++ b/external/scudo/CMakeLists.txt @@ -0,0 +1,35 @@ +# 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_scudo STATIC) +add_library(desktop-app::external_scudo ALIAS external_scudo) +init_target(external_scudo "(external)") + +set(scudo_loc ${third_party_loc}/scudo) + +# https://llvm.org/docs/ScudoHardenedAllocator.html#library +file(GLOB scudo_srcs ${scudo_loc}/*.cpp) +target_sources(external_scudo +PRIVATE + ${scudo_srcs} +) + +target_include_directories(external_scudo SYSTEM +PRIVATE + ${scudo_loc}/include +) + +add_library(external_scudo_options INTERFACE) +target_compile_options(external_scudo_options +INTERFACE + -fno-lto + -Wno-unused-result +) + +target_link_libraries(external_scudo +PRIVATE + external_scudo_options +) diff --git a/external/variant/CMakeLists.txt b/external/variant/CMakeLists.txt index 910f21c..b4e27fa 100644 --- a/external/variant/CMakeLists.txt +++ b/external/variant/CMakeLists.txt @@ -8,11 +8,11 @@ add_library(external_variant INTERFACE IMPORTED GLOBAL) add_library(desktop-app::external_variant ALIAS external_variant) if (DESKTOP_APP_USE_PACKAGED) - find_path(VARIANT_INCLUDE_DIRS mapbox/variant.hpp) - if (VARIANT_INCLUDE_DIRS) + find_path(DESKTOP_APP_VARIANT_INCLUDE_DIRS mapbox/variant.hpp) + if (DESKTOP_APP_VARIANT_INCLUDE_DIRS) target_include_directories(external_variant SYSTEM INTERFACE - ${VARIANT_INCLUDE_DIRS} + ${DESKTOP_APP_VARIANT_INCLUDE_DIRS} ) return() endif() diff --git a/external/vpx/CMakeLists.txt b/external/vpx/CMakeLists.txt index 2149b3d..39c58b0 100644 --- a/external/vpx/CMakeLists.txt +++ b/external/vpx/CMakeLists.txt @@ -46,8 +46,8 @@ else() INTERFACE /usr/local/include ) - find_library(VPX_LIBRARY libvpx.a REQUIRED) + find_library(DESKTOP_APP_VPX_LIBRARIES libvpx.a REQUIRED) set_target_properties(external_vpx PROPERTIES - IMPORTED_LOCATION "${VPX_LIBRARY}" + IMPORTED_LOCATION "${DESKTOP_APP_VPX_LIBRARIES}" ) endif() diff --git a/external/wayland_client/CMakeLists.txt b/external/wayland_client/CMakeLists.txt new file mode 100644 index 0000000..e310fae --- /dev/null +++ b/external/wayland_client/CMakeLists.txt @@ -0,0 +1,16 @@ +# 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_wayland_client INTERFACE IMPORTED GLOBAL) +add_library(desktop-app::external_wayland_client ALIAS external_wayland_client) + +if (DESKTOP_APP_USE_PACKAGED) + find_package(PkgConfig REQUIRED) + pkg_check_modules(WAYLAND_CLIENT REQUIRED IMPORTED_TARGET wayland-client) + target_link_libraries(external_wayland_client INTERFACE PkgConfig::WAYLAND_CLIENT) +else() + target_link_optional_libraries(external_wayland_client INTERFACE wayland-client) +endif() diff --git a/external/webrtc/CMakeLists.txt b/external/webrtc/CMakeLists.txt index f6ce939..0cafdbc 100644 --- a/external/webrtc/CMakeLists.txt +++ b/external/webrtc/CMakeLists.txt @@ -26,7 +26,8 @@ INTERFACE WEBRTC_USE_BUILTIN_ISAC_FLOAT WEBRTC_LIBRARY_IMPL WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=1 - WEBRTC_HAVE_USRSCTP + WEBRTC_HAVE_DCSCTP + WEBRTC_HAVE_SCTP ABSL_ALLOCATOR_NOTHROW=1 ) @@ -62,6 +63,11 @@ else() ) endif() +if (NOT EXISTS ${libs_loc}/tg_owt/out/Debug/${webrtc_lib_prefix}tg_owt${webrtc_lib_suffix}) + set(webrtc_build_loc ${libs_loc}/tg_owt/out/Release) + target_compile_definitions(external_webrtc INTERFACE $<$:NDEBUG>) +endif() + target_include_directories(external_webrtc SYSTEM INTERFACE ${webrtc_loc} @@ -89,6 +95,7 @@ INTERFACE ${webrtc_libs_list} $ $ + $ $ $ $ diff --git a/external/xcb/CMakeLists.txt b/external/xcb/CMakeLists.txt index 0f16bf3..c6ee5b3 100644 --- a/external/xcb/CMakeLists.txt +++ b/external/xcb/CMakeLists.txt @@ -16,5 +16,5 @@ if (DESKTOP_APP_USE_PACKAGED) pkg_check_modules(XCB REQUIRED IMPORTED_TARGET xcb) target_link_libraries(external_xcb INTERFACE PkgConfig::XCB) else() - target_link_libraries(external_xcb INTERFACE xcb) + target_link_optional_libraries(external_xcb INTERFACE xcb) endif() diff --git a/external/zlib/CMakeLists.txt b/external/zlib/CMakeLists.txt index 95f58e1..a248d0b 100644 --- a/external/zlib/CMakeLists.txt +++ b/external/zlib/CMakeLists.txt @@ -17,25 +17,20 @@ add_library(external_zlib STATIC IMPORTED GLOBAL) add_library(desktop-app::external_zlib ALIAS external_zlib) if (WIN32) + set(zlib_lib_loc ${libs_loc}/zlib) target_compile_definitions(external_zlib INTERFACE ZLIB_WINAPI) - target_include_directories(external_zlib SYSTEM INTERFACE ${libs_loc}/zlib) - if (build_win64) - set(zlib_config_folder x64) - else() - set(zlib_config_folder x86) - endif() - set(zlib_lib_loc ${libs_loc}/zlib/contrib/vstudio/vc14/${zlib_config_folder}) + target_include_directories(external_zlib SYSTEM INTERFACE ${zlib_lib_loc}) set_target_properties(external_zlib PROPERTIES - IMPORTED_LOCATION "${zlib_lib_loc}/ZlibStatReleaseWithoutAsm/zlibstat.lib" - IMPORTED_LOCATION_DEBUG "${zlib_lib_loc}/ZlibStatDebug/zlibstat.lib" + IMPORTED_LOCATION "${zlib_lib_loc}/Release/zlibstatic.lib" + IMPORTED_LOCATION_DEBUG "${zlib_lib_loc}/Debug/zlibstaticd.lib" ) elseif (APPLE) set_target_properties(external_zlib PROPERTIES IMPORTED_LOCATION ${libs_loc}/local/lib/libz.a ) else() - find_library(ZLIB_LIBRARY libz.a REQUIRED) + find_library(DESKTOP_APP_ZLIB_LIBRARIES libz.a REQUIRED) set_target_properties(external_zlib PROPERTIES - IMPORTED_LOCATION "${ZLIB_LIBRARY}" + IMPORTED_LOCATION "${DESKTOP_APP_ZLIB_LIBRARIES}" ) endif() diff --git a/generate_target.cmake b/generate_target.cmake index 611067f..9dc6eb8 100644 --- a/generate_target.cmake +++ b/generate_target.cmake @@ -8,7 +8,12 @@ function(generate_target parent_name postfix generated_timestamp generated_files add_custom_target(${parent_name}_${postfix} DEPENDS ${generated_timestamp}) init_target_folder(${parent_name}_${postfix} "(gen)") add_dependencies(${parent_name} ${parent_name}_${postfix}) - target_sources(${parent_name} PRIVATE ${generated_files}) - target_include_directories(${parent_name} PUBLIC ${gen_dst}) + get_target_property(parent_type ${parent_name} TYPE) + if (${parent_type} STREQUAL "INTERFACE_LIBRARY") + target_include_directories(${parent_name} SYSTEM INTERFACE ${gen_dst}) + else() + target_include_directories(${parent_name} SYSTEM PUBLIC ${gen_dst}) + target_sources(${parent_name} PRIVATE ${generated_files}) + endif() source_group("(gen)" FILES ${generated_files}) endfunction() diff --git a/init_target.cmake b/init_target.cmake index 1788fc7..549865e 100644 --- a/init_target.cmake +++ b/init_target.cmake @@ -12,49 +12,50 @@ function(init_target_folder target_name folder_name) endif() endfunction() -function(init_target target_name) # init_target(my_target folder_name) - if (ARGC GREATER 1) - if (${ARGV1} STREQUAL cxx_std_14 OR ${ARGV1} STREQUAL cxx_std_11 OR ${ARGV1} STREQUAL cxx_std_17) - target_compile_features(${target_name} PRIVATE ${ARGV1}) +function(init_target target_name) # init_target(my_target [cxx_std_..] folder_name) + set(standard ${MAXIMUM_CXX_STANDARD}) + foreach (entry ${ARGN}) + if (${entry} STREQUAL cxx_std_14 OR ${entry} STREQUAL cxx_std_11 OR ${entry} STREQUAL cxx_std_17) + set(standard ${entry}) else() - target_compile_features(${target_name} PRIVATE ${MAXIMUM_CXX_STANDARD}) - init_target_folder(${target_name} ${ARGV1}) + init_target_folder(${target_name} ${entry}) endif() - else() - target_compile_features(${target_name} PRIVATE ${MAXIMUM_CXX_STANDARD}) + endforeach() + target_compile_features(${target_name} PRIVATE ${standard}) + + if (WIN32 AND DESKTOP_APP_SPECIAL_TARGET) + set_property(TARGET ${target_name} APPEND_STRING PROPERTY STATIC_LIBRARY_OPTIONS "$,,/LTCG>") endif() - if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - set_target_properties(${target_name} PROPERTIES - MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + + if (LINUX AND NOT DESKTOP_APP_DISABLE_SCUDO AND NOT target_name STREQUAL external_scudo) + add_dependencies(${target_name} desktop-app::external_scudo) + target_link_options(${target_name} + PRIVATE + -Wl,--push-state,--whole-archive,$,--pop-state + ) endif() + target_link_libraries(${target_name} PRIVATE desktop-app::common_options) - if (NOT DESKTOP_APP_USE_PACKAGED) - set_target_properties(${target_name} PROPERTIES LINK_SEARCH_START_STATIC 1) - endif() set_target_properties(${target_name} PROPERTIES XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_WEAK YES XCODE_ATTRIBUTE_GCC_INLINES_ARE_PRIVATE_EXTERN YES XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN YES + MSVC_RUNTIME_LIBRARY MultiThreaded$<$:Debug> ) - if (DESKTOP_APP_SPECIAL_TARGET OR DESKTOP_APP_WITH_LTO) + if (DESKTOP_APP_SPECIAL_TARGET) set_target_properties(${target_name} PROPERTIES XCODE_ATTRIBUTE_GCC_OPTIMIZATION_LEVEL $,0,fast> XCODE_ATTRIBUTE_LLVM_LTO $,NO,YES> ) endif() - if (DESKTOP_APP_WITH_LTO OR (DESKTOP_APP_SPECIAL_TARGET AND WIN32 AND NOT build_win64)) - set_target_properties(${target_name} PROPERTIES - INTERPROCEDURAL_OPTIMIZATION_RELEASE True - INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO True - INTERPROCEDURAL_OPTIMIZATION_MINSIZEREL True - ) - endif() endfunction() # This code is not supposed to run on build machine, only on target machine. function(init_non_host_target target_name) - init_target(${target_name}) - set_target_properties(${target_name} PROPERTIES - OSX_ARCHITECTURES "${DESKTOP_APP_MAC_ARCH}" - ) + init_target(${ARGV}) + if (APPLE) + set_target_properties(${target_name} PROPERTIES + OSX_ARCHITECTURES "${DESKTOP_APP_MAC_ARCH}" + ) + endif() endfunction() diff --git a/linux_jemalloc_helper/CMakeLists.txt b/linux_jemalloc_helper/CMakeLists.txt deleted file mode 100644 index 0466d8a..0000000 --- a/linux_jemalloc_helper/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -# 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(linux_jemalloc_helper OBJECT) -init_target(linux_jemalloc_helper "(external)") -add_library(desktop-app::linux_jemalloc_helper ALIAS linux_jemalloc_helper) - -nice_target_sources(linux_jemalloc_helper ${CMAKE_CURRENT_SOURCE_DIR} -PRIVATE - linux_jemalloc_helper.cpp -) - -target_link_libraries(linux_jemalloc_helper -PRIVATE - desktop-app::external_jemalloc -) diff --git a/linux_jemalloc_helper/linux_jemalloc_helper.cpp b/linux_jemalloc_helper/linux_jemalloc_helper.cpp deleted file mode 100644 index 76bc863..0000000 --- a/linux_jemalloc_helper/linux_jemalloc_helper.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// 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 -// -#ifdef __FreeBSD__ -#include -#else // __FreeBSD__ -#include -#endif // !__FreeBSD__ - -namespace { - -class JemallocInitializer { -public: - JemallocInitializer() { - auto backgroundThread = true; - mallctl("background_thread", nullptr, nullptr, &backgroundThread, sizeof(bool)); - } -}; - -static const JemallocInitializer initializer; - -} // namespace diff --git a/linux_wayland_helper/CMakeLists.txt b/linux_wayland_helper/CMakeLists.txt deleted file mode 100644 index c554e94..0000000 --- a/linux_wayland_helper/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -# 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(linux_wayland_helper STATIC) -init_target(linux_wayland_helper "(external)") -add_library(desktop-app::linux_wayland_helper ALIAS linux_wayland_helper) - -nice_target_sources(linux_wayland_helper ${CMAKE_CURRENT_SOURCE_DIR} -PRIVATE - linux_wayland_helper.cpp -) - -target_link_libraries(linux_wayland_helper -PRIVATE - desktop-app::external_gsl -) diff --git a/linux_wayland_helper/linux_wayland_helper.cpp b/linux_wayland_helper/linux_wayland_helper.cpp deleted file mode 100644 index 9fb3b1f..0000000 --- a/linux_wayland_helper/linux_wayland_helper.cpp +++ /dev/null @@ -1,701 +0,0 @@ -// 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 -// -#include -#include -#include -#include -#include -#include - -#define LOAD_SYMBOL(handle, func) LoadSymbol(handle, #func, func) -#define LOAD_SYMBOL_SILENT(handle, func) LoadSymbol(handle, #func, func, true) - -namespace Wayland { -namespace { - -constexpr auto WL_CLOSURE_MAX_ARGS = 20; - -struct wl_egl_window *(*wl_egl_window_create)( - struct wl_surface *surface, - int width, - int height); -void (*wl_egl_window_destroy)(struct wl_egl_window *egl_window); -void (*wl_egl_window_resize)( - struct wl_egl_window *egl_window, - int width, - int height, - int dx, - int dy); -void (*wl_egl_window_get_attached_size)( - struct wl_egl_window *egl_window, - int *width, - int *height); - -struct wl_buffer *(*wl_cursor_image_get_buffer)( - struct wl_cursor_image *image); -struct wl_cursor_theme *(*wl_cursor_theme_load)( - const char *name, - int size, - struct wl_shm *shm); -void (*wl_cursor_theme_destroy)(struct wl_cursor_theme *theme); -struct wl_cursor *(*wl_cursor_theme_get_cursor)( - struct wl_cursor_theme *theme, - const char *name); - -int (*wl_cursor_frame_and_duration)( - struct wl_cursor *cursor, - uint32_t time, - uint32_t *duration); - -void (*wl_proxy_destroy)(struct wl_proxy *proxy); -uint32_t (*wl_proxy_get_version)(struct wl_proxy *proxy); -void (*wl_array_init)(struct wl_array *array); -void (*wl_array_release)(struct wl_array *array); -void *(*wl_array_add)(struct wl_array *array, size_t size); -int (*wl_proxy_add_listener)( - struct wl_proxy *proxy, - void (**implementation)(void), - void *data); -void (*wl_proxy_set_user_data)(struct wl_proxy *proxy, void *user_data); -void *(*wl_proxy_get_user_data)(struct wl_proxy *proxy); -int (*wl_display_get_fd)(struct wl_display *display); -int (*wl_display_get_error)(struct wl_display *display); -int (*wl_display_dispatch)(struct wl_display *display); -struct wl_event_queue *(*wl_display_create_queue)(struct wl_display *display); -int (*wl_display_dispatch_queue_pending)( - struct wl_display *display, - struct wl_event_queue *queue); -int (*wl_display_prepare_read_queue)( - struct wl_display *display, - struct wl_event_queue *queue); -int (*wl_display_flush)(struct wl_display *display); -void (*wl_display_cancel_read)(struct wl_display *display); -int (*wl_display_read_events)(struct wl_display *display); -void (*wl_event_queue_destroy)(struct wl_event_queue *queue); -int (*wl_display_prepare_read)(struct wl_display *display); -int (*wl_display_dispatch_pending)(struct wl_display *display); -struct wl_display *(*wl_display_connect)(const char *name); -struct wl_display *(*wl_display_connect_to_fd)(int fd); -void (*wl_display_disconnect)(struct wl_display *display); -void *(*wl_proxy_create_wrapper)(void *proxy); -void (*wl_proxy_wrapper_destroy)(void *proxy_wrapper); -void (*wl_proxy_set_queue)(struct wl_proxy *proxy, struct wl_event_queue *queue); -int (*wl_display_roundtrip)(struct wl_display *display); -struct wl_proxy *(*wl_proxy_marshal_array_constructor)( - struct wl_proxy *proxy, - uint32_t opcode, - union wl_argument *args, - const struct wl_interface *interface); -struct wl_proxy *(*wl_proxy_marshal_array_constructor_versioned)( - struct wl_proxy *proxy, - uint32_t opcode, - union wl_argument *args, - const struct wl_interface *interface, - uint32_t version); -struct wl_proxy *(*wl_proxy_marshal_array_flags)( - struct wl_proxy *proxy, - uint32_t opcode, - const struct wl_interface *interface, - uint32_t version, - uint32_t flags, - union wl_argument *args); -uint32_t (*wl_proxy_get_id)(struct wl_proxy *proxy); -const void *(*wl_proxy_get_listener)(struct wl_proxy *proxy); - -struct argument_details { - char type; - int nullable; -}; - -const char *get_next_argument( - const char *signature, - struct argument_details *details) { - details->nullable = 0; - for(; *signature; ++signature) { - switch(*signature) { - case 'i': - case 'u': - case 'f': - case 's': - case 'o': - case 'n': - case 'a': - case 'h': - details->type = *signature; - return signature + 1; - case '?': - details->nullable = 1; - } - } - details->type = '\0'; - return signature; -} - -void wl_argument_from_va_list( - const char *signature, - union wl_argument *args, - int count, - va_list ap) { - int i; - const char *sig_iter; - struct argument_details arg; - - sig_iter = signature; - for (i = 0; i < count; i++) { - sig_iter = get_next_argument(sig_iter, &arg); - - switch(arg.type) { - case 'i': - args[i].i = va_arg(ap, int32_t); - break; - case 'u': - args[i].u = va_arg(ap, uint32_t); - break; - case 'f': - args[i].f = va_arg(ap, wl_fixed_t); - break; - case 's': - args[i].s = va_arg(ap, const char *); - break; - case 'o': - args[i].o = va_arg(ap, struct wl_object *); - break; - case 'n': - args[i].o = va_arg(ap, struct wl_object *); - break; - case 'a': - args[i].a = va_arg(ap, struct wl_array *); - break; - case 'h': - args[i].h = va_arg(ap, int32_t); - break; - case '\0': - return; - } - } -} - -struct HandleDeleter { - void operator()(void *handle) { - dlclose(handle); - } -}; - -using Handle = std::unique_ptr; - -bool LoadLibrary(Handle &handle, const char *name) { - handle = Handle(dlopen(name, RTLD_LAZY | RTLD_NODELETE)); - if (handle) { - return true; - } - std::cerr << dlerror() << std::endl; - return false; -} - -template -inline bool LoadSymbol( - const Handle &handle, - const char *name, - Function &func, - bool silent = false) { - func = handle - ? reinterpret_cast(dlsym(handle.get(), name)) - : nullptr; - if (const auto error = dlerror(); error && !silent) { - std::cerr << error << std::endl; - } - return (func != nullptr); -} - -bool Resolve() { - static const auto loaded = [] { - auto egl = Handle(); - auto cursor = Handle(); - auto client = Handle(); - const auto required = LoadLibrary(egl, "libwayland-egl.so.1") - && LOAD_SYMBOL(egl, wl_egl_window_create) - && LOAD_SYMBOL(egl, wl_egl_window_destroy) - && LOAD_SYMBOL(egl, wl_egl_window_resize) - && LOAD_SYMBOL(egl, wl_egl_window_get_attached_size) - && LoadLibrary(cursor, "libwayland-cursor.so.0") - && LOAD_SYMBOL(cursor, wl_cursor_image_get_buffer) - && LOAD_SYMBOL(cursor, wl_cursor_theme_load) - && LOAD_SYMBOL(cursor, wl_cursor_theme_destroy) - && LOAD_SYMBOL(cursor, wl_cursor_theme_get_cursor) - && LOAD_SYMBOL(cursor, wl_cursor_frame_and_duration) - && LoadLibrary(client, "libwayland-client.so.0") - && LOAD_SYMBOL(client, wl_proxy_destroy) - && LOAD_SYMBOL(client, wl_proxy_get_version) - && LOAD_SYMBOL(client, wl_array_init) - && LOAD_SYMBOL(client, wl_array_release) - && LOAD_SYMBOL(client, wl_array_add) - && LOAD_SYMBOL(client, wl_proxy_add_listener) - && LOAD_SYMBOL(client, wl_proxy_set_user_data) - && LOAD_SYMBOL(client, wl_proxy_get_user_data) - && LOAD_SYMBOL(client, wl_display_get_fd) - && LOAD_SYMBOL(client, wl_display_get_error) - && LOAD_SYMBOL(client, wl_display_dispatch) - && LOAD_SYMBOL(client, wl_display_create_queue) - && LOAD_SYMBOL(client, wl_display_dispatch_queue_pending) - && LOAD_SYMBOL(client, wl_display_prepare_read_queue) - && LOAD_SYMBOL(client, wl_display_flush) - && LOAD_SYMBOL(client, wl_display_cancel_read) - && LOAD_SYMBOL(client, wl_display_read_events) - && LOAD_SYMBOL(client, wl_event_queue_destroy) - && LOAD_SYMBOL(client, wl_display_prepare_read) - && LOAD_SYMBOL(client, wl_display_dispatch_pending) - && LOAD_SYMBOL(client, wl_display_connect) - && LOAD_SYMBOL(client, wl_display_connect_to_fd) - && LOAD_SYMBOL(client, wl_display_disconnect) - && LOAD_SYMBOL(client, wl_proxy_create_wrapper) - && LOAD_SYMBOL(client, wl_proxy_wrapper_destroy) - && LOAD_SYMBOL(client, wl_proxy_set_queue) - && LOAD_SYMBOL(client, wl_display_roundtrip) - && LOAD_SYMBOL(client, wl_proxy_marshal_array_constructor) - && LOAD_SYMBOL(client, wl_proxy_marshal_array_constructor_versioned) - && LOAD_SYMBOL(client, wl_proxy_get_id) - && LOAD_SYMBOL(client, wl_proxy_get_listener); - LOAD_SYMBOL_SILENT(client, wl_proxy_marshal_array_flags); - return required; - }(); - return loaded; -} - -} // namespace -} // namespace Wayland - -namespace W = Wayland; - -extern "C" { - -struct wl_egl_window *wl_egl_window_create( - struct wl_surface *surface, - int width, - int height) { - Expects(W::wl_egl_window_create != nullptr); - - return W::wl_egl_window_create(surface, width, height); -} - -void wl_egl_window_destroy(struct wl_egl_window *egl_window) { - Expects(W::wl_egl_window_destroy != nullptr); - - W::wl_egl_window_destroy(egl_window); -} - -void wl_egl_window_resize( - struct wl_egl_window *egl_window, - int width, - int height, - int dx, - int dy) { - Expects(W::wl_egl_window_resize != nullptr); - - W::wl_egl_window_resize(egl_window, width, height, dx, dy); -} - -void wl_egl_window_get_attached_size( - struct wl_egl_window *egl_window, - int *width, - int *height) { - Expects(W::wl_egl_window_get_attached_size != nullptr); - - W::wl_egl_window_get_attached_size(egl_window, width, height); -} - -struct wl_buffer *wl_cursor_image_get_buffer(struct wl_cursor_image *image) { - Expects(W::wl_cursor_image_get_buffer != nullptr); - - return W::wl_cursor_image_get_buffer(image); -} - -struct wl_cursor_theme *wl_cursor_theme_load( - const char *name, - int size, - struct wl_shm *shm) { - Expects(W::wl_cursor_theme_load != nullptr); - - return W::wl_cursor_theme_load(name, size, shm); -} - -void wl_cursor_theme_destroy(struct wl_cursor_theme *theme) { - Expects(W::wl_cursor_theme_destroy != nullptr); - - W::wl_cursor_theme_destroy(theme); -} - -struct wl_cursor *wl_cursor_theme_get_cursor( - struct wl_cursor_theme *theme, - const char *name) { - Expects(W::wl_cursor_theme_get_cursor != nullptr); - - return W::wl_cursor_theme_get_cursor(theme, name); -} - -int wl_cursor_frame_and_duration( - struct wl_cursor *cursor, - uint32_t time, - uint32_t *duration) { - Expects(W::wl_cursor_frame_and_duration != nullptr); - - return W::wl_cursor_frame_and_duration(cursor, time, duration); -} - -void wl_proxy_destroy(struct wl_proxy *proxy) { - Expects(W::wl_proxy_destroy != nullptr); - - W::wl_proxy_destroy(proxy); -} - -uint32_t wl_proxy_get_version(struct wl_proxy *proxy) { - Expects(W::wl_proxy_get_version != nullptr); - - return W::wl_proxy_get_version(proxy); -} - -void wl_array_init(struct wl_array *array) { - Expects(W::wl_array_init != nullptr); - - W::wl_array_init(array); -} - -void wl_array_release(struct wl_array *array) { - Expects(W::wl_array_release != nullptr); - - W::wl_array_release(array); -} - -void *wl_array_add(struct wl_array *array, size_t size) { - Expects(W::wl_array_add != nullptr); - - return W::wl_array_add(array, size); -} - -int wl_proxy_add_listener( - struct wl_proxy *proxy, - void (**implementation)(void), - void *data) { - Expects(W::wl_proxy_add_listener != nullptr); - - return W::wl_proxy_add_listener(proxy, implementation, data); -} - -void wl_proxy_set_user_data(struct wl_proxy *proxy, void *user_data) { - Expects(W::wl_proxy_set_user_data != nullptr); - - W::wl_proxy_set_user_data(proxy, user_data); -} - -void *wl_proxy_get_user_data(struct wl_proxy *proxy) { - Expects(W::wl_proxy_get_user_data != nullptr); - - return W::wl_proxy_get_user_data(proxy); -} - -int wl_display_get_fd(struct wl_display *display) { - Expects(W::wl_display_get_fd != nullptr); - - return W::wl_display_get_fd(display); -} - -int wl_display_get_error(struct wl_display *display) { - Expects(W::wl_display_get_error != nullptr); - - return W::wl_display_get_error(display); -} - -int wl_display_dispatch(struct wl_display *display) { - Expects(W::wl_display_dispatch != nullptr); - - return W::wl_display_dispatch(display); -} - -struct wl_event_queue *wl_display_create_queue(struct wl_display *display) { - Expects(W::wl_display_create_queue != nullptr); - - return W::wl_display_create_queue(display); -} - -int wl_display_dispatch_queue_pending( - struct wl_display *display, - struct wl_event_queue *queue) { - Expects(W::wl_display_dispatch_queue_pending != nullptr); - - return W::wl_display_dispatch_queue_pending(display, queue); -} - -int wl_display_prepare_read_queue( - struct wl_display *display, - struct wl_event_queue *queue) { - Expects(W::wl_display_prepare_read_queue != nullptr); - - return W::wl_display_prepare_read_queue(display, queue); -} - -int wl_display_flush(struct wl_display *display) { - Expects(W::wl_display_flush != nullptr); - - return W::wl_display_flush(display); -} - -void wl_display_cancel_read(struct wl_display *display) { - Expects(W::wl_display_cancel_read != nullptr); - - W::wl_display_cancel_read(display); -} - -int wl_display_read_events(struct wl_display *display) { - Expects(W::wl_display_read_events != nullptr); - - return W::wl_display_read_events(display); -} - -void wl_event_queue_destroy(struct wl_event_queue *queue) { - Expects(W::wl_event_queue_destroy != nullptr); - - W::wl_event_queue_destroy(queue); -} - -int wl_display_prepare_read(struct wl_display *display) { - Expects(W::wl_display_prepare_read != nullptr); - - return W::wl_display_prepare_read(display); -} - -int wl_display_dispatch_pending(struct wl_display *display) { - Expects(W::wl_display_dispatch_pending != nullptr); - - return W::wl_display_dispatch_pending(display); -} - -struct wl_display *wl_display_connect(const char *name) { - if (!W::Resolve()) { - errno = ENOENT; - return nullptr; - } - return W::wl_display_connect(name); -} - -struct wl_display *wl_display_connect_to_fd(int fd) { - if (!W::Resolve()) { - errno = ENOENT; - return nullptr; - } - return W::wl_display_connect_to_fd(fd); -} - -void wl_display_disconnect(struct wl_display *display) { - Expects(W::wl_display_disconnect != nullptr); - - W::wl_display_disconnect(display); -} - -void *wl_proxy_create_wrapper(void *proxy) { - Expects(W::wl_proxy_create_wrapper != nullptr); - - return W::wl_proxy_create_wrapper(proxy); -} - -void wl_proxy_wrapper_destroy(void *proxy_wrapper) { - Expects(W::wl_proxy_wrapper_destroy != nullptr); - - W::wl_proxy_wrapper_destroy(proxy_wrapper); -} - -void wl_proxy_set_queue( - struct wl_proxy *proxy, - struct wl_event_queue *queue) { - Expects(W::wl_proxy_set_queue != nullptr); - - W::wl_proxy_set_queue(proxy, queue); -} - -int wl_display_roundtrip(struct wl_display *display) { - Expects(W::wl_display_roundtrip != nullptr); - - return W::wl_display_roundtrip(display); -} - -struct wl_proxy *wl_proxy_marshal_array_constructor( - struct wl_proxy *proxy, - uint32_t opcode, - union wl_argument *args, - const struct wl_interface *interface) { - Expects(W::wl_proxy_marshal_array_constructor != nullptr); - - return W::wl_proxy_marshal_array_constructor( - proxy, - opcode, - args, - interface); -} - -struct wl_proxy *wl_proxy_marshal_array_constructor_versioned( - struct wl_proxy *proxy, - uint32_t opcode, - union wl_argument *args, - const struct wl_interface *interface, - uint32_t version) { - Expects(W::wl_proxy_marshal_array_constructor_versioned != nullptr); - - return W::wl_proxy_marshal_array_constructor_versioned( - proxy, - opcode, - args, - interface, - version); -} - -struct wl_proxy *wl_proxy_marshal_array_flags( - struct wl_proxy *proxy, - uint32_t opcode, - const struct wl_interface *interface, - uint32_t version, - uint32_t flags, - union wl_argument *args) { - Expects(W::wl_proxy_marshal_array_flags != nullptr); - - return W::wl_proxy_marshal_array_flags( - proxy, - opcode, - interface, - version, - flags, - args); -} - -uint32_t wl_proxy_get_id(struct wl_proxy *proxy) { - Expects(W::wl_proxy_get_id != nullptr); - - return W::wl_proxy_get_id(proxy); -} - -const void *wl_proxy_get_listener(struct wl_proxy *proxy) { - Expects(W::wl_proxy_get_listener != nullptr); - - return W::wl_proxy_get_listener(proxy); -} - -void wl_proxy_marshal(struct wl_proxy *proxy, uint32_t opcode, ...) { - union wl_argument args[W::WL_CLOSURE_MAX_ARGS]; - va_list ap; - - va_start(ap, opcode); - - // wl_proxy { wl_object { wl_interface *, ... }, ... } - struct wl_object *object = (struct wl_object*)proxy; - struct wl_interface *interface = *((struct wl_interface**)object); - W::wl_argument_from_va_list( - interface->methods[opcode].signature, - args, - W::WL_CLOSURE_MAX_ARGS, - ap); - - va_end(ap); - - wl_proxy_marshal_array_constructor(proxy, opcode, args, nullptr); -} - -struct wl_proxy *wl_proxy_marshal_constructor( - struct wl_proxy *proxy, - uint32_t opcode, - const struct wl_interface *interface, - ...) { - union wl_argument args[W::WL_CLOSURE_MAX_ARGS]; - va_list ap; - - va_start(ap, interface); - - // wl_proxy { wl_object { wl_interface *, ... }, ... } - struct wl_object *object = (struct wl_object*)proxy; - struct wl_interface *i = *((struct wl_interface**)object); - W::wl_argument_from_va_list( - i->methods[opcode].signature, - args, - W::WL_CLOSURE_MAX_ARGS, - ap); - - va_end(ap); - - return wl_proxy_marshal_array_constructor(proxy, opcode, args, interface); -} - -struct wl_proxy *wl_proxy_marshal_constructor_versioned( - struct wl_proxy *proxy, - uint32_t opcode, - const struct wl_interface *interface, - uint32_t version, - ...) { - union wl_argument args[W::WL_CLOSURE_MAX_ARGS]; - va_list ap; - - va_start(ap, version); - - // wl_proxy { wl_object { wl_interface *, ... }, ... } - struct wl_object *object = (struct wl_object*)proxy; - struct wl_interface *i = *((struct wl_interface**)object); - W::wl_argument_from_va_list( - i->methods[opcode].signature, - args, - W::WL_CLOSURE_MAX_ARGS, - ap); - - va_end(ap); - - return wl_proxy_marshal_array_constructor_versioned(proxy, opcode, - args, interface, - version); -} - -struct wl_proxy *wl_proxy_marshal_flags( - struct wl_proxy *proxy, - uint32_t opcode, - const struct wl_interface *interface, - uint32_t version, - uint32_t flags, - ...) { - union wl_argument args[W::WL_CLOSURE_MAX_ARGS]; - va_list ap; - - va_start(ap, flags); - - // wl_proxy { wl_object { wl_interface *, ... }, ... } - struct wl_object *object = (struct wl_object*)proxy; - struct wl_interface *i = *((struct wl_interface**)object); - W::wl_argument_from_va_list( - i->methods[opcode].signature, - args, - W::WL_CLOSURE_MAX_ARGS, - ap); - - va_end(ap); - - if (W::wl_proxy_marshal_array_flags == nullptr) { - const auto result = wl_proxy_marshal_array_constructor_versioned( - proxy, - opcode, - args, - interface, - version); - - if (flags & WL_MARSHAL_FLAG_DESTROY) { - wl_proxy_destroy(proxy); - } - - return result; - } - - return wl_proxy_marshal_array_flags( - proxy, - opcode, - interface, - version, - flags, - args); -} - -} // extern "C" diff --git a/linux_xcb_helper/CMakeLists.txt b/linux_xcb_helper/CMakeLists.txt deleted file mode 100644 index 8344d6b..0000000 --- a/linux_xcb_helper/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -# 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(linux_xcb_helper STATIC) -init_target(linux_xcb_helper "(external)") -add_library(desktop-app::linux_xcb_helper ALIAS linux_xcb_helper) - -nice_target_sources(linux_xcb_helper ${CMAKE_CURRENT_SOURCE_DIR} -PRIVATE - linux_xcb_helper.cpp -) diff --git a/linux_xcb_helper/linux_xcb_helper.cpp b/linux_xcb_helper/linux_xcb_helper.cpp deleted file mode 100644 index e056830..0000000 --- a/linux_xcb_helper/linux_xcb_helper.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// 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 -// -#include -#include -#include -#include - -unsigned int xcb_send_request_with_fds( - xcb_connection_t *c, - int flags, - struct iovec *vector, - const xcb_protocol_request_t *req, - unsigned int num_fds, - int *fds) { - const auto send_request_with_fds = reinterpret_cast(dlsym(RTLD_NEXT, "xcb_send_request_with_fds")); - - if (!dlerror()) { - return send_request_with_fds(c, flags, vector, req, num_fds, fds); - } - - const auto send_fd = reinterpret_cast( - dlsym(RTLD_NEXT, "xcb_send_fd")); - - if (dlerror()) { - abort(); - } - - const auto send_request = reinterpret_cast(dlsym(RTLD_NEXT, "xcb_send_request")); - - if (dlerror()) { - abort(); - } - - for (int i = 0; i != num_fds; ++i) { - send_fd(c, fds[i]); - } - - return send_request(c, flags, vector, req); -} diff --git a/nice_target_sources.cmake b/nice_target_sources.cmake index 81f9a7b..aa24595 100644 --- a/nice_target_sources.cmake +++ b/nice_target_sources.cmake @@ -5,9 +5,6 @@ # https://github.com/desktop-app/legal/blob/master/LEGAL function(nice_target_sources target_name src_loc) - set(list ${ARGV}) - list(REMOVE_AT list 0 1) - set(writing_now "") set(private_sources "") set(public_sources "") @@ -15,7 +12,7 @@ function(nice_target_sources target_name src_loc) set(not_win_sources "") set(not_mac_sources "") set(not_linux_sources "") - foreach (entry ${list}) + foreach (entry ${ARGN}) if (${entry} STREQUAL "PRIVATE" OR ${entry} STREQUAL "PUBLIC" OR ${entry} STREQUAL "INTERFACE") set(writing_now ${entry}) else() @@ -71,11 +68,8 @@ function(nice_target_sources target_name src_loc) endfunction() function(remove_target_sources target_name src_loc) - set(list ${ARGV}) - list(REMOVE_AT list 0 1) - set(sources "") - foreach (entry ${list}) + foreach (entry ${ARGN}) set(full_name ${src_loc}/${entry}) list(APPEND sources ${full_name}) endforeach() diff --git a/nuget.cmake b/nuget.cmake index 7aba5c9..8ddce7c 100644 --- a/nuget.cmake +++ b/nuget.cmake @@ -8,7 +8,7 @@ function(nuget_add_package package_name package package_version) get_property(nuget_exe_defined GLOBAL PROPERTY nuget_exe_path_property SET) if (NOT nuget_exe_defined) # Thanks https://github.com/clarkezone/flutter_win_webview/blob/master/webview_popupauth/windows/CMakeLists.txt - find_program(NUGET_EXE NAMES nuget) + find_program(NUGET_EXE NAMES nuget PATHS "${CMAKE_SOURCE_DIR}/../ThirdParty/NuGet") if (NOT NUGET_EXE) message("NUGET.EXE not found.") message(FATAL_ERROR "Please install this executable, and run CMake again.") @@ -45,7 +45,7 @@ function(nuget_add_package package_name package package_version) endfunction() function(nuget_add_webview target_name) - nuget_add_package(webview2 "Microsoft.Web.WebView2" 1.0.864.35) + nuget_add_package(webview2 "Microsoft.Web.WebView2" 1.0.1901.177) set(webview2_loc_native ${webview2_loc}/build/native) # target_link_libraries(${target_name} @@ -77,7 +77,14 @@ function(nuget_add_winrt target_name) set(gen_dst ${CMAKE_BINARY_DIR}/packages/gen) file(MAKE_DIRECTORY ${gen_dst}/winrt) - set(winrt_sdk_version ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}) + set(winrt_sdk_version) + if (NOT DEFINED CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION) + set(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION) + endif() + # https://gitlab.kitware.com/cmake/cmake/-/blob/89cfb90b9c0893133983b4f25896671c4f07497c/Modules/InstallRequiredSystemLibraries.cmake#L381 + if (";${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION};$ENV{UCRTVersion};$ENV{WindowsSDKVersion};" MATCHES [=[;([0-9.]+)[;\]]=]) + set(winrt_sdk_version ${CMAKE_MATCH_1}) + endif() set(winrt_version_key ${gen_dst}/winrt/version_key) set(winrt_version_test ${winrt_version_key}_test) set(sdk_version_key ${gen_dst}/winrt/sdk_version_key) diff --git a/options.cmake b/options.cmake index 9e9822d..7ad2804 100644 --- a/options.cmake +++ b/options.cmake @@ -13,22 +13,9 @@ INTERFACE QT_NO_KEYWORDS QT_NO_CAST_FROM_BYTEARRAY QT_IMPLICIT_QCHAR_CONSTRUCTION + QT_DEPRECATED_WARNINGS_SINCE=0x051500 ) -if (DESKTOP_APP_DISABLE_CRASH_REPORTS) - target_compile_definitions(common_options - INTERFACE - DESKTOP_APP_DISABLE_CRASH_REPORTS - ) -endif() - -if (DESKTOP_APP_DISABLE_DBUS_INTEGRATION) - target_compile_definitions(common_options - INTERFACE - DESKTOP_APP_DISABLE_DBUS_INTEGRATION - ) -endif() - if (DESKTOP_APP_DISABLE_X11_INTEGRATION) target_compile_definitions(common_options INTERFACE @@ -36,48 +23,6 @@ if (DESKTOP_APP_DISABLE_X11_INTEGRATION) ) endif() -if (DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) - target_compile_definitions(common_options - INTERFACE - DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION - ) -endif() - -if (DESKTOP_APP_USE_PACKAGED) - target_compile_definitions(common_options - INTERFACE - DESKTOP_APP_USE_PACKAGED - ) -endif() - -if (DESKTOP_APP_USE_PACKAGED_LAZY) - target_compile_definitions(common_options - INTERFACE - DESKTOP_APP_USE_PACKAGED_LAZY - ) -endif() - -if (DESKTOP_APP_USE_PACKAGED_FONTS) - target_compile_definitions(common_options - INTERFACE - DESKTOP_APP_USE_PACKAGED_FONTS - ) -endif() - -if (DESKTOP_APP_USE_PACKAGED_RLOTTIE) - target_compile_definitions(common_options - INTERFACE - DESKTOP_APP_USE_PACKAGED_RLOTTIE - ) -endif() - -if (NOT DESKTOP_APP_SPECIAL_TARGET STREQUAL "") - target_compile_definitions(common_options - INTERFACE - DESKTOP_APP_SPECIAL_TARGET=${DESKTOP_APP_SPECIAL_TARGET} - ) -endif() - if (WIN32) include(cmake/options_win.cmake) elseif (APPLE) diff --git a/options_linux.cmake b/options_linux.cmake index 9312468..b037f67 100644 --- a/options_linux.cmake +++ b/options_linux.cmake @@ -6,68 +6,97 @@ target_compile_options(common_options INTERFACE - -fstack-protector-all - -fstack-clash-protection -fPIC - $,,-fno-strict-aliasing> + $<$>:-fno-strict-aliasing> -pipe +) + +target_compile_options_if_exists(common_options +INTERFACE -Wall - -W + -Wextra -Wno-unused-parameter -Wno-switch + -Wno-maybe-uninitialized -Wno-missing-field-initializers -Wno-sign-compare -Wno-deprecated # implicit capture of 'this' via '[=]' is deprecated in C++20 ) -target_compile_definitions(common_options -INTERFACE - $,,_FORTIFY_SOURCE=2> - _GLIBCXX_ASSERTIONS -) - -target_link_options(common_options +target_link_options_if_exists(common_options INTERFACE + -Wno-alloc-size-larger-than # Qt + LTO + -Wno-stringop-overflow # Qt + LTO + -Wno-odr # Qt + LTO + -Wno-inline # OpenAL + LTO + -pthread -Wl,--as-needed ) -if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - target_compile_options(common_options - INTERFACE - -Wno-maybe-uninitialized - ) -endif() - -# TODO: Remove when there will be no Qt 5 support -if (DESKTOP_APP_QT6) - target_compile_options(common_options - INTERFACE - -Wno-deprecated-declarations - ) -endif() - if (DESKTOP_APP_SPECIAL_TARGET) target_compile_options(common_options INTERFACE - $,,-Ofast> -Werror + $<$>:-g> + $<$>:-flto=auto> ) - target_link_options(common_options INTERFACE - $,,-Ofast> + $<$>:-flto=auto> + $<$>:-fwhole-program> ) - - target_compile_options(common_options INTERFACE $,,-g -flto>) - target_link_options(common_options INTERFACE $,,-g -flto -fuse-linker-plugin>) endif() -target_link_libraries(common_options -INTERFACE - $ - $ - ${CMAKE_DL_LIBS} -) +if (NOT DESKTOP_APP_USE_PACKAGED) + if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_link_options(common_options + INTERFACE + -static-libstdc++ + ) + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + target_link_static_libraries(common_options + INTERFACE + c++ + c++abi + ) + target_link_options(common_options + INTERFACE + -nostdlib++ + ) + endif() + set(interprocedural_optimization_config $>>) + set(interprocedural_optimization_value_on -fwhole-program) + set(interprocedural_optimization_value_off -fuse-ld=lld -fno-use-linker-plugin) + set(interprocedural_optimization_values ${interprocedural_optimization_value_on},$<$>,$>:${interprocedural_optimization_value_off}>) + target_link_options(common_options + INTERFACE + $>,$,${interprocedural_optimization_values}>,$>,${interprocedural_optimization_values}>> + -rdynamic + -Wl,-z,muldefs + ) +endif() + +if (NOT DESKTOP_APP_USE_PACKAGED OR DESKTOP_APP_SPECIAL_TARGET) + target_compile_options_if_exists(common_options + INTERFACE + -fno-omit-frame-pointer + -fstack-protector-all + -fstack-clash-protection + -fcf-protection + ) + target_link_options(common_options + INTERFACE + -Wl,-z,relro + -Wl,-z,now + -Wl,-z,noexecstack + -pie + ) + target_compile_definitions(common_options + INTERFACE + $<$>:_FORTIFY_SOURCE=3> + _GLIBCXX_ASSERTIONS + ) +endif() if (DESKTOP_APP_USE_ALLOCATION_TRACER) target_link_options(common_options @@ -92,38 +121,7 @@ if (DESKTOP_APP_USE_ALLOCATION_TRACER) ) endif() -if (DESKTOP_APP_USE_PACKAGED) - set(THREADS_PREFER_PTHREAD_FLAG ON) - find_package(Threads REQUIRED) - target_link_libraries(common_options - INTERFACE - Threads::Threads - ) -else() - if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - target_link_options(common_options - INTERFACE - -static-libstdc++ - -static-libgcc - ) - elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - target_link_static_libraries(common_options - INTERFACE - c++ - c++abi - ) - target_link_options(common_options - INTERFACE - -nostdlib++ - ) - endif() - target_link_options(common_options - INTERFACE - -pthread - -rdynamic - -fwhole-program - -Wl,-z,relro - -Wl,-z,now - # -pie # https://gitlab.gnome.org/GNOME/nautilus/-/issues/1601 - ) -endif() +target_link_libraries(common_options +INTERFACE + ${CMAKE_DL_LIBS} +) diff --git a/options_mac.cmake b/options_mac.cmake index c7792c7..8279e4a 100644 --- a/options_mac.cmake +++ b/options_mac.cmake @@ -22,12 +22,11 @@ target_compile_options(common_options INTERFACE -pipe -Wall - -W + -Wextra -fPIE $<$:-fobjc-weak> -fvisibility-inlines-hidden -fvisibility=hidden - -Wno-deprecated-declarations # temp for range-v3 -Wno-unused-variable -Wno-unused-parameter -Wno-unused-function @@ -37,6 +36,7 @@ INTERFACE -Wno-sign-compare -Wno-unknown-attributes -Wno-pragma-system-header-outside-header + -Wno-shorten-64-to-32 ) if (DESKTOP_APP_SPECIAL_TARGET) @@ -47,11 +47,6 @@ if (DESKTOP_APP_SPECIAL_TARGET) ) endif() -target_link_options(common_options -INTERFACE - -Wl,-no_compact_unwind -) - target_link_frameworks(common_options INTERFACE Cocoa diff --git a/options_win.cmake b/options_win.cmake index 884528c..2a56641 100644 --- a/options_win.cmake +++ b/options_win.cmake @@ -7,9 +7,20 @@ target_compile_definitions(common_options INTERFACE WIN32 + WIN32_LEAN_AND_MEAN _WINDOWS _SCL_SECURE_NO_WARNINGS NOMINMAX + NOSERVICE + NOMCX + NOIME + NOSOUND + NOCOMM + NOKANJI + NORPC + NOPROXYSTUB + NOIMAGE + NOTAPE UNICODE _UNICODE ) @@ -19,6 +30,7 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") /bigobj # scheme.cpp and history_widget.cpp has too many sections. /permissive- # /Qspectre + /utf-8 /W1 /WX /MP # Enable multi process build. @@ -38,8 +50,20 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") INTERFACE $,/NODEFAULTLIB:LIBCMT,/DEBUG;/OPT:REF> $<$:/DEBUG:NONE> + /INCREMENTAL:NO ) + if (DESKTOP_APP_ASAN) + target_compile_options(common_options INTERFACE /fsanitize=address) + + # https://developercommunity.visualstudio.com/t/Linker-error-LNK2038-when-using-Parallel/10512721 + target_compile_definitions(common_options + INTERFACE + _DISABLE_VECTOR_ANNOTATION + _DISABLE_STRING_ANNOTATION + ) + endif() + if (NOT build_win64) # target_compile_options(common_options # INTERFACE @@ -50,6 +74,18 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") /LARGEADDRESSAWARE # Allow more than 2 GB in 32 bit application. ) endif() + + if (DESKTOP_APP_SPECIAL_TARGET) + target_compile_options(common_options + INTERFACE + $,,/GL> + ) + target_link_options(common_options + INTERFACE + $,,/LTCG> + $,,/LTCGOUT:> + ) + endif() elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") target_compile_definitions(common_options INTERFACE diff --git a/run_cmake.py b/run_cmake.py index 67631ec..928262f 100644 --- a/run_cmake.py +++ b/run_cmake.py @@ -11,25 +11,26 @@ def run(project, arguments, buildType=''): basePath = scriptPath + '/../out/' + buildType cmake = ['cmake'] - windowsArch = '' + vsArch = '' explicitGenerator = False for arg in arguments: if arg == 'debug': cmake.append('-DCMAKE_BUILD_TYPE=Debug') elif arg == 'x86' or arg == 'x64': - windowsArch = arg + vsArch = arg elif arg != 'force': if arg.startswith('-G'): explicitGenerator = True cmake.append(arg) - if sys.platform == 'win32': - if windowsArch == 'x64': + if sys.platform == 'win32' and (vsArch == 'x64' or os.environ['Platform'] == 'x64'): + basePath = scriptPath + '/../out64/' + buildType + if sys.platform == 'win32' and not explicitGenerator: + if vsArch == 'x64': cmake.append('-Ax64') - basePath = scriptPath + '/../out64/' + buildType else: cmake.append('-AWin32') # default - elif windowsArch != '': - print("[ERROR] x86/x64 switch is supported only on Windows.") + elif vsArch != '': + print("[ERROR] x86/x64 switch is supported only with Visual Studio.") return 1 elif sys.platform == 'darwin': if not explicitGenerator: @@ -59,7 +60,8 @@ def run(project, arguments, buildType=''): elif 'force' in arguments: paths = os.listdir(basePath) for path in paths: - if path.lower().startswith('cmake'): + low = path.lower(); + if not low.startswith('debug') and not low.startswith('release'): full = basePath + '/' + path if os.path.isdir(full): shutil.rmtree(full, ignore_errors=False) @@ -67,6 +69,4 @@ def run(project, arguments, buildType=''): os.remove(full) print('Cleared previous.') os.chdir(basePath) - subprocess.call(command, shell=True) - - return 0 + return subprocess.call(command, shell=True) diff --git a/target_compile_options_if_exists.cmake b/target_compile_options_if_exists.cmake new file mode 100644 index 0000000..76282c6 --- /dev/null +++ b/target_compile_options_if_exists.cmake @@ -0,0 +1,43 @@ +# 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 + +include(CheckCXXCompilerFlag) + +function(target_compile_options_if_exists target_name) + set(writing_now "") + set(private_options "") + set(public_options "") + set(interface_options "") + foreach (entry ${ARGN}) + if (${entry} STREQUAL "PRIVATE" OR ${entry} STREQUAL "PUBLIC" OR ${entry} STREQUAL "INTERFACE") + set(writing_now ${entry}) + else() + string(MAKE_C_IDENTIFIER ${entry} entry_identifier) + check_cxx_compiler_flag(${entry} DESKTOP_APP_${entry_identifier}_EXISTS) + if (DESKTOP_APP_${entry_identifier}_EXISTS) + if ("${writing_now}" STREQUAL "PRIVATE") + list(APPEND private_options ${entry}) + elseif ("${writing_now}" STREQUAL "PUBLIC") + list(APPEND public_options ${entry}) + elseif ("${writing_now}" STREQUAL "INTERFACE") + list(APPEND interface_options ${entry}) + else() + message(FATAL_ERROR "Unknown options scope for target ${target_name}") + endif() + endif() + endif() + endforeach() + + if (NOT "${public_options}" STREQUAL "") + target_compile_options(${target_name} PUBLIC ${public_options}) + endif() + if (NOT "${private_options}" STREQUAL "") + target_compile_options(${target_name} PRIVATE ${private_options}) + endif() + if (NOT "${interface_options}" STREQUAL "") + target_compile_options(${target_name} INTERFACE ${interface_options}) + endif() +endfunction() diff --git a/target_link_frameworks.cmake b/target_link_frameworks.cmake index f5fe9a6..cec0a95 100644 --- a/target_link_frameworks.cmake +++ b/target_link_frameworks.cmake @@ -4,19 +4,16 @@ # For license and copyright information please follow this link: # https://github.com/desktop-app/legal/blob/master/LEGAL -function(target_link_frameworks target_name) - set(list ${ARGV}) - list(REMOVE_AT list 0) - +function(target_link_frameworks_generic type target_name) set(writing_now "") set(private_frameworks "") set(public_frameworks "") set(interface_frameworks "") - foreach (entry ${list}) + foreach (entry ${ARGN}) if (${entry} STREQUAL "PRIVATE" OR ${entry} STREQUAL "PUBLIC" OR ${entry} STREQUAL "INTERFACE") set(writing_now ${entry}) else() - set(full_argument "-framework ${entry}") + set(full_argument "${type} ${entry}") if ("${writing_now}" STREQUAL "PRIVATE") list(APPEND private_frameworks ${full_argument}) elseif ("${writing_now}" STREQUAL "PUBLIC") @@ -39,3 +36,11 @@ function(target_link_frameworks target_name) target_link_libraries(${target_name} INTERFACE ${interface_frameworks}) endif() endfunction() + +function(target_link_frameworks) + target_link_frameworks_generic("-framework" ${ARGN}) +endfunction() + +function(target_link_frameworks_weak) + target_link_frameworks_generic("-weak_framework" ${ARGN}) +endfunction() diff --git a/target_link_optional_libraries.cmake b/target_link_optional_libraries.cmake new file mode 100644 index 0000000..32436d1 --- /dev/null +++ b/target_link_optional_libraries.cmake @@ -0,0 +1,87 @@ +# 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 + +function(generate_implib) + find_package(Python3 REQUIRED) + + set(gen_dst ${CMAKE_CURRENT_BINARY_DIR}/gen) + file(MAKE_DIRECTORY ${gen_dst}) + + foreach (lib ${ARGN}) + string(MAKE_C_IDENTIFIER ${lib} lib_identifier) + find_library(DESKTOP_APP_${lib_identifier}_PATH ${lib} REQUIRED) + get_filename_component(lib_file ${DESKTOP_APP_${lib_identifier}_PATH} NAME) + + set(gen_timestamp ${gen_dst}/implib_${lib_identifier}.timestamp) + set(gen_files + ${gen_dst}/${lib_file}.init.c + ${gen_dst}/${lib_file}.tramp.S + ) + + add_custom_command( + OUTPUT + ${gen_timestamp} + BYPRODUCTS + ${gen_files} + COMMAND + ${Python3_EXECUTABLE} + ${cmake_helpers_loc}/external/Implib.so/implib-gen.py + -q + -o + ${gen_dst} + ${DESKTOP_APP_${lib_identifier}_PATH} + COMMAND + echo 1> ${gen_timestamp} + COMMENT "Generating dlopen helper for ${lib_file}" + DEPENDS + ${DESKTOP_APP_${lib_identifier}_PATH} + ) + + add_library(implib_${lib_identifier} STATIC) + init_target(implib_${lib_identifier} "(gen)") + generate_target(implib_${lib_identifier} timestamp ${gen_timestamp} "${gen_files}" ${gen_dst}) + endforeach() +endfunction() + +function(target_link_optional_libraries target_name) + set(writing_now "") + set(private_libs "") + set(public_libs "") + set(interface_libs "") + foreach (entry ${ARGN}) + if (${entry} STREQUAL "PRIVATE" OR ${entry} STREQUAL "PUBLIC" OR ${entry} STREQUAL "INTERFACE") + set(writing_now ${entry}) + else() + string(MAKE_C_IDENTIFIER ${entry} entry_identifier) + if (NOT TARGET implib_${entry_identifier}) + generate_implib(${entry}) + endif() + set(result + $ + $ + ) + if ("${writing_now}" STREQUAL "PRIVATE") + list(APPEND private_libs ${result}) + elseif ("${writing_now}" STREQUAL "PUBLIC") + list(APPEND public_libs ${result}) + elseif ("${writing_now}" STREQUAL "INTERFACE") + list(APPEND interface_libs ${result}) + else() + message(FATAL_ERROR "Unknown libraries scope for target ${target_name}") + endif() + endif() + endforeach() + + if (NOT "${public_libs}" STREQUAL "") + target_link_libraries(${target_name} PUBLIC ${public_libs}) + endif() + if (NOT "${private_libs}" STREQUAL "") + target_link_libraries(${target_name} PRIVATE ${private_libs}) + endif() + if (NOT "${interface_libs}" STREQUAL "") + target_link_libraries(${target_name} INTERFACE ${interface_libs}) + endif() +endfunction() diff --git a/target_link_options_if_exists.cmake b/target_link_options_if_exists.cmake new file mode 100644 index 0000000..cabd8b3 --- /dev/null +++ b/target_link_options_if_exists.cmake @@ -0,0 +1,43 @@ +# 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 + +include(CheckLinkerFlag) + +function(target_link_options_if_exists target_name) + set(writing_now "") + set(private_options "") + set(public_options "") + set(interface_options "") + foreach (entry ${ARGN}) + if (${entry} STREQUAL "PRIVATE" OR ${entry} STREQUAL "PUBLIC" OR ${entry} STREQUAL "INTERFACE") + set(writing_now ${entry}) + else() + string(MAKE_C_IDENTIFIER ${entry} entry_identifier) + check_linker_flag(CXX ${entry} DESKTOP_APP_${entry_identifier}_EXISTS) + if (DESKTOP_APP_${entry_identifier}_EXISTS) + if ("${writing_now}" STREQUAL "PRIVATE") + list(APPEND private_options ${entry}) + elseif ("${writing_now}" STREQUAL "PUBLIC") + list(APPEND public_options ${entry}) + elseif ("${writing_now}" STREQUAL "INTERFACE") + list(APPEND interface_options ${entry}) + else() + message(FATAL_ERROR "Unknown options scope for target ${target_name}") + endif() + endif() + endif() + endforeach() + + if (NOT "${public_options}" STREQUAL "") + target_link_options(${target_name} PUBLIC ${public_options}) + endif() + if (NOT "${private_options}" STREQUAL "") + target_link_options(${target_name} PRIVATE ${private_options}) + endif() + if (NOT "${interface_options}" STREQUAL "") + target_link_options(${target_name} INTERFACE ${interface_options}) + endif() +endfunction() diff --git a/target_link_static_libraries.cmake b/target_link_static_libraries.cmake index d52912b..41a747f 100644 --- a/target_link_static_libraries.cmake +++ b/target_link_static_libraries.cmake @@ -5,14 +5,11 @@ # https://github.com/desktop-app/legal/blob/master/LEGAL function(target_link_static_libraries target_name) - set(list ${ARGV}) - list(REMOVE_AT list 0) - set(writing_now "") set(private_libs "") set(public_libs "") set(interface_libs "") - foreach (entry ${list}) + foreach (entry ${ARGN}) if (${entry} STREQUAL "PRIVATE" OR ${entry} STREQUAL "PUBLIC" OR ${entry} STREQUAL "INTERFACE") set(writing_now ${entry}) else() @@ -24,7 +21,7 @@ function(target_link_static_libraries target_name) elseif ("${writing_now}" STREQUAL "INTERFACE") list(APPEND interface_libs ${link_option}) else() - message(FATAL_ERROR "Unknown frameworks scope for target ${target_name}") + message(FATAL_ERROR "Unknown libraries scope for target ${target_name}") endif() endif() endforeach() diff --git a/target_prepare_qrc.cmake b/target_prepare_qrc.cmake index 0e2ec4b..342f41e 100644 --- a/target_prepare_qrc.cmake +++ b/target_prepare_qrc.cmake @@ -5,8 +5,7 @@ # https://github.com/desktop-app/legal/blob/master/LEGAL function(target_add_resource target_name) - set(list ${ARGV}) - list(REMOVE_AT list 0) + set(list ${ARGN}) target_sources(${target_name} PRIVATE ${list}) get_target_property(existing_resources ${target_name} RESOURCE) if (NOT "${existing_resources}" STREQUAL "existing_resources-NOTFOUND") @@ -23,25 +22,24 @@ function(target_prepare_qrc target_name) else() set(rcc_flags --binary "$") - set(qrc_files_all "$,INCLUDE,\\.qrc$>") - if (WIN32) - set(qrc_files "$") - elseif (APPLE) - set(qrc_files "$") - elseif (LINUX) - set(qrc_files "$") + set(qrc_files) + get_target_property(list ${target_name} SOURCES) + foreach (entry ${list}) + get_source_file_property(skip_autogen ${entry} SKIP_AUTOGEN) + if (NOT ${entry} MATCHES "\\.qrc$" OR skip_autogen) + continue() + endif() + list(APPEND qrc_files ${entry}) + endforeach() + if (NOT qrc_files) + return() endif() set(rcc_file ${target_name}.rcc) set(rcc_path "${CMAKE_BINARY_DIR}/${rcc_file}") source_group(TREE ${CMAKE_BINARY_DIR} PREFIX Resources FILES ${rcc_path}) - if (DESKTOP_APP_QT6) - set(rcc_binary Qt6::rcc) - else() - set(rcc_binary Qt5::rcc) - endif() add_custom_command(OUTPUT ${rcc_path} DEPENDS ${qrc_files} - COMMAND ${rcc_binary} ${rcc_flags} -o ${rcc_path} ${qrc_files} + COMMAND Qt::rcc ${rcc_flags} -o ${rcc_path} ${qrc_files} COMMAND_EXPAND_LISTS VERBATIM ) target_add_resource(${target_name} ${rcc_path}) diff --git a/validate_d3d_compiler.cmake b/validate_d3d_compiler.cmake index 5330b52..a3d6919 100644 --- a/validate_d3d_compiler.cmake +++ b/validate_d3d_compiler.cmake @@ -21,7 +21,7 @@ function(validate_d3d_compiler target_name) set(modules_hash_loc ${CMAKE_BINARY_DIR}/modules/${modules_subdir}) set(modules_debug_loc ${CMAKE_BINARY_DIR}/Debug/modules/${modules_subdir}) set(modules_release_loc ${CMAKE_BINARY_DIR}/Release/modules/${modules_subdir}) - + set(key_path ${modules_hash_loc}/d3d/d3dcompiler_47) set(module_debug_path ${modules_debug_loc}/d3d) set(module_release_path ${modules_release_loc}/d3d) @@ -39,17 +39,17 @@ function(validate_d3d_compiler target_name) if (NOT "${key_length}" STREQUAL "32" OR NOT EXISTS ${module_debug_path}/d3dcompiler_47.dll OR NOT EXISTS ${module_release_path}/d3dcompiler_47.dll) - + if ("${windows_sdk_loc}" STREQUAL "") validate_d3d_error("Could not find Windows SDK.") return() endif() set(sdk_compiler ${windows_sdk_loc}/Redist/D3D/${modules_subdir}/d3dcompiler_47.dll) - find_package(Python REQUIRED) + find_package(Python3 REQUIRED) execute_process( COMMAND - ${Python_EXECUTABLE} + ${Python3_EXECUTABLE} ${cmake_helpers_loc}/validate_d3d_compiler.py ${sdk_compiler} OUTPUT_VARIABLE key @@ -66,7 +66,7 @@ function(validate_d3d_compiler target_name) file(MAKE_DIRECTORY ${modules_release_loc}/d3d) file(COPY ${sdk_compiler} DESTINATION ${module_release_path}) - file(MAKE_DIRECTORY ${modules_hash_loc}/d3d) + file(MAKE_DIRECTORY ${modules_hash_loc}/d3d) file(WRITE ${key_path} ${key}) endif() diff --git a/validate_d3d_compiler.py b/validate_d3d_compiler.py index 60747f6..40edce9 100644 --- a/validate_d3d_compiler.py +++ b/validate_d3d_compiler.py @@ -25,7 +25,7 @@ if not os.path.exists(inputPath): info = GetFileVersionInfo(inputPath, '\\') version = [ info['FileVersionMS'] // 65536, info['FileVersionMS'] % 65536, info['FileVersionLS'] // 65536, info['FileVersionLS'] % 65536 ] -if (version != [10, 0, 22000, 194]): +if (version != [10, 0, 22000, 832]): error('Bad "d3dcompiler_47.dll" version: ' + '.'.join(str(x) for x in version)) bufferSize = 1024 * 1024 diff --git a/validate_special_target.cmake b/validate_special_target.cmake index dc55e50..8fa3582 100644 --- a/validate_special_target.cmake +++ b/validate_special_target.cmake @@ -4,19 +4,16 @@ # For license and copyright information please follow this link: # https://github.com/desktop-app/legal/blob/master/LEGAL +include(CMakeDependentOption) + set(DESKTOP_APP_SPECIAL_TARGET "" CACHE STRING "Use special platform target, like 'macstore' for Mac App Store.") -set(no_special_target 0) -if (DESKTOP_APP_SPECIAL_TARGET STREQUAL "") - set(no_special_target 1) +get_filename_component(libs_loc "../Libraries" REALPATH) +set(libs_loc_exists 0) +if (EXISTS ${libs_loc}) + set(libs_loc_exists 1) endif() -option(DESKTOP_APP_USE_PACKAGED "Find libraries using CMake instead of exact paths." ${no_special_target}) - -set(default_to_qt6 1) -if (WIN32) - set(default_to_qt6 0) -endif() -option(DESKTOP_APP_QT6 "Build with Qt 6" ${default_to_qt6}) +cmake_dependent_option(DESKTOP_APP_USE_PACKAGED "Find libraries using CMake instead of exact paths." OFF libs_loc_exists ON) function(report_bad_special_target) if (NOT DESKTOP_APP_SPECIAL_TARGET STREQUAL "") @@ -25,11 +22,9 @@ function(report_bad_special_target) endfunction() if (NOT DESKTOP_APP_USE_PACKAGED) - set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12 CACHE STRING "Minimum macOS deployment version" FORCE) - if (DESKTOP_APP_QT6) + set(CMAKE_OSX_DEPLOYMENT_TARGET 10.13 CACHE STRING "Minimum macOS deployment version" FORCE) + if (NOT DEFINED CMAKE_OSX_ARCHITECTURES) set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "Target macOS architectures" FORCE) - else() - set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "Target macOS architectures" FORCE) endif() endif() diff --git a/variables.cmake b/variables.cmake index 3b0b5ef..f0f2644 100644 --- a/variables.cmake +++ b/variables.cmake @@ -4,6 +4,8 @@ # For license and copyright information please follow this link: # https://github.com/desktop-app/legal/blob/master/LEGAL +include(CMakeDependentOption) + set(no_special_target 0) if (DESKTOP_APP_SPECIAL_TARGET STREQUAL "") set(no_special_target 1) @@ -18,35 +20,40 @@ if (DESKTOP_APP_SPECIAL_TARGET STREQUAL "" endif() option(DESKTOP_APP_LOTTIE_USE_CACHE "Use caching in lottie animations." ON) -option(DESKTOP_APP_DISABLE_DBUS_INTEGRATION "Disable all code for D-Bus integration (Linux only)." OFF) -option(DESKTOP_APP_DISABLE_X11_INTEGRATION "Disable all code for X11 integration (Linux only)." OFF) -option(DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION "Disable all code for Wayland integration (Linux only)." OFF) -option(DESKTOP_APP_USE_ALLOCATION_TRACER "Use simple allocation tracer (Linux only)." OFF) -option(DESKTOP_APP_USE_PACKAGED_LAZY "Bundle recommended Qt plugins for self-contained packages. (Linux only)" OFF) +cmake_dependent_option(DESKTOP_APP_DISABLE_X11_INTEGRATION "Disable all code for X11 integration." OFF LINUX ON) +cmake_dependent_option(DESKTOP_APP_USE_ALLOCATION_TRACER "Use simple allocation tracer." OFF LINUX OFF) +cmake_dependent_option(DESKTOP_APP_USE_PACKAGED_LAZY "Bundle recommended Qt plugins for self-contained packages." OFF LINUX OFF) option(DESKTOP_APP_USE_PACKAGED_FONTS "Use preinstalled fonts instead of bundled patched ones." OFF) option(DESKTOP_APP_USE_PACKAGED_RLOTTIE "Find rlottie using CMake instead of bundled patched one." OFF) -option(DESKTOP_APP_DISABLE_SPELLCHECK "Disable spellcheck library." OFF) option(DESKTOP_APP_DISABLE_CRASH_REPORTS "Disable crash report generation." ${no_special_target}) option(DESKTOP_APP_DISABLE_AUTOUPDATE "Disable autoupdate." ${disable_autoupdate}) option(DESKTOP_APP_USE_HUNSPELL_ONLY "Disable system spellchecker and use bundled Hunspell only. (For debugging purposes)" OFF) -option(DESKTOP_APP_USE_ENCHANT "Use Enchant instead of bundled Hunspell. (Linux only)" OFF) -option(DESKTOP_APP_NO_PDB "Disable PDB file generation. (Windows only)" OFF) -option(DESKTOP_APP_WITH_LTO "Forcibly enable link-time optimization." OFF) +option(DESKTOP_APP_ASAN "Enable address sanitizer" OFF) +cmake_dependent_option(DESKTOP_APP_USE_ENCHANT "Use Enchant instead of bundled Hunspell." OFF LINUX OFF) +cmake_dependent_option(DESKTOP_APP_USE_CLD3 "Disable system text language recognition and use bundled cld3 only." OFF APPLE ON) +cmake_dependent_option(DESKTOP_APP_NO_PDB "Disable PDB file generation." OFF WIN32 OFF) +cmake_dependent_option(DESKTOP_APP_DISABLE_SCUDO "Disable scudo, use system malloc." OFF LINUX OFF) -if (DESKTOP_APP_USE_PACKAGED AND DEFINED CMAKE_OSX_ARCHITECTURES) - set(DESKTOP_APP_MAC_ARCH "${CMAKE_OSX_ARCHITECTURES}" CACHE STRING "Target macOS arch. (macOS only)") -else() - set(DESKTOP_APP_MAC_ARCH "x86_64;arm64" CACHE STRING "Target macOS arch. (macOS only)") +if (APPLE AND NOT DEFINED DESKTOP_APP_MAC_ARCH) + if (DEFINED CMAKE_OSX_ARCHITECTURES) + set(DESKTOP_APP_MAC_ARCH "${CMAKE_OSX_ARCHITECTURES}" CACHE STRING "Target macOS arch.") + else() + set(DESKTOP_APP_MAC_ARCH "x86_64;arm64" CACHE STRING "Target macOS arch.") + endif() endif() set(add_hunspell_library 0) -if ((WIN32 +if (WIN32 OR (LINUX AND NOT DESKTOP_APP_USE_ENCHANT) OR DESKTOP_APP_USE_HUNSPELL_ONLY) - AND NOT DESKTOP_APP_DISABLE_SPELLCHECK) set(add_hunspell_library 1) endif() +set(add_cld3_library 0) +if (LINUX OR DESKTOP_APP_USE_CLD3) + set(add_cld3_library 1) +endif() + set(build_macstore 0) set(build_winstore 0) # 32 or 64 bit set(build_win64 0) # normal or uwp @@ -82,6 +89,13 @@ else() endif() endif() +#if (DESKTOP_APP_ASAN AND WIN32) +# if (build_win64) +# get_filename_component(libs_loc "../Libraries64/asan" REALPATH) +# else() +# get_filename_component(libs_loc "../Libraries/asan" REALPATH) +# endif() +#elseif (build_win64) if (build_win64) get_filename_component(libs_loc "../Libraries64" REALPATH) else() diff --git a/win_directx_helper/CMakeLists.txt b/win_directx_helper/CMakeLists.txt index 889f8a9..a5e766f 100644 --- a/win_directx_helper/CMakeLists.txt +++ b/win_directx_helper/CMakeLists.txt @@ -19,3 +19,10 @@ target_link_libraries(win_directx_helper PUBLIC desktop-app::external_openssl ) + +if (NOT DESKTOP_APP_SPECIAL_TARGET STREQUAL "") + target_compile_definitions(win_directx_helper + PRIVATE + WIN_DIRECTX_HELPER_SPECIAL_TARGET=${DESKTOP_APP_SPECIAL_TARGET} + ) +endif() diff --git a/win_directx_helper/win_directx_helper.cpp b/win_directx_helper/win_directx_helper.cpp index 13a90f0..7550177 100644 --- a/win_directx_helper/win_directx_helper.cpp +++ b/win_directx_helper/win_directx_helper.cpp @@ -173,9 +173,9 @@ bool ResolveD3DCompiler() { if (FileSha256(path) == hash && ResolveD3DCompiler(path)) { return true; } -#elif defined DESKTOP_APP_SPECIAL_TARGET // DESKTOP_APP_D3DCOMPILER_HASH +#elif defined WIN_DIRECTX_HELPER_SPECIAL_TARGET // DESKTOP_APP_D3DCOMPILER_HASH #error "Special target build should have d3dcompiler hash." -#endif // !DESKTOP_APP_D3DCOMPILER_HASH && DESKTOP_APP_SPECIAL_TARGET +#endif // !DESKTOP_APP_D3DCOMPILER_HASH && WIN_DIRECTX_HELPER_SPECIAL_TARGET return ResolveD3DCompiler(L"d3dcompiler_47.dll"); }();