From affecc4734979418ed81754d245bacbec7df52d0 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Thu, 3 Apr 2025 15:56:22 +0200 Subject: [PATCH 1/4] Drop superfluous `MACOSX_RPATH` definition It's on by default since CMake version `3.0` --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 730eda6f7..0bd22d349 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -225,7 +225,6 @@ if(WIN32) list(APPEND base_DEPS ws2_32 dbghelp shlwapi msi) endif() -set(CMAKE_MACOSX_RPATH 1) set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH};${CMAKE_INSTALL_FULL_LIBDIR}/icinga2") if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") From 43ff97065e8259dbb66f22b5e5c9c3b7de8526e4 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Thu, 3 Apr 2025 16:43:31 +0200 Subject: [PATCH 2/4] Fix CMake doesn't export symbols of executables anymore CMake 3.4 introduced a new policy [^1] which prevents from automatically adding the compiler flags needed for exporting the symbols of the executables and libraries without the `ENABLE_EXPORTS` property. So, by defining this variable, CMake will restore the previous behaviour by automatically adding the `ENABLE_EXPORTS` properties to all targets. [1]: https://cmake.org/cmake/help/latest/policy/CMP0065.html --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0bd22d349..f5abbfa46 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,10 @@ if(NOT CMAKE_BUILD_TYPE) FORCE) endif() +# Include symbols in executables so that function names can be printed in stack traces, for example in crash dumps. +set(CMAKE_ENABLE_EXPORTS ON) # Added in CMake 3.4 +set(CMAKE_EXECUTABLE_ENABLE_EXPORTS ON) # Added in CMake 3.27 and supersedes the above one. + option(ICINGA2_WITH_MYSQL "Build the MySQL IDO module" ON) option(ICINGA2_WITH_PGSQL "Build the PostgreSQL IDO module" ON) option(ICINGA2_WITH_CHECKER "Build the checker module" ON) From a25d5d84667a7ae8710cc89223852616dc666667 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Thu, 3 Apr 2025 10:01:43 +0200 Subject: [PATCH 3/4] Raise cmake minimum required version to `3.8...3.17` CMake version `< 3.5` is no longer supported, so the new CMake minimum policy version is set to `3.8` to support C++17 unconditionally. After checking all the policies that might affect Icinga 2 in any way, CMake `3.17` is used as a max supported CMake policy. Anything above that may work but we didn't explicitly verify the policies introduced with CMake 3.18 and later and may or may not affect Icinga 2. --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f5abbfa46..d7df520bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,7 @@ # Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ -cmake_minimum_required(VERSION 2.8.8) +# CMake 3.8 is required, CMake policy compatibility was verified up to 3.17. +cmake_minimum_required(VERSION 3.8...3.17) set(BOOST_MIN_VERSION "1.66.0") project(icinga2) From c59cd55073b0c3fb8eb3fd5804f213185bc8b1ae Mon Sep 17 00:00:00 2001 From: Julian Brost Date: Mon, 16 Jun 2025 09:08:19 +0200 Subject: [PATCH 4/4] icinga-installer: statically link MSVC runtime library on CMake 3.15+ CMake 3.15 introduced the `MSVC_RUNTIME_LIBRARY` property as a way to specify which MSVC runtime library is used and how it is linked. Also with that release, policy CMP0091 was introduced where the new behavior no longer adds the corresponding compile flags to the `CMAKE__FLAGS_` variables. The new policy was enabled by 7f164bda96341272be385fa1359a26f97eb9d2b4, resulting in the MSI no longer working on previous Windows Server versions (2019 for example) as the CMake configuration replaced those compile flags (lines 3-9 in the same file) which no longer works when they are no longer part of the string. This commit fixes this regression by setting the `MSVC_RUNTIME_LIBRARY` property on the icinga-installer target. I've also added a comment stating my understanding of why this is necessary. Unfortunately, I couldn't find an explanation of why replacing the /MD with the /MT flag was done originally in the project history, so it's a bit of guesswork. https://cmake.org/cmake/help/latest/policy/CMP0091.html https://cmake.org/cmake/help/latest/prop_tgt/MSVC_RUNTIME_LIBRARY.html --- icinga-installer/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/icinga-installer/CMakeLists.txt b/icinga-installer/CMakeLists.txt index 6ac5e1f04..1cd80b513 100644 --- a/icinga-installer/CMakeLists.txt +++ b/icinga-installer/CMakeLists.txt @@ -19,6 +19,10 @@ set_target_properties( FOLDER Bin OUTPUT_NAME icinga2-installer LINK_FLAGS "/SUBSYSTEM:WINDOWS" + + # Use a statically-linked runtime library as this binary is run during the installation process where the other DLLs + # may not have been installed already and the system-provided version may be too old. + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" ) target_link_libraries(icinga-installer shlwapi)