Version 0.12.0
[marnav.git] / CMakeLists.txt
blob373e44ccd1e1b525f457953280f89476f14f6d08
1 cmake_minimum_required(VERSION 3.11)
3 project(marnav
4         VERSION 0.12.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 11)
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_IO "Enable IO support" ON)
25 option(ENABLE_EXAMPLES "Enable Examples" ON)
26 option(ENABLE_TESTS "Enable Tests" ON)
27 option(ENABLE_TOOLS "Enable Tools" ON)
29 if(NOT DEFINED BUILD_SHARED_LIBS)
30         if(ENABLE_STATIC)
31                 set(BUILD_SHARED_LIBS FALSE)
32         else()
33                 set(BUILD_SHARED_LIBS TRUE)
34         endif()
35 endif()
37 # misc
38 include(RepoInformation)
39 include(Documentation)
40 include(CppCheck)
41 include(ExternalProject)
43 if(ENABLE_TOOLS)
44         include(ExternCxxopts)
45         include(ExternFmt)
46 endif()
48 ### common
49 message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}")
50 file(MAKE_DIRECTORY
51         ${CMAKE_CURRENT_BINARY_DIR}/doc
52         ${CMAKE_CURRENT_BINARY_DIR}/doc/coverage
53         ${CMAKE_CURRENT_BINARY_DIR}/local/include
54         )
56 ### library
57 add_subdirectory(src)
59 ### examples
60 message(STATUS "Build Examples: ${ENABLE_EXAMPLES}")
61 if(ENABLE_EXAMPLES)
62         add_subdirectory(examples)
63 endif()
65 ### ctags / cscope
66 include(CTags)
67 if(CTAGS_PATH AND CSCOPE_PATH)
68         setup_ctags_target("${CMAKE_CURRENT_SOURCE_DIR}/src/*.?pp;${CMAKE_CURRENT_SOURCE_DIR}/include/*.?pp")
69 endif()
71 ### testing
72 message(STATUS "Build Tests: ${ENABLE_TESTS}")
73 if(ENABLE_TESTS)
74         enable_testing()
75         include(ExternGoogletest)
76         include(ExternBenchmark)
77         add_subdirectory(test)
78 endif()
80 ### coverage
81 if(CMAKE_BUILD_TYPE MATCHES Coverage)
82         include(CodeCoverage)
83         setup_target_for_coverage(coverage
84                 testrunner
85                 doc/coverage
86                 )
87 endif()
89 set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
90 set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
91 set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
92 set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
93 set(CPACK_PACKAGE_NAME "marnav")
94 set(CPACK_PACKAGE_VENDOR "Mario Konrad")
95 set(CPACK_PACKAGE_CONTACT "Mario Konrad <mario.konrad@gmx.net>")
96 set(CPACK_PACAKGE_DESCRIPTION "Library for maritime navigation.")
97 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Library")
98 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
99 set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
100 set(CPACK_MONOLITHIC_INSTALL 1)
101 #set(CPACK_PACKAGE_EXECUTABLES "??" "??")
102 set(CPACK_STRIP_FILES true)
104 # package: debian
105 set(CPACK_DEBIAN_PACKAGE_NAME ${CPACK_DEBIAN_PACKAGE_NAME})
106 set(CPACK_DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_CONTACT})
107 set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACAKGE_DESCRIPTION})
108 set(CPACK_DEBIAN_PACKAGE_DEPENDS "libstdc++6 (>= 4.9)")
109 set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.3)")
110 set(CPACK_DEBIAN_PACKAGE_SECTION "misc")
111 if (CMAKE_SIZEOF_VOID_P MATCHES "8")
112         set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
113 else()
114         set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "i386")
115 endif()
117 include(CPack)