Skip to content

CMake: Fix for #1699 msvc runtime selection issues#1701

Merged
dsnopek merged 1 commit into
godotengine:masterfrom
enetheru:msvc_runtime
Feb 17, 2025
Merged

CMake: Fix for #1699 msvc runtime selection issues#1701
dsnopek merged 1 commit into
godotengine:masterfrom
enetheru:msvc_runtime

Conversation

@enetheru

@enetheru enetheru commented Feb 5, 2025

Copy link
Copy Markdown
Collaborator

Previously I eschewed the use of CMAKE_MSVC_RUNTIME_LIBRARY in favour of setting the flags using target_compile_options so that they would propagate to consumers.

However, it has been raised in #1699 that a dependency( independent to godot-cpp ) that doesn't set any runtime flags, which relies purely on the CMAKE_MSVC_RUNTIME_LIBRARY variable will very likely not have the correct msvc runtime flags set.

Where MSVC documentation states "All modules passed to a given invocation of the linker must have been compiled with the same runtime library compiler option (/MD, /MT, /LD)."

It was also mentioned that messaging as a warning that we are setting the option was not ideal.

So I have updated the cmake code to use CMAKE_MSVC_RUNTIME_LIBRARY over target-compile_options. And set it as a CACHE STRING variable so that it can be overridden if desired. We still message consumers, but as a STATUS.

@enetheru
enetheru force-pushed the msvc_runtime branch 3 times, most recently from b2b13df to 776ca38 Compare February 5, 2025 11:20
@enetheru
enetheru marked this pull request as ready for review February 5, 2025 12:34
@enetheru
enetheru requested a review from a team as a code owner February 5, 2025 12:34
@enetheru

enetheru commented Feb 8, 2025

Copy link
Copy Markdown
Collaborator Author

@dsnopek This is an important PR for windows.
Discussion is in #1699

@dsnopek dsnopek left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks! LGTM :-)

@dsnopek dsnopek added bug This has been identified as a bug cmake topic:buildsystem Related to the buildsystem or CI setup labels Feb 14, 2025
@dsnopek dsnopek added this to the 4.x milestone Feb 14, 2025
Previously I eschewed the use of CMAKE_MSVC_RUNTIME_LIBRARY in favour of setting the flags using target_compile_options so that they would propagate to consumers.

However, it has been raised that a dependency( independent to godot-cpp ) that doesn't set any runtime flags, which relies purely on the CMAKE_MSVC_RUNTIME_LIBRARY variable will very likely not have the correct msvc runtime flags set.

Where MSVC documentation states "All modules passed to a given invocation of the linker must have been compiled with the same runtime library compiler option (/MD, /MT, /LD)."

It was also mentioned that message type WARNING is not ideal for notifying consumers.

So I have updated the cmake code to use CMAKE_MSVC_RUNTIME_LIBRARY  over target-compile_options. And set it as a CACHE STRING variable so that it can be overridden if desired. We still message consumers, but as a NOTICE.
@dsnopek
dsnopek merged commit 847dca4 into godotengine:master Feb 17, 2025
@enetheru
enetheru deleted the msvc_runtime branch February 17, 2025 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug This has been identified as a bug cmake topic:buildsystem Related to the buildsystem or CI setup

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants