Set static/shared msvc runtime flags using a CMake property instead of overwriting the flags #2434
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.
Issue #, if available: #2056
Description of changes:
This PR changes how the flags for the MSVC C++ runtime linkage are set. Before this PR, the CMAKE_CXX_FLAGS were changed. WIth CMake 3.15, there exists the property CMAKE_MSVC_RUNTIME_LIBRARY. Based on the options provided by this SDK, this property is set instead of changing the flags.
Defining the property so early has 2 advantages:
This variable is used to initialize the MSVC_RUNTIME_LIBRARY property on all targets as they are created
which results in that all targets have the right runtime. This solves the problem described in Built aws-sdk-cpp with multi-threaded (\MT) runtime library (including aws-crt-cpp) #2056As you can read in the CMake documentation, any non msvc builds are not affected by defining the property.
Please ask and/or edit, if I missed something.
Check all that applies:
Changes in the buildsystem. Test would be, if the project compiled or not. I cannot see any CI builds in the .guthub/workflows. If I should add a build target, please let me know.
Requires CMake 3.15 instead of 3.12. CMake 3.15 is from 2019, so I don't see it as a big problem
Only Windows is affected.
No Readme changes required. Options are still the same with the same semantic.
Check which platforms you have built SDK on to verify the correctness of this PR.
Build and unit-tested locally with dynamic and static linkage
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.