From ca0650f48a90905fb8e8c0916cea268901bf4741 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Wed, 25 Dec 2024 18:49:33 +0100 Subject: [PATCH] ifdef feature switches --- .github/workflows/build_test.yml | 4 ++++ CMakeLists.txt | 8 ++++++++ src/odr/html.cpp | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 2bc94e40..3208f2be 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -72,6 +72,8 @@ jobs: -DCMAKE_CXX_FLAGS="-Werror" -DCMAKE_INSTALL_PREFIX=install -DODR_TEST=ON + -DWITH_PDF2HTMLEX=ON + -DWITH_WVWARE=ON - name: cmake if: runner.os == 'Windows' @@ -82,6 +84,8 @@ jobs: -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install -DODR_TEST=ON + -DWITH_PDF2HTMLEX=OFF + -DWITH_WVWARE=OFF - name: build run: cmake --build build --config Release diff --git a/CMakeLists.txt b/CMakeLists.txt index e292e4db..c869e538 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -208,6 +208,10 @@ if (WITH_PDF2HTMLEX) pdf2htmlex::pdf2htmlex poppler::poppler ) + target_compile_definitions(odr + PRIVATE + ODR_WITH_PDF2HTMLEX + ) endif () if (WITH_WVWARE) find_package(wvware REQUIRED) @@ -220,6 +224,10 @@ if (WITH_WVWARE) PRIVATE wvware::wvware ) + target_compile_definitions(odr + PRIVATE + ODR_WITH_WVWARE + ) endif () if (EXISTS "${PROJECT_SOURCE_DIR}/.git") diff --git a/src/odr/html.cpp b/src/odr/html.cpp index e769f53c..c619d33a 100644 --- a/src/odr/html.cpp +++ b/src/odr/html.cpp @@ -108,6 +108,7 @@ Html html::translate(const DocumentFile &document_file, const std::string &output_path, const HtmlConfig &config) { auto document_file_impl = document_file.impl(); +#ifdef ODR_WITH_WVWARE if (auto wv_document_file = std::dynamic_pointer_cast( document_file_impl)) { @@ -115,6 +116,7 @@ Html html::translate(const DocumentFile &document_file, return internal::html::translate_wvware_oldms_file(*wv_document_file, output_path, config); } +#endif return translate(document_file.document(), output_path, config); } @@ -123,12 +125,14 @@ Html html::translate(const PdfFile &pdf_file, const std::string &output_path, const HtmlConfig &config) { auto pdf_file_impl = pdf_file.impl(); +#ifdef ODR_WITH_PDF2HTMLEX if (auto poppler_pdf_file = std::dynamic_pointer_cast(pdf_file_impl)) { fs::create_directories(output_path); return internal::html::translate_poppler_pdf_file(*poppler_pdf_file, output_path, config); } +#endif return internal::html::translate_pdf_file(pdf_file, output_path, config); }