|
4 | 4 | cmake_minimum_required(VERSION 3.17...3.17) |
5 | 5 | set(BOOST_MIN_VERSION "1.66.0") |
6 | 6 |
|
| 7 | +set(ICINGA2_VERSION "2.15.0") |
| 8 | + |
7 | 9 | set(CMAKE_CXX_STANDARD 17) |
8 | 10 | set(CMAKE_CXX_STANDARD_REQUIRED ON) |
9 | 11 | set(CMAKE_CXX_EXTENSIONS OFF) |
@@ -54,6 +56,11 @@ set(ICINGA2_GIT_VERSION_INFO ON CACHE BOOL "Whether to use git describe") |
54 | 56 | set(ICINGA2_UNITY_BUILD ON CACHE BOOL "Whether to perform a unity build") |
55 | 57 | set(ICINGA2_LTO_BUILD OFF CACHE BOOL "Whether to use LTO") |
56 | 58 |
|
| 59 | +option(ICINGA2_INCLUDE_PACKAGE_INFO "Include package version in 'icinga2 --version'" OFF) |
| 60 | +set(ICINGA2_PACKAGE_VERSION ${ICINGA2_VERSION} CACHE STRING "Version used when packaging Icinga 2") |
| 61 | +set(ICINGA2_PACKAGE_REVISION "1" CACHE STRING "Revision used when packaging Icinga 2") |
| 62 | +set(ICINGA2_PACKAGE_VENDOR "Icinga GmbH" CACHE STRING "Vendor string used when packaging Icinga 2") |
| 63 | + |
57 | 64 | set(ICINGA2_CONFIGDIR "${CMAKE_INSTALL_SYSCONFDIR}/icinga2" CACHE FILEPATH "Main config directory, e.g. /etc/icinga2") |
58 | 65 | set(ICINGA2_CACHEDIR "${CMAKE_INSTALL_LOCALSTATEDIR}/cache/icinga2" CACHE FILEPATH "Directory for cache files, e.g. /var/cache/icinga2") |
59 | 66 | set(ICINGA2_DATADIR "${CMAKE_INSTALL_LOCALSTATEDIR}/lib/icinga2" CACHE FILEPATH "Data directory for the daemon, e.g. /var/lib/icinga2") |
@@ -97,35 +104,20 @@ file(READ "${CMAKE_CURRENT_SOURCE_DIR}/COPYING" ICINGA2_LICENSE_GPL) |
97 | 104 | set(ICINGA2_LICENSE "${ICINGA2_LICENSE_GPL}\n\n---\n\n${ICINGA2_LICENSE_ADDITIONS}") |
98 | 105 | file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt" ${ICINGA2_LICENSE}) |
99 | 106 |
|
100 | | -file(STRINGS ICINGA2_VERSION SPEC_VERSION REGEX "^Version:") |
101 | | -string(LENGTH "${SPEC_VERSION}" SPEC_VERSION_LENGTH) |
102 | | -math(EXPR SPEC_VERSION_LENGTH "${SPEC_VERSION_LENGTH} - 9") |
103 | | -string(SUBSTRING ${SPEC_VERSION} 9 ${SPEC_VERSION_LENGTH} SPEC_VERSION) |
104 | | - |
105 | | -configure_file(icinga-spec-version.h.cmake icinga-spec-version.h) |
106 | | - |
107 | 107 | include(GetGitRevisionDescription) |
108 | | -git_describe(GIT_VERSION --tags) |
109 | | -if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/icinga-version.h.force) |
110 | | - configure_file(icinga-version.h.force ${CMAKE_CURRENT_BINARY_DIR}/icinga-version.h COPYONLY) |
111 | | -else() |
112 | | - if(NOT ICINGA2_GIT_VERSION_INFO OR GIT_VERSION MATCHES "-NOTFOUND$") |
113 | | - file(STRINGS ICINGA2_VERSION SPEC_REVISION REGEX "^Revision: ") |
114 | | - string(LENGTH "${SPEC_REVISION}" SPEC_REVISION_LENGTH) |
115 | | - math(EXPR SPEC_REVISION_LENGTH "${SPEC_REVISION_LENGTH} - 10") |
116 | | - string(SUBSTRING ${SPEC_REVISION} 10 ${SPEC_REVISION_LENGTH} SPEC_REVISION) |
117 | | - |
118 | | - set(GIT_VERSION "r${SPEC_VERSION}-${SPEC_REVISION}") |
119 | | - set(ICINGA2_VERSION "${SPEC_VERSION}") |
120 | | - else() |
121 | | - # use GIT version as ICINGA2_VERSION |
122 | | - string(REGEX REPLACE "^[rv]" "" ICINGA2_VERSION "${GIT_VERSION}") |
| 108 | +git_describe(ICINGA2_VERSION) |
| 109 | +if(NOT ICINGA2_GIT_VERSION_INFO OR ICINGA2_VERSION MATCHES "-NOTFOUND$") |
| 110 | + include(icinga-archive-version.cmake) |
| 111 | + if(ICINGA2_VERSION MATCHES "^\\$.*") |
| 112 | + set(ICINGA2_VERSION "v${ICINGA2_PACKAGE_VERSION}-${ICINGA2_PACKAGE_REVISION}") |
123 | 113 | endif() |
124 | | - configure_file(icinga-version.h.cmake icinga-version.h) |
125 | 114 | endif() |
126 | 115 |
|
| 116 | +# We need a version string that doesn't contain the leading 'v' for the icinga.rc file |
| 117 | +string(REGEX REPLACE "^[rv]" "" ICINGA2_RC_VERSION "${ICINGA2_VERSION}") |
| 118 | + |
127 | 119 | # NuGet on Windows requires a semantic versioning, example: 2.10.4.123 (only 4 element, only numeric) |
128 | | -string(REGEX REPLACE "-([0-9]+).*$" ".\\1" ICINGA2_VERSION_SAFE "${ICINGA2_VERSION}") |
| 120 | +string(REGEX REPLACE "-([0-9]+).*$" ".\\1" ICINGA2_VERSION_SAFE "${ICINGA2_RC_VERSION}") |
129 | 121 | string(REGEX REPLACE "-[^\\.]*(.*)$" "\\1" ICINGA2_VERSION_SAFE "${ICINGA2_VERSION_SAFE}") |
130 | 122 | string(REGEX REPLACE "^([0-9]+\\.[0-9]+\\.[0-9]+)[\\.]?[0-9]*" "\\1" CHOCO_VERSION_SHORT "${ICINGA2_VERSION_SAFE}") |
131 | 123 |
|
@@ -496,7 +488,7 @@ if(BUILD_TESTING) |
496 | 488 | endif() |
497 | 489 |
|
498 | 490 | set(CPACK_PACKAGE_NAME "Icinga 2") |
499 | | -set(CPACK_PACKAGE_VENDOR "Icinga GmbH") |
| 491 | +set(CPACK_PACKAGE_VENDOR ${ICINGA2_PACKAGE_VENDOR}) |
500 | 492 | set(CPACK_PACKAGE_VERSION ${ICINGA2_VERSION_SAFE}) |
501 | 493 | set(CPACK_PACKAGE_INSTALL_DIRECTORY "ICINGA2") |
502 | 494 | set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/icinga-app\\\\icinga.ico") |
|
0 commit comments