WhisperCom/CMakeLists.txt

97 lines
2.6 KiB
CMake
Raw Normal View History

cmake_minimum_required (VERSION 3.1 FATAL_ERROR)
project (whisper-com VERSION 0.0.1 LANGUAGES CXX C)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
include(compdb)
include(doxygen)
build_docs(PROCESS_DOXYFILE DOXYFILE_PATH "docs/Doxyfile.in" )
IF(NOT TARGET loguru)
find_package (Threads REQUIRED)
add_library(loguru STATIC libs/loguru/loguru.cpp libs/loguru/loguru.hpp)
target_include_directories(loguru PUBLIC libs/loguru/)
target_compile_options(loguru PUBLIC -DLOGURU_WITH_STREAMS=1)
target_link_libraries(loguru PUBLIC dl Threads::Threads)
set_property(TARGET loguru PROPERTY POSITION_INDEPENDENT_CODE 1)
ENDIF()
2021-08-26 21:43:38 +02:00
IF(NOT TARGET nlohmann_json::nlohmann_json)
set(JSON_BuildTests OFF CACHE INTERNAL "")
add_subdirectory(libs/json EXCLUDE_FROM_ALL)
ENDIF()
set(WHISPER_SOURCES
include/Whisper/Data/Classification.hpp
src/Whisper/Data/Classification.cpp
2021-08-26 21:42:58 +02:00
include/Whisper/Tree/Node.hpp
)
2021-08-26 21:43:38 +02:00
set(WHISPER_REQUIRED_LIBRARIES loguru nlohmann_json::nlohmann_json )
add_library(objlib OBJECT ${WHISPER_SOURCES})
set_property(TARGET objlib PROPERTY POSITION_INDEPENDENT_CODE 1)
target_include_directories(objlib
PUBLIC
include
PRIVATE
src
)
target_link_libraries(objlib PUBLIC ${WHISPER_REQUIRED_LIBRARIES})
add_library(whisper SHARED $<TARGET_OBJECTS:objlib>)
target_include_directories(whisper
PUBLIC
include
PRIVATE
src
)
target_link_libraries(whisper PUBLIC ${WHISPER_REQUIRED_LIBRARIES})
add_library(whisper-static STATIC $<TARGET_OBJECTS:objlib>)
target_include_directories(whisper-static
PUBLIC
include
PRIVATE
src
)
target_link_libraries(whisper-static PUBLIC ${WHISPER_REQUIRED_LIBRARIES})
#
# Everything test related
#
option(WHISPER_TESTS "ENABLE/DISABLE all tests for whisper-com" ON)
IF(${WHISPER_TESTS})
message(STATUS "whisper-com tests enabled")
IF(NOT TARGET Catch2)
add_subdirectory(libs/Catch2)
include(libs/Catch2/contrib/Catch.cmake)
ENDIF()
include(CTest)
ELSE()
message(STATUS "whisper-com tests disabled")
ENDIF()
IF(${WHISPER_TESTS})
#
# all tests
#
add_executable(test_classification tests/test_classification.cpp)
target_link_libraries(test_classification PUBLIC Catch2::Catch2 whisper-static)
catch_discover_tests(test_classification)
#
# add_executable(test_message tests/test_message.cpp)
# target_link_libraries(test_message PUBLIC Catch2::Catch2 bc-ng loguru)
# target_compile_definitions(test_message PRIVATE -DNDEBUG=1 -DNLOGGING_VERBOSE=1)
# catch_discover_tests(test_message)
ENDIF()