NMEA: enhancement and fix of RTE
[marnav.git] / CMakeLists.txt
blobab7b8655ee80da94748fc3711b1f1581f5edb950
1 cmake_minimum_required(VERSION 3.11)
3 list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
4 list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
5 set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
7 project(marnav
8         VERSION 0.10.0
9         LANGUAGES CXX C
10         DESCRIPTION "Library for maritime navigation."
11         )
13 ### compiler check
14 if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU|Clang")
15         message(STATUS "Compiler: ${CMAKE_CXX_COMPILER_ID}")
16 else()
17         message(FATAL_ERROR "Unsupported compiler detected: ${CMAKE_CXX_COMPILER_ID}")
18 endif()
20 # compilation traits
21 set(CMAKE_CXX_STANDARD 11)
22 set(CMAKE_CXX_STANDARD_REQUIRED ON)
23 set(CMAKE_CXX_EXTENSIONS OFF)
24 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
26 ### options
27 option(ENABLE_STATIC "Enable static library" ON)
28 option(ENABLE_PROFILING "Enable Profiling" OFF)
29 option(ENABLE_BENCHMARK "Enable Benchmark" OFF)
30 option(ENABLE_SANITIZER "Enable Sanitizing (address, undefined)" OFF)
31 option(ENABLE_IO "Enable IO support" ON)
32 option(ENABLE_EXAMPLES "Enable Examples" ON)
33 option(ENABLE_TESTS "Enable Tests" ON)
34 option(ENABLE_TOOLS "Enable Tools" ON)
36 if(${ENABLE_STATIC})
37         set(BUILD_SHARED_LIBS FALSE)
38 else()
39         set(BUILD_SHARED_LIBS TRUE)
40 endif()
42 # misc
43 include(RepoInformation)
44 include(Documentation)
45 include(CppCheck)
46 include(ExternalProject)
48 if(ENABLE_TOOLS)
49         include(ExternCxxopts)
50         include(ExternFmt)
51 endif()
53 ### common
54 message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}")
55 file(MAKE_DIRECTORY
56         ${CMAKE_CURRENT_BINARY_DIR}/doc
57         ${CMAKE_CURRENT_BINARY_DIR}/doc/coverage
58         ${CMAKE_CURRENT_BINARY_DIR}/local/include
59         )
61 ### library
62 add_subdirectory(src)
64 ### examples
65 message(STATUS "Build Examples: ${ENABLE_EXAMPLES}")
66 if(ENABLE_EXAMPLES)
67         add_subdirectory(examples)
68 endif()
70 ### ctags / cscope
71 include(CTags)
72 if(CTAGS_PATH AND CSCOPE_PATH)
73         setup_ctags_target("${CMAKE_CURRENT_SOURCE_DIR}/src/*.?pp;${CMAKE_CURRENT_SOURCE_DIR}/include/*.?pp")
74 endif()
76 ### testing
77 message(STATUS "Build Tests: ${ENABLE_TESTS}")
78 if(ENABLE_TESTS)
79         enable_testing()
80         include(ExternGoogletest)
81         include(ExternBenchmark)
82         add_subdirectory(test)
83 endif()
85 ### coverage
86 if(CMAKE_BUILD_TYPE MATCHES Coverage)
87         include(CodeCoverage)
88         setup_target_for_coverage(coverage
89                 testrunner
90                 doc/coverage
91                 )
92 endif()
94 include(Packaging)