-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
75 lines (63 loc) · 2.42 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
cmake_minimum_required(VERSION 3.8.0)
project("libClaPP" VERSION 0.4.0)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
include(cmake/git.cmake)
include(cmake/compiler_flags.cmake)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
message(STATUS "Setting build to ${CMAKE_BUILD_TYPE}, because nothing was given.")
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_package(PkgConfig REQUIRED)
string(TIMESTAMP libClaPP_CONFIG_TIME "%Y-%m-%d %H:%M:%S")
set (THIRD_PARTY_DIR "${PROJECT_SOURCE_DIR}/third_party")
option(libClaPP_CLANG_TIDY "Clang-Tidy." Off)
option(libClaPP_CPPCHECK "CPPCheck." Off)
option(libClaPP_BUILD_TESTS "Build tests." Off)
option(libClaPP_BUILD_EXAMPLES "Build examples." Off)
option(libClaPP_BUILD_DOC_CODE "Build doc code." Off)
option(libClaPP_BUILD_COVERAGE "Cretae gcov build." Off)
option(libClaPP_SUBMODULE_DEPENDENCIES "Use dependencies from git submodules." Off)
option(libClaPP_ENABLE_IPO "Enable Iterprocedural Optimization, aka Link Time Optimization (LTO)" Off)
option(libClaPP_PEDANTIC_COMPILER_FLAGS "Enable pedantic compiler flags." Off)
if(libClaPP_ENABLE_IPO)
include(CheckIPOSupported)
check_ipo_supported(RESULT result OUTPUT output)
if(result)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
message(SEND_ERROR "IPO is not supported: ${output}")
endif()
endif()
if(libClaPP_CLANG_TIDY)
include(cmake/clang_tidy.cmake)
endif()
if(libClaPP_CPPCHECK)
if(CMAKE_VERSION VERSION_GREATER 3.10)
find_program(CPPCHECK cppcheck)
if(CPPCHECK)
set(CMAKE_CXX_CPPCHECK ${CPPCHECK} --enable=all --suppress=*:${CMAKE_CURRENT_SOURCE_DIR}/src/include/clapp/filesystem.h:27 --suppress=*:${THIRD_PARTY_DIR}/* --inconclusive -v -i${THIRD_PARTY_DIR})
else()
message(SEND_ERROR "CPPCheck requested but executable not found.")
endif()
else()
message(SEND_ERROR "CPPCheck requested but current CMAKE is not compatible.")
endif()
endif()
include(cmake/sanitizer.cmake)
include(cmake/gsl.cmake)
include(cmake/gtest.cmake)
enable_testing()
add_subdirectory(src)
if(libClaPP_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
if(libClaPP_BUILD_DOC_CODE)
add_subdirectory(doc)
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libclapp.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libclapp.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libclapp.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig/")
if(libClaPP_BUILD_TESTS)
add_subdirectory(tests)
endif()