From 0c75d4f39900e8fb0ff7fd451ad0e666ca11f522 Mon Sep 17 00:00:00 2001 From: shenleban tongying Date: Wed, 31 May 2023 23:39:29 -0400 Subject: [PATCH] cmake: updates * add USE_SYSTEM_FMT & USE_SYSTEM_TOML * switch back to libeb --- .github/workflows/cmake build check.yml | 4 +-- CMakeLists.txt | 25 +++++++++++++------ CMake_Unix.cmake | 25 ++++++++++++------- goldendict.pro | 2 +- src/metadata.cc | 2 +- .../tomlplusplus/{toml.hpp => toml++/toml.h} | 0 6 files changed, 38 insertions(+), 20 deletions(-) rename thirdparty/tomlplusplus/{toml.hpp => toml++/toml.h} (100%) diff --git a/.github/workflows/cmake build check.yml b/.github/workflows/cmake build check.yml index 5b6ff8d9..8b3dc2d1 100644 --- a/.github/workflows/cmake build check.yml +++ b/.github/workflows/cmake build check.yml @@ -53,7 +53,7 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - submodules: true + submodules: false - name: Run build-wrapper run: | @@ -106,7 +106,7 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - submodules: true + submodules: false - name: install dependencies run: | brew install pcre2 harfbuzz freetype diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f5f4061..92e6fa14 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,9 @@ option(WITH_EPWING_SUPPORT "Enable epwing support" ON) option(WITH_XAPIAN "enable Xapian support" ON) option(WITH_ZIM "enable zim support" ON) +# options for linux packaging +option(USE_SYSTEM_FMT "use system fmt instead of bundled one" OFF) +option(USE_SYSTEM_TOML "use system toml++ instead of bundled one" OFF) include(FeatureSummary) @@ -79,11 +82,14 @@ target_sources(${GOLDENDICT} PRIVATE resources.qrc src/scripts/scripts.qrc src/stylesheets/css.qrc - thirdparty/fmt/format.cc ${ALL_SOURCE_FILES} ${MACOS_SOURCE_FILES} ${QSINGLEAPP_SOURCE_FILES}) +if (NOT USE_SYSTEM_FMT) + target_sources(${GOLDENDICT} PRIVATE thirdparty/fmt/format.cc) +endif () + ### Common parts amount all platforms # Note: used as c++ string thus need surrounding " " @@ -108,9 +114,16 @@ target_include_directories(${GOLDENDICT} PRIVATE ${PROJECT_SOURCE_DIR}/src/dict ${PROJECT_SOURCE_DIR}/src/ui ${PROJECT_SOURCE_DIR}/thirdparty/tomlplusplus - ${PROJECT_SOURCE_DIR}/thirdparty/fmt/include ) +if (NOT USE_SYSTEM_TOML) + target_include_directories(${GOLDENDICT} PRIVATE ${PROJECT_SOURCE_DIR}/thirdparty/tomlplusplus) +endif () + +if (NOT USE_SYSTEM_FMT) + target_include_directories(${GOLDENDICT} PRIVATE ${PROJECT_SOURCE_DIR}/thirdparty/fmt/include) +endif () + #### Compile definitions target_compile_definitions(${GOLDENDICT} PUBLIC @@ -134,11 +147,9 @@ if (WITH_XAPIAN) target_compile_definitions(${GOLDENDICT} PUBLIC USE_XAPIAN) endif () -if(WITH_ZIM) - target_compile_definitions(${GOLDENDICT} PUBLIC - MAKE_ZIM_SUPPORT - ) -endif() +if (WITH_ZIM) + target_compile_definitions(${GOLDENDICT} PUBLIC MAKE_ZIM_SUPPORT) +endif () #### libraries linking && includes for Win or Unix diff --git a/CMake_Unix.cmake b/CMake_Unix.cmake index a04c99a1..358b710a 100644 --- a/CMake_Unix.cmake +++ b/CMake_Unix.cmake @@ -44,10 +44,9 @@ pkg_check_modules(PKGCONFIG_DEPS IMPORTED_TARGET ) target_link_libraries(${GOLDENDICT} PRIVATE - # pkg-config packages need manually link PkgConfig::PKGCONFIG_DEPS BZip2::BZip2 - ZLIB::ZLIB #hidden requirement of dsl_details.cc and more? + ZLIB::ZLIB Iconv::Iconv ) @@ -67,13 +66,21 @@ if (WITH_XAPIAN) endif () if (WITH_EPWING_SUPPORT) - add_subdirectory(thirdparty/eb EXCLUDE_FROM_ALL) - target_link_libraries(${GOLDENDICT} PRIVATE eb) + find_library(EB_LIBRARY eb REQUIRED) + target_link_libraries(${GOLDENDICT} PRIVATE ${EB_LIBRARY}) endif () -if(WITH_ZIM) - pkg_check_modules(ZIM REQUIRED IMPORTED_TARGET - libzim - ) +if (WITH_ZIM) + pkg_check_modules(ZIM REQUIRED IMPORTED_TARGET libzim) target_link_libraries(${GOLDENDICT} PRIVATE PkgConfig::ZIM) -endif() +endif () + +if (USE_SYSTEM_FMT) + find_package(fmt) + target_link_libraries(${GOLDENDICT} PRIVATE fmt::fmt) +endif () + +if (USE_SYSTEM_TOML) + find_package(tomlplusplus) + target_link_libraries(${GOLDENDICT} PRIVATE tomlplusplus::tomlplusplus) +endif () \ No newline at end of file diff --git a/goldendict.pro b/goldendict.pro index d856cf68..aa917ef0 100644 --- a/goldendict.pro +++ b/goldendict.pro @@ -412,7 +412,7 @@ HEADERS += \ src/wordfinder.hh \ src/wordlist.hh \ src/zipfile.hh \ - thirdparty/tomlplusplus/toml.hpp + thirdparty/tomlplusplus/toml++/toml.h FORMS += $$files(src/ui/*.ui) diff --git a/src/metadata.cc b/src/metadata.cc index 3d8a6956..83aacff5 100644 --- a/src/metadata.cc +++ b/src/metadata.cc @@ -1,5 +1,5 @@ #include "metadata.hh" -#include "toml.hpp" +#include "toml++/toml.h" #include #include diff --git a/thirdparty/tomlplusplus/toml.hpp b/thirdparty/tomlplusplus/toml++/toml.h similarity index 100% rename from thirdparty/tomlplusplus/toml.hpp rename to thirdparty/tomlplusplus/toml++/toml.h