-
-
Notifications
You must be signed in to change notification settings - Fork 603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support multi configuration build tools (MSVC) with CMake #1229
Comments
pull request |
I encountered the same problem on vs2022. I hope it can be merged soon. |
I have a PR to modernise the current solution which no longer relies on CMAKE_BUILD_TYPE for exactly this reason. If merged I believe should solve this issue. |
With PR Modernise existing cmake options by @enetheru being merged, I consider this issue being resolved. Thank you a lot!! We wanted a candy and you baked us a master chief level cake!!! I have some issues though, that are probably rise from legacy usage of godot-cpp and I don't know how to adapt to modernized approach. Can't find the exact guide I've followed, but here is a similar one: Godot4 GDExtension C++ Example cmake_minimum_required(VERSION 3.19)
project(MyGdExCppProject )
include(FetchContent)
FetchContent_Declare(
godot-cpp
GIT_REPOSITORY https://github.com/godotengine/godot-cpp.git
GIT_TAG master (the last tag, I used before was godot-4.1.1-stable)
)
FetchContent_MakeAvailable(godot-cpp)
add_library(MyGdExCppProject MODULE MyGdExCppProject .cpp)
target_link_libraries(MyGdExCppProject PRIVATE godot::cpp ) What it used to do is automatically pull git repo, run CMake for it and link target godot::cpp to my target (MyGdExCppProject here). godot::cpp was a separate target for making a static library. Now CMake gives error:
I've disabled
My main question is how to properly link against Once again thank you for titanic work you've done! |
The godot::cpp target has been split into three to follow the way the SCons build works. so you want to add to target link libraries one of the aliases
I'll look into methods of hiding godot-cpp targets from consumers so they dont clutter up the list. |
Do I Get it right, that I should use something like this?
Will it be possible to add proxy (INTERFACE in CMake terms) target godot::cpp for backward compatibility? There are many guides that use that and it might cause confusion. |
are PUBLIC,PRIVATE,INTERFACE the thing you mean? I'm not sure.
The reason they are all visible is because you can build all the targets at once, and they dont block each other, no re-configure required. so you can do something like I am on discord in the godot-cafe or on the dev rocket chat if you want more real-time chat.
template_debug and template_release mean something different than your typical Release/Debug build configurations. so while you can do what you listed, unless you want debug symbols I would build only as release. a template_debug build is more about enabling godot debug features rather than enabling c++ debug symbols and optimisation flags. It's confusing I know. |
Closing as resolved. If there is still some confusion, discussion can continue here (or elsewhere). |
Godot version
4.1-dev
godot-cpp version
4.1
System information
Windows10
Issue description
When creating GDExtention C++ module using CMake, both Release and Debug configurations are linked against debug runtime libraries for MSVC, wich causes multiple errors like that:
This happens because in CMakeLists.txt there is a static check for CMAKE_BUILD_TYPE, which is not used for multi-config build generators (MSVC, Ninja-MultiConfig, xcode) at this point of CMakeLists.txt
Its better to use CMAKE_CXX_FLAGS_DEBUG, CMAKE_CXX_FLAGS_RELEASE etc for Release|Debug configurations without any condition on CMAKE_BUILD_TYPE, because it will break any multi-config generators (while using CMAKE_CXX_FLAGS_ is universal). Using CMAKE_CXX_FLAGS should be reserved for common flags: in the example of MSCV: "/EHsc /utf-8".
here is how I propose to change this segment (removed project-specific options, because it might be better to have same compile options for godot-cpp and GDExtention project):
Steps to reproduce
Minimal reproduction project
N/A
The text was updated successfully, but these errors were encountered: