blob: 74f2ca2b342124d558cd004fd0e0d92a42d73c4d [file] [log] [blame]
Tomáš Pecka5123e002020-06-05 15:29:21 +02001project(velia LANGUAGES CXX)
Tomáš Peckaa06d74d2020-06-14 18:18:13 +02002cmake_minimum_required(VERSION 3.15)
Tomáš Pecka5123e002020-06-05 15:29:21 +02003
4# Build options
5set(CMAKE_CXX_STANDARD 17)
6set(CMAKE_CXX_STANDARD_REQUIRED ON)
7
8set(CMAKE_CXX_FLAGS_DEBUG "-Werror ${CMAKE_CXX_FLAGS_DEBUG}")
9set(CMAKE_CXX_FLAGS "-Wall -Wextra -pedantic -Woverloaded-virtual ${CMAKE_CXX_FLAGS}")
10if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
11 set(CMAKE_CXX_FLAGS "-Wsuggest-override ${CMAKE_CXX_FLAGS}")
12endif()
13
14add_custom_target(velia-version-cmake-ide
15 cmake/ProjectGitVersion.cmake
16 cmake/ProjectGitVersionRunner.cmake
17 )
18include(cmake/ProjectGitVersion.cmake)
19prepare_git_version(VELIA_VERSION "0.0")
20
21find_package(Doxygen)
22option(WITH_DOCS "Create and install internal documentation (needs Doxygen)" ${DOXYGEN_FOUND})
23
Tomáš Pecka74b885f2020-06-06 20:02:41 +020024find_package(Boost REQUIRED)
Tomáš Pecka5123e002020-06-05 15:29:21 +020025find_package(spdlog REQUIRED)
26
27include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/)
28
29# Targets
Tomáš Peckabd828862020-06-15 15:53:35 +020030add_library(velia-utils STATIC
Tomáš Pecka5123e002020-06-05 15:29:21 +020031 src/utils/log-init.h
32 src/utils/log-init.cpp
33 )
Tomáš Peckabd828862020-06-15 15:53:35 +020034target_link_libraries(velia-utils PUBLIC spdlog::spdlog)
Tomáš Pecka5123e002020-06-05 15:29:21 +020035
Tomáš Pecka74b885f2020-06-06 20:02:41 +020036add_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 )
42target_link_libraries(velia-state-manager PUBLIC velia-utils Boost::boost)
43
Tomáš Peckabd828862020-06-15 15:53:35 +020044add_executable(veliad
Tomáš Pecka5123e002020-06-05 15:29:21 +020045 src/main.cpp
46 )
47
Tomáš Peckabd828862020-06-15 15:53:35 +020048target_link_libraries(veliad PUBLIC velia-utils)
49add_dependencies(veliad target-VELIA_VERSION)
Tomáš Pecka5123e002020-06-05 15:29:21 +020050
51# Testing
Tomáš Peckaa06d74d2020-06-14 18:18:13 +020052include(CTest)
Tomáš Pecka5123e002020-06-05 15:29:21 +020053if(BUILD_TESTING)
Tomáš Pecka5123e002020-06-05 15:29:21 +020054 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áš Pecka74b885f2020-06-06 20:02:41 +020075 velia_test(state-manager velia-state-manager)
Tomáš Pecka5123e002020-06-05 15:29:21 +020076endif()
77
78if(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áš Peckaa06d74d2020-06-14 18:18:13 +020089endif()