epubgrep/src/CMakeLists.txt

59 lines
1.6 KiB
CMake

include(GNUInstallDirs)
configure_file("version.hpp.in" "version.hpp" @ONLY)
configure_file("fs-compat.hpp.in" "fs-compat.hpp" @ONLY)
# The library is only here for the tests.
add_library(${PROJECT_NAME}_lib STATIC)
file(GLOB sources_src CONFIGURE_DEPENDS *.cpp)
file(GLOB headers_src CONFIGURE_DEPENDS *.hpp)
list(REMOVE_ITEM sources_src "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp")
target_sources(${PROJECT_NAME}_lib
PRIVATE "${sources_src}" "${headers_src}")
unset(sources_src)
unset(headers_src)
# Older CMake versions apparently need this, but I don't know in which version
# it changed. Theoretically Boost::dynamic_linking should take care of it.
add_compile_definitions("BOOST_LOG_DYN_LINK")
target_link_libraries(${PROJECT_NAME}_lib
PUBLIC
Boost::dynamic_linking
Boost::locale
Boost::log_setup
Boost::log
Boost::program_options
Boost::regex
std::filesystem
fmt::fmt
termcolor::termcolor
Threads::Threads
m
pugixml
nlohmann_json)
if(${CMAKE_VERSION} VERSION_LESS 3.17)
target_link_libraries(${PROJECT_NAME}_lib
PUBLIC ${LibArchive_LIBRARIES})
target_include_directories(${PROJECT_NAME}_lib
PUBLIC ${LibArchive_INCLUDE_DIRS})
else()
target_link_libraries(${PROJECT_NAME}_lib
PUBLIC LibArchive::LibArchive)
endif()
target_include_directories(${PROJECT_NAME}_lib
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>")
add_executable(${PROJECT_NAME} "main.cpp")
target_link_libraries(${PROJECT_NAME}
PRIVATE ${PROJECT_NAME}_lib)
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")