Skip to content

Conversation

@jschmidt-icinga
Copy link
Contributor

These are the changes from #10402 backported to the 2.13 support branch as requested by @julianbrost.

It's on by default since CMake version `3.0`
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
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.
@cla-bot cla-bot bot added the cla/signed label Nov 6, 2025
Copy link
Member

@Al2Klimov Al2Klimov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This stuff already broke #10473, so do either:

  • Keep stuff as is – our build server can handle it
  • Also backport #10478

(To be sure, you can test on Windows Server.)

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_<LANG>_FLAGS_<CONFIG>` variables.

The new policy was enabled by 7f164bd,
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants