Skip to content

Incorrect CMake configuration for template_release #1690

Closed

Description

@NetroScript

Godot version

4.4-beta1

godot-cpp version

13cd2d9

System information

Windows 11, CMake 3.30.5, Visual Studio 2022

Issue description

When using CMake and compiling godot-cpp::template_release debugging features will still be enabled.

Specifically in

set( DEBUG_FEATURES "$<NOT:$<STREQUAL:${TARGET_NAME},template_release>>" )
DEBUG_FEATURES are turned off, when ${TARGET_NAME}is set to template_release, however it needs to be ${TARGET_ALIAS}.

This can also be seen in current build logs of the GitHub Actions such as
https://github.com/godotengine/godot-cpp/actions/runs/12892247119/job/35946077972
When checking the Build test GDExtension library step, a release version should be built, however the build command includes /D DEBUG_ENABLED /D DEBUG_METHODS_ENABLED

I investigated this, as for my extension the build on Windows MSVC was failing, as libgodot-cpp.windows.template_release.x86_64.libwas over 4GB in size. Thankfully #1628 puts it back at around 3.5GB so MSVC is working again.

However even when correcting the aforementioned line of code to set( DEBUG_FEATURES "$<NOT:$<STREQUAL:${TARGET_ALIAS},template_release>>") the line in

$<${DEBUG_FEATURES}:DEBUG_ENABLED DEBUG_METHODS_ENABLED>
still evaluates to true for me. However, I did not have the time to take a more detailed look.

Steps to reproduce

It is possible to use the same commands the CI is currently using:

mkdir cmake-build
cd cmake-build
cmake ../ -DGODOT_ENABLE_TESTING=YES
cmake --build . --verbose -t godot-cpp.test.template_release --config Release

Upon inspection of the generated build commands it will be visible how the debug info is always included.

Minimal reproduction project

/

Activity

  1. added a commit that references this issue on Jan 23, 2025
    9ce7a71
  2. enetheru commented on Jan 23, 2025

    @enetheru
    Collaborator

    Thanks for the report, you are indeed correct and it's my bad.

    However even when correcting the aforementioned line of code to set( DEBUG_FEATURES "$<NOT:$<STREQUAL:${TARGET_ALIAS},template_release>>") the line in

    godot-cpp/cmake/common_compiler_flags.cmake

    Line 149 in 13cd2d9

    I checked this, and I am not seeing the same result. a template_release Release build evaluates the expression to 0 for me.
    I ran exactly the same commands as you to check it. and the resulting compile commands omit the related build flags.

  3. NetroScript commented on Jan 23, 2025

    @NetroScript
    Author

    I just tested it again in the console instead of with my IDE and then it also works for me without the debug switches. The only difference is that the IDE uses Ninja as generator (which in turn then uses MSVC).

    However when Ninja is used as generator, it still produces build files which have -DDEBUG_ENABLED -DDEBUG_METHODS_ENABLED enabled for some reason.

    This is also reproducible in the test project when using:

    cmake -G Ninja ../ -DGODOT_ENABLE_TESTING=YES

    instead as command.

    (Here I was using the Developer Powershell for VS 2022, CMake 3.29.0, Ninja 1.11.1)

  4. enetheru commented on Jan 23, 2025

    @enetheru
    Collaborator

    This is after the fix yes?

    I cant re-produce, it generates correct results for me. Is this an accurate reflection of what you have done?

    Note: I use the build_profile to cut down on compile times.

    **********************************************************************
    ** Visual Studio 2022 Developer PowerShell v17.12.4
    ** Copyright (c) 2022 Microsoft Corporation
    **********************************************************************
    PS C:\Program Files\Microsoft Visual Studio\2022\Community> cd C:\Godot\src\godot-cpp\cmake-build-test\
    
    PS C:\Godot\src\godot-cpp\cmake-build-test> cmake ../ -DGODOT_ENABLE_TESTING=YES -GNinja -DCMAKE_VERBOSE_MAKEFILE=ON -DGODOT_BUILD_PROFILE="..\test\build_profile.json"
    Auto-detected 16 CPU cores available for build parallelism.
    Using 15 cores for multi-threaded compilation.
    -- Using build profile to trim api file
            BUILD_PROFILE = 'C:/Godot/src/godot-cpp/test/build_profile.json'
            API_SOURCE = 'gdextension/extension_api.json'
    -- GODOT_GDEXTENSION_API_FILE = 'C:/Godot/src/godot-cpp/cmake-build-test/extension_api.json'
    -- There are 110 Files to generate
    -- Testing Integration targets are enabled.
    -- Configuring done (0.5s)
    -- Generating done (0.2s)
    -- Build files have been written to: C:/Godot/src/godot-cpp/cmake-build-test
    PS C:\Godot\src\godot-cpp\cmake-build-test> cmake --build . -t godot-cpp.test.template_release
    Change Dir: 'C:/Godot/src/godot-cpp/cmake-build-test'
    
    Run Build Command(s): C:/Users/nicho/AppData/Local/Microsoft/WinGet/Packages/Ninja-build.Ninja_Microsoft.Winget.Source_8wekyb3d8bbwe/ninja.exe -v godot-cpp.test.template_release
    [0/2] "C:\Program Files\CMake\bin\cmake.exe" -P C:\Godot\src\godot-cpp\cmake-build-test\CMakeFiles\VerifyGlobs.cmake
    [1/82] C:\WINDOWS\system32\cmd.exe /C "cd /D C:\Godot\src\godot-cpp && C:\Users\nicho\AppData\Local\Programs\Python\Python313\python.exe -c "from binding_generator import generate_bindings;generate_bindings( api_filepath='C:/Godot/src/godot-cpp/cmake-build-test/extension_api.json', use_template_get_node='True', bits='64', precision='', output_dir='C:/Godot/src/godot-cpp/cmake-build-test')""
    Built-in type config: float_64
    [2/82] C:\PROGRA~1\MICROS~3\2022\COMMUN~1\VC\Tools\MSVC\1442~1.344\bin\Hostx64\x64\cl.exe   /TP -DGDEXTENSION -DNOMINMAX -DTYPED_METHOD_BIND -DWINDOWS_ENABLED -D_HAS_EXCEPTIONS=0 -IC:\Godot\src\godot-cpp\include -IC:\Godot\src\godot-cpp\cmake-build-test\gen\include -IC:\Godot\src\godot-cpp\gdextension -std:c++17 /MT /MP15 /W4 /wd4100 /wd4127 /wd4201 /wd4244 /wd4245 /wd4267 /wd4305 /wd4514 /wd4714 /wd4820 /utf-8 /showIncludes /FoCMakeFiles\godot-cpp.template_release.dir\src\core\memory.cpp.obj /FdCMakeFiles\godot-cpp.template_release.dir\godot-cpp.template_release.pdb /FS -c C:\Godot\src\godot-cpp\src\core\memory.cpp
    Microsoft (R) C/C++ Optimizing Compiler Version 19.42.34436 for x64
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
    <snip>
    
    PS C:\Godot\src\godot-cpp\cmake-build-test> cmake --build . -t godot-cpp.test.template_debug
    Change Dir: 'C:/Godot/src/godot-cpp/cmake-build-test'
    
    Run Build Command(s): C:/Users/nicho/AppData/Local/Microsoft/WinGet/Packages/Ninja-build.Ninja_Microsoft.Winget.Source_8wekyb3d8bbwe/ninja.exe -v godot-cpp.test.template_debug
    [0/2] "C:\Program Files\CMake\bin\cmake.exe" -P C:\Godot\src\godot-cpp\cmake-build-test\CMakeFiles\VerifyGlobs.cmake
    [1/83] C:\PROGRA~1\MICROS~3\2022\COMMUN~1\VC\Tools\MSVC\1442~1.344\bin\Hostx64\x64\cl.exe   /TP -DDEBUG_ENABLED -DDEBUG_METHODS_ENABLED -DGDEXTENSION -DHOT_RELOAD_ENABLED -DNOMINMAX -DTYPED_METHOD_BIND -DWINDOWS_ENABLED -D_HAS_EXCEPTIONS=0 -IC:\Godot\src\godot-cpp\include -IC:\Godot\src\godot-cpp\cmake-build-test\gen\include -IC:\Godot\src\godot-cpp\gdextension -std:c++17 /MT /MP15 /W4 /wd4100 /wd4127 /wd4201 /wd4244 /wd4245 /wd4267 /wd4305 /wd4514 /wd4714 /wd4820 /utf-8 /showIncludes /FoCMakeFiles\godot-cpp.template_debug.dir\src\core\memory.cpp.obj /FdCMakeFiles\godot-cpp.template_debug.dir\godot-cpp.template_debug.pdb /FS -c C:\Godot\src\godot-cpp\src\core\memory.cpp
    Microsoft (R) C/C++ Optimizing Compiler Version 19.42.34436 for x64
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
    <snip>
    
  5. NetroScript commented on Jan 23, 2025

    @NetroScript
    Author

    Ok, I have no idea what is happening with my setup 😅. I tried the same commands again (and also still see the console history where it didn't work, and I removed the entire build folder every time) and now I can't reproduce it anymore.

    So it seems this additional thing with Ninja was some very strange issue on my end, and it is now (for some reason) solved.

  6. enetheru commented on Jan 24, 2025

    @enetheru
    Collaborator

    Thanks, I've marked the PR ready to review.

  7. added a commit that references this issue on Jan 29, 2025
    3c55ca7
  8. added a commit that references this issue on Jun 8, 2026
    78dfc59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions