icinga-installer: statically link MSVC runtime library on CMake 3.15+#10478
Merged
icinga-installer: statically link MSVC runtime library on CMake 3.15+#10478
Conversation
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
6f98507 to
15a8114
Compare
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. |
Member
Author
Wrong commit or wrong PR? |
Member
|
I've rebased that "wrong" PR on top of yours before testing. Work smarter, not harder. 😎 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CMake 3.15 introduced the
MSVC_RUNTIME_LIBRARYproperty 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 theCMAKE_<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_LIBRARYproperty 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.execan be started (to test that there are no other similar issues there).fixes #10473
Footnotes
x86, x86_64 (not available publicly) ↩