diff --git a/CMakeLists.txt b/CMakeLists.txt index e76fc42..57e8cc5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,6 +60,7 @@ list( "$<$:-DAPPIMAGE=1>" "$<$:-DAPPBUNDLE=1>" "$<$:-DOCR_SUPPORT=1>" + "$<$:-DMECAB_SUPPORT=1>" ) # Set Qt preprocessor settings @@ -134,7 +135,9 @@ endif() # Dependencies find_package(JsonC REQUIRED) find_package(libzip REQUIRED) -find_package(MeCab REQUIRED) +if(MECAB_SUPPORT) + find_package(MeCab REQUIRED) +endif() find_package(mpv REQUIRED) find_package(SQLite3 REQUIRED) if (UNIX AND NOT APPLE) diff --git a/option/CMakeLists.txt b/option/CMakeLists.txt index 03e7f21..96a7a54 100644 --- a/option/CMakeLists.txt +++ b/option/CMakeLists.txt @@ -6,5 +6,7 @@ if(UNIX AND NOT APPLE) option(APPIMAGE "Toggle when building for AppImages" OFF) endif() option(MAC_CROSSCOMPILE_X86 "Enables ARM machines to cross compile for x86" OFF) +option(RELEASE_BUILD "Toggle to build with release settings" OFF) + option(OCR_SUPPORT "Support for OCR through MangaOCR" OFF) -option(RELEASE_BUILD "Toggle to build with release settings" OFF) \ No newline at end of file +option(MECAB_SUPPORT "Support for deconjugation with MeCab" ON) diff --git a/src/dict/CMakeLists.txt b/src/dict/CMakeLists.txt index c39555d..998076e 100644 --- a/src/dict/CMakeLists.txt +++ b/src/dict/CMakeLists.txt @@ -27,20 +27,26 @@ target_link_libraries( PUBLIC querygenerator ) -add_library( - mecabquerygenerator STATIC - mecabquerygenerator.cpp - mecabquerygenerator.h -) -target_compile_features(mecabquerygenerator PRIVATE cxx_std_17) -target_compile_options(mecabquerygenerator PRIVATE ${MEMENTO_COMPILER_FLAGS}) -target_include_directories(mecabquerygenerator PRIVATE ${MEMENTO_INCLUDE_DIRS}) -target_link_libraries( - mecabquerygenerator - PRIVATE utils - PUBLIC MeCab::MeCab - PUBLIC querygenerator -) +if(MECAB_SUPPORT) + add_library( + mecabquerygenerator STATIC + mecabquerygenerator.cpp + mecabquerygenerator.h + ) + target_compile_features(mecabquerygenerator PRIVATE cxx_std_17) + target_compile_options( + mecabquerygenerator PRIVATE ${MEMENTO_COMPILER_FLAGS} + ) + target_include_directories( + mecabquerygenerator PRIVATE ${MEMENTO_INCLUDE_DIRS} + ) + target_link_libraries( + mecabquerygenerator + PRIVATE utils + PUBLIC MeCab::MeCab + PUBLIC querygenerator + ) +endif() add_library( yomidbbuilder STATIC @@ -76,13 +82,20 @@ add_library( target_compile_features(dictionary_db PUBLIC cxx_std_17) target_compile_options(dictionary_db PRIVATE ${MEMENTO_COMPILER_FLAGS}) target_include_directories(dictionary_db PRIVATE ${MEMENTO_INCLUDE_DIRS}) +set( + DICTIONARY_DB_GENERATOR_LIBS + exactquerygenerator +) +if(MECAB_SUPPORT) + list(APPEND DICTIONARY_DB_GENERATOR_LIBS mecabquerygenerator) +endif() target_link_libraries( dictionary_db - PRIVATE exactquerygenerator - PRIVATE mecabquerygenerator + PRIVATE ${DICTIONARY_DB_GENERATOR_LIBS} PRIVATE Qt6::Widgets PRIVATE querygenerator PRIVATE SQLite::SQLite3 PRIVATE yomidbbuilder PUBLIC Qt6::Core ) +unset(DICTIONARY_DB_GENERATOR_LIBS) diff --git a/src/dict/dictionary.cpp b/src/dict/dictionary.cpp index 343600f..2b6229a 100644 --- a/src/dict/dictionary.cpp +++ b/src/dict/dictionary.cpp @@ -29,7 +29,10 @@ #include "databasemanager.h" #include "exactquerygenerator.h" + +#ifdef MECAB_SUPPORT #include "mecabquerygenerator.h" +#endif // MECAB_SUPPORT #include "util/constants.h" #include "util/globalmediator.h" @@ -72,6 +75,8 @@ void Dictionary::initDictionaryOrder() void Dictionary::initQueryGenerators() { m_generators.emplace_back(std::make_unique()); + +#ifdef MECAB_SUPPORT m_generators.emplace_back(std::make_unique()); if (!m_generators.back()->valid()) { @@ -100,6 +105,7 @@ void Dictionary::initQueryGenerators() #endif ); } +#endif // MECAB_SUPPORT } Dictionary::~Dictionary()