Skip to content

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

@jpxaraujo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis has been identified as a bugconfirmedtopic:buildsystemRelated to the buildsystem or CI setup

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions