cmake: updates

* add USE_SYSTEM_FMT & USE_SYSTEM_TOML
* switch back to libeb
This commit is contained in:
shenleban tongying 2023-05-31 23:39:29 -04:00
parent 4b8c87a30d
commit 0c75d4f399
No known key found for this signature in database
6 changed files with 38 additions and 20 deletions

View file

@ -53,7 +53,7 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
submodules: true submodules: false
- name: Run build-wrapper - name: Run build-wrapper
run: | run: |
@ -106,7 +106,7 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
submodules: true submodules: false
- name: install dependencies - name: install dependencies
run: | run: |
brew install pcre2 harfbuzz freetype brew install pcre2 harfbuzz freetype

View file

@ -8,6 +8,9 @@ option(WITH_EPWING_SUPPORT "Enable epwing support" ON)
option(WITH_XAPIAN "enable Xapian support" ON) option(WITH_XAPIAN "enable Xapian support" ON)
option(WITH_ZIM "enable zim 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) include(FeatureSummary)
@ -79,11 +82,14 @@ target_sources(${GOLDENDICT} PRIVATE
resources.qrc resources.qrc
src/scripts/scripts.qrc src/scripts/scripts.qrc
src/stylesheets/css.qrc src/stylesheets/css.qrc
thirdparty/fmt/format.cc
${ALL_SOURCE_FILES} ${ALL_SOURCE_FILES}
${MACOS_SOURCE_FILES} ${MACOS_SOURCE_FILES}
${QSINGLEAPP_SOURCE_FILES}) ${QSINGLEAPP_SOURCE_FILES})
if (NOT USE_SYSTEM_FMT)
target_sources(${GOLDENDICT} PRIVATE thirdparty/fmt/format.cc)
endif ()
### Common parts amount all platforms ### Common parts amount all platforms
# Note: used as c++ string thus need surrounding " " # 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/dict
${PROJECT_SOURCE_DIR}/src/ui ${PROJECT_SOURCE_DIR}/src/ui
${PROJECT_SOURCE_DIR}/thirdparty/tomlplusplus ${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 #### Compile definitions
target_compile_definitions(${GOLDENDICT} PUBLIC target_compile_definitions(${GOLDENDICT} PUBLIC
@ -134,11 +147,9 @@ if (WITH_XAPIAN)
target_compile_definitions(${GOLDENDICT} PUBLIC USE_XAPIAN) target_compile_definitions(${GOLDENDICT} PUBLIC USE_XAPIAN)
endif () endif ()
if(WITH_ZIM) if (WITH_ZIM)
target_compile_definitions(${GOLDENDICT} PUBLIC target_compile_definitions(${GOLDENDICT} PUBLIC MAKE_ZIM_SUPPORT)
MAKE_ZIM_SUPPORT endif ()
)
endif()
#### libraries linking && includes for Win or Unix #### libraries linking && includes for Win or Unix

View file

@ -44,10 +44,9 @@ pkg_check_modules(PKGCONFIG_DEPS IMPORTED_TARGET
) )
target_link_libraries(${GOLDENDICT} PRIVATE target_link_libraries(${GOLDENDICT} PRIVATE
# pkg-config packages need manually link
PkgConfig::PKGCONFIG_DEPS PkgConfig::PKGCONFIG_DEPS
BZip2::BZip2 BZip2::BZip2
ZLIB::ZLIB #hidden requirement of dsl_details.cc and more? ZLIB::ZLIB
Iconv::Iconv Iconv::Iconv
) )
@ -67,13 +66,21 @@ if (WITH_XAPIAN)
endif () endif ()
if (WITH_EPWING_SUPPORT) if (WITH_EPWING_SUPPORT)
add_subdirectory(thirdparty/eb EXCLUDE_FROM_ALL) find_library(EB_LIBRARY eb REQUIRED)
target_link_libraries(${GOLDENDICT} PRIVATE eb) target_link_libraries(${GOLDENDICT} PRIVATE ${EB_LIBRARY})
endif () endif ()
if(WITH_ZIM) if (WITH_ZIM)
pkg_check_modules(ZIM REQUIRED IMPORTED_TARGET pkg_check_modules(ZIM REQUIRED IMPORTED_TARGET libzim)
libzim
)
target_link_libraries(${GOLDENDICT} PRIVATE PkgConfig::ZIM) 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 ()

View file

@ -412,7 +412,7 @@ HEADERS += \
src/wordfinder.hh \ src/wordfinder.hh \
src/wordlist.hh \ src/wordlist.hh \
src/zipfile.hh \ src/zipfile.hh \
thirdparty/tomlplusplus/toml.hpp thirdparty/tomlplusplus/toml++/toml.h
FORMS += $$files(src/ui/*.ui) FORMS += $$files(src/ui/*.ui)

View file

@ -1,5 +1,5 @@
#include "metadata.hh" #include "metadata.hh"
#include "toml.hpp" #include "toml++/toml.h"
#include <QDebug> #include <QDebug>
#include <QFile> #include <QFile>