Skip to content

icinga-installer: statically link MSVC runtime library on CMake 3.15+#10478

Merged
Al2Klimov merged 1 commit intomasterfrom
windows-installer-compat
Jun 16, 2025
Merged

icinga-installer: statically link MSVC runtime library on CMake 3.15+#10478
Al2Klimov merged 1 commit intomasterfrom
windows-installer-compat

Conversation

@julianbrost
Copy link
Copy Markdown
Member

@julianbrost julianbrost commented Jun 16, 2025

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.

Tests

I've built test packages1 and verified that the MSIs can be installed on both Windows Server 2016 and 2019 as well as that icinga2.exe can be started (to test that there are no other similar issues there).

fixes #10473

Footnotes

  1. x86, x86_64 (not available publicly)

@julianbrost julianbrost added this to the 2.15.0 milestone Jun 16, 2025
@julianbrost julianbrost added bug Something isn't working area/setup Installation, systemd, sample files area/windows Windows agent and plugins labels Jun 16, 2025
@cla-bot cla-bot bot added the cla/signed label Jun 16, 2025
@Al2Klimov Al2Klimov requested review from Al2Klimov and Copilot and removed request for Copilot June 16, 2025 09:26

This comment was marked as spam.

@julianbrost julianbrost marked this pull request as ready for review June 16, 2025 10:11
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
@julianbrost julianbrost force-pushed the windows-installer-compat branch from 6f98507 to 15a8114 Compare June 16, 2025 10:17
@julianbrost julianbrost changed the title icinga-installer: statically link MSCV runtime library on CMake 3.15+ icinga-installer: statically link MSVC runtime library on CMake 3.15+ Jun 16, 2025
@julianbrost
Copy link
Copy Markdown
Member Author

Just noticed a typo in the PR title and thus commit message. Fixed it, PR should be good to go from my side now.

Copy link
Copy Markdown
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.

  • Server 2012 R2
  • Server 2016
  • Server 2019

3b729e9 made it to "information/ConfigItem: Activated all objects." 👍

@Al2Klimov Al2Klimov mentioned this pull request Jun 16, 2025
3 tasks
@julianbrost
Copy link
Copy Markdown
Member Author

3b729e9

GHA: Windows: upgrade to VS 2022

Wrong commit or wrong PR?

@Al2Klimov
Copy link
Copy Markdown
Member

I've rebased that "wrong" PR on top of yours before testing.

Work smarter, not harder. 😎

@Al2Klimov Al2Klimov enabled auto-merge June 16, 2025 11:19
@Al2Klimov Al2Klimov merged commit cbff5c5 into master Jun 16, 2025
25 checks passed
@Al2Klimov Al2Klimov deleted the windows-installer-compat branch June 16, 2025 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/setup Installation, systemd, sample files area/windows Windows agent and plugins bug Something isn't working cla/signed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Latest snapshot broken on Server 2019 x64

3 participants