1 cmake_minimum_required(VERSION 3.2)
3 set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
4 set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
5 include(GitInformation)
7 project(marnav VERSION 0.6.1 LANGUAGES CXX C)
10 if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
11 message(STATUS "Compiler: GNU")
12 elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
13 message(STATUS "Compiler: Clang")
15 message(FATAL_ERROR "Unsupported compiler detected: ${CMAKE_CXX_COMPILER_ID}")
18 set(CMAKE_CXX_STANDARD 11)
19 set(CMAKE_CXX_STANDARD_REQUIRED ON)
20 set(CMAKE_CXX_EXTENSIONS OFF)
22 git_commit_hash(GIT_COMMIT_HASH GIT_COMMIT_HASH_SHORT)
23 git_branch_name(GIT_BRANCH)
25 message(STATUS "git branch: ${GIT_BRANCH}")
26 message(STATUS "git commit hash: ${GIT_COMMIT_HASH}")
29 if(NOT ("${CMAKE_BUILD_TYPE}" MATCHES "Release"))
30 set(PROJECT_VERSION "${PROJECT_VERSION}-${GIT_COMMIT_HASH_SHORT}")
32 message(STATUS "Project Vesion: ${PROJECT_VERSION}")
35 include(ExternalProject)
37 include(ExternBenchmark)
40 option(ENABLE_PROFILING "Enable Profiling" OFF)
41 option(ENABLE_BENCHMARK "Enable Benchmark" OFF)
42 option(ENABLE_WARNING_HELL "Enable Warning Hell" OFF)
43 option(ENABLE_SANITIZER "Enable Sanitizing (address, undefined)" OFF)
44 option(ENABLE_AIS "Enable AIS support" ON)
45 option(ENABLE_SEATALK "Enable SeaTalk support" ON)
46 option(ENABLE_IO "Enable IO support" ON)
49 message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}")
50 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
52 ${CMAKE_CURRENT_BINARY_DIR}/doc
53 ${CMAKE_CURRENT_BINARY_DIR}/doc/coverage
54 ${CMAKE_CURRENT_BINARY_DIR}/local/include
56 string(TOLOWER "${CMAKE_BUILD_TYPE}" build_type_lower)
62 add_subdirectory(examples)
66 if(CTAGS_PATH AND CSCOPE_PATH)
67 setup_ctags_target("${CMAKE_CURRENT_SOURCE_DIR}/src/*.?pp")
73 git_authors(GIT_AUTHORS AUTHOR_LIST)
75 ${CMAKE_CURRENT_SOURCE_DIR}/doc/main.dox.in
76 ${CMAKE_CURRENT_BINARY_DIR}/doc/main.dox
79 ${CMAKE_CURRENT_SOURCE_DIR}/doxygen.conf.in
80 ${CMAKE_CURRENT_BINARY_DIR}/doxygen.conf
83 COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxygen.conf
85 add_dependencies(doc tags)
89 find_program(CPPCHECK_PATH cppcheck)
91 message(STATUS "cppcheck found: ${CPPCHECK_PATH}")
92 add_custom_target(cppcheck
93 COMMAND ${CPPCHECK_PATH} --suppressions-list=${CMAKE_CURRENT_SOURCE_DIR}/cppcheck-suppress.txt --std=c++11 --platform=unix32 -v -f --enable=all --template='{file}:{line},{severity},{id},{message}' -I ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/test 2> ${CMAKE_CURRENT_BINARY_DIR}/doc/cppcheck.txt
94 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
97 message(STATUS "cppcheck not found, target not available.")
100 ### testing common stuff
103 ### unit tests, assumes gtest (because of the program argument)
104 add_custom_target(unittest)
105 macro(run_unittest unittest_target)
106 add_custom_target(${unittest_target}_runtest
107 COMMAND ${unittest_target} --gtest_shuffle
108 DEPENDS ${unittest_target}
109 WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
111 add_dependencies(unittest ${unittest_target}_runtest)
114 add_subdirectory(test)
117 if(build_type_lower MATCHES coverage)
118 include(CodeCoverage)
119 setup_target_for_coverage(coverage
127 set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
128 set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
129 set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
130 set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
131 set(CPACK_PACKAGE_NAME "marnav")
132 set(CPACK_PACKAGE_VENDOR "Mario Konrad")
133 set(CPACK_PACKAGE_CONTACT "Mario Konrad <mario.konrad@gmx.net>")
134 set(CPACK_PACAKGE_DESCRIPTION "Library for maritime navigation.")
135 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Library")
136 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
137 set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
138 set(CPACK_MONOLITHIC_INSTALL 1)
139 #set(CPACK_PACKAGE_EXECUTABLES "??" "??")
140 set(CPACK_STRIP_FILES true)
143 set(CPACK_DEBIAN_PACKAGE_NAME ${CPACK_DEBIAN_PACKAGE_NAME})
144 set(CPACK_DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_CONTACT})
145 set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACAKGE_DESCRIPTION})
146 set(CPACK_DEBIAN_PACKAGE_DEPENDS "libstdc++6 (>= 4.8)")
147 set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.3)")
148 set(CPACK_DEBIAN_PACKAGE_SECTION "misc")
149 if (CMAKE_SIZEOF_VOID_P MATCHES "8")
150 set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
152 set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "i386")