-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathCMakeLists.txt
118 lines (101 loc) · 4.29 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
################################################################################
## J-PET Framework Library
## Description:
## Builds J-PET Framework using CMake build generator.
################################################################################
cmake_minimum_required(VERSION 3.1...3.14)
if(${CMAKE_VERSION} VERSION_LESS 3.14)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
else()
cmake_policy(VERSION 3.14)
endif()
## Set correct project version based on: https://semver.org/
# Given a version number MAJOR.MINOR.PATCH, increment the:
#
# MAJOR version when you make incompatible API changes,
# MINOR version when you add functionality in a backwards-compatible manner, and
# PATCH version when you make backwards-compatible bug fixes.
project(JPetFramework VERSION 10.0.0
LANGUAGES CXX)
set(PROJECT_DESCRIPTION "JPetFramework module")
message(STATUS "")
message(STATUS " == ${PROJECT_NAME} Project configuration ==")
message(STATUS "")
message(STATUS "")
message(STATUS "Starting to configure libJPetFramework..")
message(STATUS "")
set(default_build_type "Release")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_PLATFORM_INDEPENDENT_CODE ON)
# Force out-of-source build
file(TO_CMAKE_PATH "${PROJECT_BINARY_DIR}/CMakeLists.txt" LOC_PATH)
if(EXISTS "${LOC_PATH}")
message(FATAL_ERROR "You cannot build in a source directory (or any directory with a CMakeLists.txt file). Please make a build subdirectory. Feel free to remove CMakeCache.txt and CMakeFiles.")
endif()
# Include cmake modules
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
include(JPetFramework-Utilities)
# Helpful option enable build profiling to identify slowly compiling files
option(MEASURE_ALL "When enabled all commands will be passed through time command" OFF)
if(MEASURE_ALL)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "time")
endif()
################################################################################
## Install format hook to git
## Automatically installs hook to .git/hooks/pre-commit to format code with clang-format
option(INSTALL_HOOK "Install format hook to .git/hooks/pre-commit" ON)
if(INSTALL_HOOK)
message(STATUS "Trying to install format hook..")
package_add_format_hook()
endif()
add_subdirectory(src)
#documentation
option(PACKAGE_DOC "Build the documentation" OFF)
if(PACKAGE_TESTS)
add_subdirectory(doc)
endif()
#unit tests
option(PACKAGE_TESTS "Build the tests" ON)
if(PACKAGE_TESTS)
enable_testing()
add_subdirectory(tests)
endif()
# Packaging support
set(CPACK_GENERATOR "DEB")
set(CPACK_PACKAGE_VENDOR "JPetTomography")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Package contains JPetFramework module")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "grey")
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_SOURCE_GENERATOR "TGZ;ZIP")
set(CPACK_SOURCE_IGNORE_FILES
/.git
/*.dist*
/.*build.*
/\\\\.DS_Store
)
include(CPack)
################################################################################
# Wrap up of settings printed on build
message(STATUS "")
message(STATUS " == Final overview for ${PROJECT_NAME} ==")
message(STATUS "Version: ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "Compiler: ${CMAKE_CXX_COMPILER}")
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
message(STATUS " possible options: Debug Release RelWithDebInfo MinSizeRel")
message(STATUS " set with ` cmake -DCMAKE_BUILD_TYPE=Debug .. `")
message(STATUS "")