NMEA: add install step to fmt, usd by nmeatool
[marnav.git] / CMakeLists.txt
blob4568c7fedbb6f4d7d7145dd367a191f5fed423d7
1 cmake_minimum_required(VERSION 3.19)
3 project(marnav
4         VERSION 0.13.0
5         LANGUAGES CXX C
6         DESCRIPTION "Library for maritime navigation."
7         )
9 list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
10 list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
11 set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
13 # compilation traits
14 set(CMAKE_CXX_STANDARD 17)
15 set(CMAKE_CXX_STANDARD_REQUIRED ON)
16 set(CMAKE_CXX_EXTENSIONS OFF)
17 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
19 ### options
20 option(ENABLE_STATIC "Enable static library" ON)
21 option(ENABLE_PROFILING "Enable Profiling" OFF)
22 option(ENABLE_BENCHMARK "Enable Benchmark" OFF)
23 option(ENABLE_SANITIZER "Enable Sanitizing (address, undefined)" OFF)
24 option(ENABLE_EXAMPLES "Enable Examples" ON)
25 option(ENABLE_TESTS "Enable Tests" ON)
26 option(ENABLE_TESTS_BENCHMARK "Enable Test Benchmarks" ON)
27 option(ENABLE_TOOLS "Enable Tools" ON)
28 option(ENABLE_IWYU "Enable include-what-you-use" OFF)
30 if(NOT DEFINED BUILD_SHARED_LIBS)
31         if(ENABLE_STATIC)
32                 set(BUILD_SHARED_LIBS FALSE)
33         else()
34                 set(BUILD_SHARED_LIBS TRUE)
35         endif()
36 endif()
38 if(ENABLE_TESTS)
39         set(BUILD_TESTING TRUE)
40         enable_testing()
41 else()
42         set(BUILD_TESTING FALSE)
43 endif()
45 # misc
46 include(RepoInformation)
47 include(Documentation)
48 include(CppCheck)
49 include(FetchContent)
51 if(ENABLE_TOOLS)
52         set(CXXOPTS_BUILD_EXAMPLES FALSE CACHE BOOL "" FORCE)
53         set(CXXOPTS_BUILD_TESTS FALSE CACHE BOOL "" FORCE)
54         FetchContent_Declare(cxxopts
55                 URL "${CMAKE_CURRENT_SOURCE_DIR}/extern/cxxopts"
56                 )
57         FetchContent_MakeAvailable(cxxopts)
59         set(FMT_INSTALL TRUE CACHE BOOL "" FORCE)
60         FetchContent_Declare(fmt
61                 URL "${CMAKE_CURRENT_SOURCE_DIR}/extern/fmt"
62                 )
63         FetchContent_MakeAvailable(fmt)
64 endif()
66 ### common
67 message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}")
68 file(MAKE_DIRECTORY
69         ${CMAKE_CURRENT_BINARY_DIR}/doc
70         ${CMAKE_CURRENT_BINARY_DIR}/doc/coverage
71         ${CMAKE_CURRENT_BINARY_DIR}/local/include
72         )
74 ### library and tools
75 add_subdirectory(src)
77 ### examples
78 message(STATUS "Build Examples       : ${ENABLE_EXAMPLES}")
79 if(ENABLE_EXAMPLES)
80         add_subdirectory(examples)
81 endif()
83 ### testing
84 message(STATUS "Build Tests          : ${ENABLE_TESTS}")
85 message(STATUS "Build Tests Benchmark: ${ENABLE_TESTS_BENCHMARK}")
86 if(ENABLE_TESTS)
87         FetchContent_Declare(googletest
88                 URL "${CMAKE_CURRENT_SOURCE_DIR}/extern/googletest-1.11.0"
89                 )
90         FetchContent_MakeAvailable(googletest)
92         if(ENABLE_TESTS_BENCHMARK)
93                 set(BENCHMARK_ENABLE_TESTING FALSE CACHE BOOL "" FORCE)
94                 set(BENCHMARK_ENABLE_GTEST_TESTS FALSE CACHE BOOL "" FORCE)
95                 FetchContent_Declare(benchmark
96                         URL "${CMAKE_CURRENT_SOURCE_DIR}/extern/benchmark-1.6.0"
97                         )
98                 FetchContent_MakeAvailable(benchmark)
99         endif()
101         add_subdirectory(test)
102 endif()
104 ### coverage
105 if(CMAKE_BUILD_TYPE MATCHES Coverage)
106         include(CodeCoverage)
107         setup_target_for_coverage(coverage
108                 testrunner
109                 doc/coverage
110                 )
111 endif()
113 set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
114 set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
115 set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
116 set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
117 set(CPACK_PACKAGE_NAME "marnav")
118 set(CPACK_PACKAGE_VENDOR "Mario Konrad")
119 set(CPACK_PACKAGE_CONTACT "Mario Konrad <mario.konrad@gmx.net>")
120 set(CPACK_PACAKGE_DESCRIPTION "Library for maritime navigation.")
121 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Library")
122 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
123 set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
124 set(CPACK_MONOLITHIC_INSTALL 1)
125 #set(CPACK_PACKAGE_EXECUTABLES "??" "??")
126 set(CPACK_STRIP_FILES true)
128 # package: debian
129 set(CPACK_DEBIAN_PACKAGE_NAME ${CPACK_DEBIAN_PACKAGE_NAME})
130 set(CPACK_DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_CONTACT})
131 set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACAKGE_DESCRIPTION})
132 set(CPACK_DEBIAN_PACKAGE_DEPENDS "libstdc++6 (>= 7.0)")
133 set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.3)")
134 set(CPACK_DEBIAN_PACKAGE_SECTION "misc")
135 if (CMAKE_SIZEOF_VOID_P MATCHES "8")
136         set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
137 else()
138         set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "i386")
139 endif()
141 include(CPack)