Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 1 | project(velia LANGUAGES CXX) |
Tomáš Pecka | a06d74d | 2020-06-14 18:18:13 +0200 | [diff] [blame] | 2 | cmake_minimum_required(VERSION 3.15) |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 3 | |
| 4 | # Build options |
| 5 | set(CMAKE_CXX_STANDARD 17) |
| 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 7 | |
| 8 | set(CMAKE_CXX_FLAGS_DEBUG "-Werror ${CMAKE_CXX_FLAGS_DEBUG}") |
| 9 | set(CMAKE_CXX_FLAGS "-Wall -Wextra -pedantic -Woverloaded-virtual ${CMAKE_CXX_FLAGS}") |
| 10 | if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") |
| 11 | set(CMAKE_CXX_FLAGS "-Wsuggest-override ${CMAKE_CXX_FLAGS}") |
| 12 | endif() |
| 13 | |
| 14 | add_custom_target(velia-version-cmake-ide |
| 15 | cmake/ProjectGitVersion.cmake |
| 16 | cmake/ProjectGitVersionRunner.cmake |
| 17 | ) |
| 18 | include(cmake/ProjectGitVersion.cmake) |
| 19 | prepare_git_version(VELIA_VERSION "0.0") |
| 20 | |
| 21 | find_package(Doxygen) |
| 22 | option(WITH_DOCS "Create and install internal documentation (needs Doxygen)" ${DOXYGEN_FOUND}) |
| 23 | |
Tomáš Pecka | 74b885f | 2020-06-06 20:02:41 +0200 | [diff] [blame^] | 24 | find_package(Boost REQUIRED) |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 25 | find_package(spdlog REQUIRED) |
| 26 | |
| 27 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/) |
| 28 | |
| 29 | # Targets |
Tomáš Pecka | bd82886 | 2020-06-15 15:53:35 +0200 | [diff] [blame] | 30 | add_library(velia-utils STATIC |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 31 | src/utils/log-init.h |
| 32 | src/utils/log-init.cpp |
| 33 | ) |
Tomáš Pecka | bd82886 | 2020-06-15 15:53:35 +0200 | [diff] [blame] | 34 | target_link_libraries(velia-utils PUBLIC spdlog::spdlog) |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 35 | |
Tomáš Pecka | 74b885f | 2020-06-06 20:02:41 +0200 | [diff] [blame^] | 36 | add_library(velia-state-manager STATIC |
| 37 | src/inputs/AbstractInput.cpp |
| 38 | src/manager/AbstractManager.cpp |
| 39 | src/manager/StateManager.cpp |
| 40 | src/State.cpp |
| 41 | ) |
| 42 | target_link_libraries(velia-state-manager PUBLIC velia-utils Boost::boost) |
| 43 | |
Tomáš Pecka | bd82886 | 2020-06-15 15:53:35 +0200 | [diff] [blame] | 44 | add_executable(veliad |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 45 | src/main.cpp |
| 46 | ) |
| 47 | |
Tomáš Pecka | bd82886 | 2020-06-15 15:53:35 +0200 | [diff] [blame] | 48 | target_link_libraries(veliad PUBLIC velia-utils) |
| 49 | add_dependencies(veliad target-VELIA_VERSION) |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 50 | |
| 51 | # Testing |
Tomáš Pecka | a06d74d | 2020-06-14 18:18:13 +0200 | [diff] [blame] | 52 | include(CTest) |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 53 | if(BUILD_TESTING) |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 54 | find_package(trompeloeil 33 REQUIRED) |
| 55 | find_package(doctest 2.3.1 REQUIRED) |
| 56 | |
| 57 | add_library(DoctestIntegration STATIC |
| 58 | tests/doctest_integration.cpp |
| 59 | tests/trompeloeil_doctest.h |
| 60 | ) |
| 61 | target_include_directories(DoctestIntegration PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/tests/ ${CMAKE_CURRENT_SOURCE_DIR}/src/) |
| 62 | target_link_libraries(DoctestIntegration doctest::doctest trompeloeil spdlog::spdlog) |
| 63 | target_compile_definitions(DoctestIntegration PUBLIC DOCTEST_CONFIG_SUPER_FAST_ASSERTS) |
| 64 | |
| 65 | function(velia_test name) |
| 66 | add_executable(test_${name} tests/${name}.cpp) |
| 67 | target_link_libraries(test_${name} DoctestIntegration ${ARGN}) |
| 68 | target_include_directories(test_${name} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) |
| 69 | |
| 70 | if(NOT CMAKE_CROSSCOMPILING) |
| 71 | add_test(test_${name} test_${name}) |
| 72 | endif() |
| 73 | |
| 74 | endfunction() |
Tomáš Pecka | 74b885f | 2020-06-06 20:02:41 +0200 | [diff] [blame^] | 75 | velia_test(state-manager velia-state-manager) |
Tomáš Pecka | 5123e00 | 2020-06-05 15:29:21 +0200 | [diff] [blame] | 76 | endif() |
| 77 | |
| 78 | if(WITH_DOCS) |
| 79 | set(doxyfile_in ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in) |
| 80 | set(doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) |
| 81 | configure_file(${doxyfile_in} ${doxyfile} @ONLY) |
| 82 | add_custom_target(doc |
| 83 | COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile} |
| 84 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} |
| 85 | COMMENT "Generating API documentation with Doxygen" |
| 86 | VERBATIM |
| 87 | SOURCES ${doxyfile_in} |
| 88 | ) |
Tomáš Pecka | a06d74d | 2020-06-14 18:18:13 +0200 | [diff] [blame] | 89 | endif() |