diff --git a/CMakeLists.txt b/CMakeLists.txt index 1eb972a..73d38cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,7 @@ list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") # Project build options. option(WITH_TESTS "Compile tests." NO) +option(FALLBACK_BUNDLED "Fall back to bundled libs." YES) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -26,6 +27,14 @@ find_package(Gettext REQUIRED) find_package(Filesystem REQUIRED COMPONENTS Final Experimental) find_package(LibArchive 3.2 REQUIRED) find_package(fmt 4 REQUIRED CONFIG) +find_package(termcolor CONFIG) +if(NOT termcolor_FOUND) + if(FALLBACK_BUNDLED) + add_subdirectory(dist/termcolor) + else() + message(FATAL_ERROR "Termcolor was not found.") + endif() +endif() add_subdirectory(src) diff --git a/README.adoc b/README.adoc index c1b95b7..32c901e 100644 --- a/README.adoc +++ b/README.adoc @@ -14,6 +14,7 @@ :uri-libarchive: https://www.libarchive.org/ :uri-fmt: https://github.com/fmtlib/fmt :uri-asciidoc: http://asciidoc.org/ +uri-termcolor: https://termcolor.readthedocs.io/ *{project}* is a search tool for EPUB e-books. @@ -49,6 +50,7 @@ image::https://repology.org/badge/vertical-allrepos/epubgrep.svg[] * link:{uri-libarchive}[libarchive] (tested: 3.5 / 3.2) * link:{uri-fmt}[fmt] (tested: 7.0 / 4.0) * link:{uri-asciidoc}[AsciiDoc] (tested: 8.6 / 9.0) +* link:{uri-termcolor}[Termcolor] (tested: 2.0) * Optional ** Tests: link:{uri-catch}[Catch] (tested: 2.13 / 1.10) @@ -79,5 +81,6 @@ cmake --build . -- --jobs=$(nproc --ignore=1) * `-DCMAKE_BUILD_TYPE=Debug` for a debug build. * `-DWITH_TESTS=YES` if you want to compile the tests. * `-DXGETTEXT_CMD=String` The program to use instead of `xgettext`. +* `-DFALLBACK_BUNDLED=NO if you don't want to fall back on bundled libraries. include::{uri-base}/raw/branch/main/CONTRIBUTING.adoc[] diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 830a520..668fcf1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -21,7 +21,8 @@ target_link_libraries(${PROJECT_NAME}_lib Boost::program_options Boost::regex std::filesystem - fmt::fmt) + fmt::fmt + termcolor::termcolor) if(${CMAKE_VERSION} VERSION_LESS 3.17) target_link_libraries(${PROJECT_NAME}_lib