-
-
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
{cmake} Use cmake capabilities #957
base: master
Are you sure you want to change the base?
Conversation
FYI I'm trying to get this CMake to play nicer with CMake-based projects which include this as a subdirectory (e.g. GDExtensionTemplate). The including project should have control over optimization level and debug symbols, for example. Also - I'm not sure about the Windows stuff here (since I don't build on Windows) - but I suspect that some of it is setting things that are already defaults. This can can probably be cleaned up as well. |
312850b
to
2b6ede5
Compare
Out of curiosity, does enabling LTO/LTCG with |
Following up on my previous comment, I used CI to look at the command lines being produced by MSVC and removed some redundancies from the CMake file. |
Oh! I'm not sure. I've not used INTERPROCEDURAL_OPTIMIZATION before, but I can try it locally (macOS x86_64). |
I may have gotten the name wrong – it might be |
👍 It's |
cefd946
to
8f10246
Compare
Still loads and seems to run fine in Godot. |
Note that after this PR the CI builds for Visual Studio will be I tried addressing this in my (admittedly over-complicated) PR #893. The very abbreviated version of it is that I would suggest replacing any remaining occurrence of |
Thanks @mihe - I will look at it! |
8f10246
to
7dbd6ff
Compare
7dbd6ff
to
8072a4e
Compare
Updated based on input from @mihe.
|
8072a4e
to
a78155c
Compare
a78155c
to
6d981a4
Compare
Would it be easier if I broke this PR up a bit? I can see about 3 logical pieces I can break it into. |
I'm not deeply familiar with CMake, but I have one requirement for this buildsystem: The output should be the same as the SCons reference buildsystem. The CMake tooling is provided as convenience for people who want to integrate in other CMake projects, or who really don't want to use SCons for some reason, but the generated binaries for equivalent options in SCons and CMake should be the same. As such, I'm not too fond of removing explicit flags because they're default in CMake's equivalent config. Godot's flags may change in the future, or CMake's flags may change. Both should always be in sync. Explicit is always better than implicit so that we know what we're doing and why. This isn't a decision we're leaving to the CMake team. |
I get where you are coming from, but anyone familiar with CMake and trying to use this in their own project will find it difficult (or impossible) to work with. There are several anti-patterns here (e.g. setting some flags like I would argue that godot-cpp is not Godot - it's the API a non-godot developer uses to write their extensions and therefore it needs to integrate with their code and existing libraries - not the other way around. It's essentially the UX for someone trying to integrate with Godot and as such it should follow standards (actual & defacto) more closely to make it easier to understand and easier to work with for the (non-godot) developers. With all the PRs/issues I've made in godot-cpp I've tried to adopt the viewpoint of a C++ developer without any knowledge of Godot's code base who wants to create an extension for Godot. I ask questions such as "how would they expect this to work?", "how does this work if they are integrating one or more existing CMake-based libraries? (e.g. conflicting explicit flags?)", "can this be made clearer & easier?", ""are there problems what would prevent them from working with it?". Then I worked through the experience by building the GDExtensionTemplate project (and another project using it - Inception?) to provide a solid starting point. I'm trying to improve the dev's UX because I believe extensions are a critical part of Godot's ecosystem, so making it easy & familiar is a big win. All that said, most of the changes here are not making explicit flags implicit. I will pick this PR apart and try smaller PRs so we can see where the friction points are. |
I've just received my first report about linking issues that seems the be because godot-cpp is trying to do things its own way. Those MSVC link options have to be consistent throughout the build, so setting them explicitly just won't work. The way things are right now, we can't set up multiconfig builds using godot-cpp (see discussion about |
- (gcc/clang) should not set "-g" (debug symbols) explicitly; this is controlled by CMAKE_BUILD_TYPE for single-configuration generators (Debug or RelWithDebInfo will include symbols) - (gcc/clang) "-O0" is the default for Debug builds - (gcc/clang) "-O3" is the default for Release builds - (MSVC) remove explicit setting of flags which are already set by Debug/Release (/EHsc, /Md, etc.) - (MSVC) remove manipulation of CMAKE_CXX_FLAGS_DEBUG; the including project should control this - remove/replace references to CMAKE_BUILD_TYPE to allow for multi-config generators
6d981a4
to
cc6911a
Compare
(Force push to remove |
Yeah, the MSVC runtime library stuff (assuming you're talking about asmaloney/GDExtensionTemplate#43) was part of the PR I linked above. This is two problems rolled up into one. The first problem is, as you say, the reliance on The second problem is that even if the first problem wasn't a thing, you'd still run into this linker error when a user wants to statically link against MSVC's runtime, meaning This is something you find in CMake setups of other popular libraries as well, such as GLFW. I'm not sure if there's much of an argument for making it a build option with |
How much of this conversation is still relevant?
|
- we are building a static lib, so don't set the link flags explicitly, use STATIC- use the POSITION_INDEPENDENT_CODE property instead of setting the flag explicitly(Moved to its own PR.)