Skip to content

CMake completely broken when trying to migrate from 4.3 to 4.4 #1739

Closed

Description

@jpxaraujo

Godot version

4.4

godot-cpp version

4.4

System information

Linux, intel core i7-12800h

Issue description

4.4 completely broke my project's CMake, I have the following setup:

ADD_SUBDIRECTORY(godot-cpp) # godot-cpp as a submodule

...

TARGET_LINK_LIBRARIES(${PROJECT_NAME} PRIVATE
    godot-cpp
)

I use warnings as errors and, with 4.4, my project is picking all the warnings that godot-cpp has, which is not happening in 4.3.

It seems the godot-cpp's CMake has global compile options that are affecting other dependencies, which was not happening before. I think compile options should be private for each project/dependency.

It also recompiles the entire godot-cpp every time I do a modification, which was also not happening in 4.3.

Steps to reproduce

Create a CMake project, clone godot-cpp and add it as a subdirectory.

CMAKE_MINIMUM_REQUIRED(VERSION 3.5)

PROJECT(godot-4.4-test)

ADD_SUBDIRECTORY(godot-cpp)

FILE(GLOB_RECURSE SRCS
    src/*
)

ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})

TARGET_LINK_LIBRARIES(${PROJECT_NAME} PRIVATE
    godot-cpp
)

SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES
    CXX_STANDARD 23
)

TARGET_COMPILE_OPTIONS(${PROJECT_NAME} PRIVATE
    -pipe
    -fexceptions
    -Wall
    -Wextra
    -Wpedantic
    -Werror
)

Then just add a src/test.cpp and include something from godot-cpp with:

#include <godot_cpp/variant/utility_functions.hpp>

And compile it with:

cmake -S . -B build && cd build && make -j $(nproc)

Minimal reproduction project

godot-4.4-test.zip

You just have to git clone the godot-cpp inside the project directory and changes from this PR:
#1733

Activity

  1. enetheru commented on Mar 10, 2025

    @enetheru
    Collaborator

    I have a PR in the wings for changing options to PRIVATE. I'll clean it up and submit.

    Why #1733 ? The PUBLIC/PRIVATE thing has been waiting to be fixed for a while.

  2. added
    bug
    topic:buildsystem
    on Mar 10, 2025
  3. added theissue type on Mar 10, 2025
  4. enetheru commented on Mar 10, 2025

    @enetheru
    Collaborator

    here is the PR: #1740

  5. jpxaraujo commented on Mar 10, 2025

    @jpxaraujo
    Author

    I have a PR in the wings for changing options to PRIVATE. I'll clean it up and submit.

    Why #1733 ? The PUBLIC/PRIVATE thing has been waiting to be fixed for a while.

    I tested with this PR and it's still failing.
    Will test with #1740

  6. enetheru commented on Mar 11, 2025

    @enetheru
    Collaborator

    I think I see the issue with the re-building, its related to how the sources are generate with the add_custom_target which is considered always out of date.

    I will research how to do it without breaking the XCode dependency chain.

  7. enetheru commented on Mar 11, 2025

    @enetheru
    Collaborator

    Ok I finally found a way around the XCode dependency chain issue. and as always It's simpler than expected.
    here's my branch which I used for testing
    https://github.com/enetheru/godot-cpp/tree/re-build

    I have a bunch of PR's lined up already, I'll see if I can re-work the XCode one since its tightly related to the changes made in there.

  8. enetheru commented on Mar 11, 2025

    @enetheru
    Collaborator

    I've re-worked the XCode change to solve the re-building one since it goes hand in hand with the changes I needed to make there.
    If these all pass review and merge, it will solve the re-building issue.

  9. jpxaraujo commented on Mar 16, 2025

    @jpxaraujo
    Author

    I don't know why this was closed, it's not totally fixed.
    I made an example repository here:
    https://github.com/jpxaraujo/godot-4.4-test
    If you change the godot-cpp branch to godot-4.3-stable and run the compile.sh, it works.
    But if you change to the master branch, it still fails due to propagation of warnings.
    @enetheru @dsnopek

  10. enetheru commented on Mar 17, 2025

    @enetheru
    Collaborator

    The timing of the 4.4-stable tagging and branching was a little unfortunate as the CMake interface needed changing which was merged in #1733 which I am going to petition to have cherry picked for 4.4 branch and have the tag updated asap. I recommend using master at least until #1733 gets cherry picked.

  11. jpxaraujo commented on Mar 17, 2025

    @jpxaraujo
    Author

    But it still fails in master. You can verify it with my example repo.

  12. enetheru commented on Mar 17, 2025

    @enetheru
    Collaborator

    But it still fails in master. You can verify it with my example repo.

    Sorry I just woke up, still groggy. I'll test it now.

  13. enetheru commented on Mar 17, 2025

    @enetheru
    Collaborator

    Try this please:

    ADD_SUBDIRECTORY( godot-cpp SYSTEM )

    CMake thinks godot-cpp is your project and will assume you want to know about any warnings raised from includes and such.
    Marking godot-cpp as SYSTEM changes the expression of the flags for the compiler so that it wont raise any warnings.

    I can do a fresh configure/build with this change, where before it would error due to warnings raised from including godot-cpp headers.

  14. jpxaraujo commented on Mar 17, 2025

    @jpxaraujo
    Author

    Thank you @enetheru! It works! I didn't know about the SYSTEM thing in CMake. Sorry for the inconvenience.

  15. enetheru commented on Mar 17, 2025

    @enetheru
    Collaborator

    Sorry for the inconvenience.

    Not at all, I'm the one making everyone have to adjust, so thank you for working with me.

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

    bugconfirmedtopic:buildsystem

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions