Skip to content

CMake: XCode dependency chain fixes #1730

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

Merged
merged 1 commit into from
Mar 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions cmake/GodotCPPModule.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ function(
DEPENDS ${godot-cpp_SOURCE_DIR}/binding_generator.py
COMMENT "Generating bindings"
)
add_custom_target(generate_bindings DEPENDS ${GENERATED_FILES_LIST})
set_target_properties(generate_bindings PROPERTIES FOLDER "godot-cpp")
endfunction()

#[[ Generate doc_data.cpp
Expand Down Expand Up @@ -145,19 +147,19 @@ function(generate_doc_source OUTPUT_PATH SOURCES)
COMMAND "${Python3_EXECUTABLE}" "-c" "${PYTHON_SCRIPT}"
VERBATIM
WORKING_DIRECTORY "${godot-cpp_SOURCE_DIR}"
DEPENDS
DEPENDS #
"${godot-cpp_SOURCE_DIR}/doc_source_generator.py"
"${SOURCES}"
COMMENT "Generating: ${OUTPUT_PATH}"
)
add_custom_target(generate_doc_source DEPENDS "${OUTPUT_PATH}")
set_target_properties(generate_doc_source PROPERTIES FOLDER "godot-cpp")
endfunction()

#[[ target_doc_sources
A simpler interface to add xml files as doc source to a output target.
TARGET: The gdexension library target
SOURCES: a list of xml files to use for source generation and inclusion.
This function also adds a doc_gen target to test source generation.]]
SOURCES: a list of xml files to use for source generation and inclusion.]]
function(target_doc_sources TARGET SOURCES)
# set the generated file name
set(DOC_SOURCE_FILE "${CMAKE_CURRENT_BINARY_DIR}/gen/doc_source.cpp")
Expand All @@ -169,11 +171,6 @@ function(target_doc_sources TARGET SOURCES)
# Add DOC_SOURCE_FILE as a dependency to TARGET
target_sources(${TARGET} PRIVATE "${DOC_SOURCE_FILE}")

# Create a dummy target that depends on the source so that users can
# test the file generation task.
if(TARGET doc_gen)
else()
add_custom_target(doc_gen)
endif()
target_sources(doc_gen PRIVATE "${DOC_SOURCE_FILE}")
# Without adding this dependency to the doc_source_generator, XCode will complain.
add_dependencies(${TARGET} generate_doc_source)
endfunction()
6 changes: 3 additions & 3 deletions cmake/godotcpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,6 @@ function(godotcpp_generate)
"${CMAKE_CURRENT_BINARY_DIR}"
)

add_custom_target(godot-cpp.generate_bindings DEPENDS ${GENERATED_FILES_LIST})
set_target_properties(godot-cpp.generate_bindings PROPERTIES FOLDER "godot-cpp")

### Platform is derived from the toolchain target
# See GeneratorExpressions PLATFORM_ID and CMAKE_SYSTEM_NAME
string(
Expand Down Expand Up @@ -332,6 +329,9 @@ function(godotcpp_generate)
# the godot-cpp.* library targets
add_library(godot-cpp STATIC)

# Without adding this dependency to the binding generator, XCode will complain.
add_dependencies(godot-cpp generate_bindings)

# Added for backwards compatibility with prior cmake solution so that builds dont immediately break
# from a missing target.
add_library(godot::cpp ALIAS godot-cpp)
Expand Down
10 changes: 2 additions & 8 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@ The Test target used to validate changes in the GitHub CI.

message(STATUS "Testing Integration targets are enabled.")

# Generate Doc Data
file(GLOB_RECURSE DOC_XML LIST_DIRECTORIES NO CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/doc_classes/*.xml")

set(DOC_SOURCE_FILE "${CMAKE_CURRENT_BINARY_DIR}/gen/doc_source.cpp")

generate_doc_source( "${DOC_SOURCE_FILE}" ${DOC_XML} )

set(TARGET_NAME "godot-cpp-test")

add_library(${TARGET_NAME} SHARED EXCLUDE_FROM_ALL)
Expand All @@ -25,7 +18,8 @@ target_sources(

# conditionally add doc data to compile output
if(GODOTCPP_TARGET MATCHES "editor|template_debug")
target_sources(${TARGET_NAME} PRIVATE "${DOC_SOURCE_FILE}")
file(GLOB_RECURSE DOC_XML LIST_DIRECTORIES NO CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/doc_classes/*.xml")
target_doc_sources( ${TARGET_NAME} ${DOC_XML} )
endif()

set(OUTPUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/project/bin/")
Expand Down