Skip to content

Commit f83f364

Browse files
committed
CMake: XCode dependency chain fixes - remastered
When attempting to generate XCode projects it would fail due to the target dependency chain not meeting expectations. This PR, adds the required dependency infomation so that the XCode generator works.
1 parent 6f981b3 commit f83f364

File tree

3 files changed

+12
-21
lines changed

3 files changed

+12
-21
lines changed

cmake/GodotCPPModule.cmake

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ function(
116116
DEPENDS ${godot-cpp_SOURCE_DIR}/binding_generator.py
117117
COMMENT "Generating bindings"
118118
)
119+
add_custom_target(generate_bindings DEPENDS ${GENERATED_FILES_LIST})
120+
set_target_properties(generate_bindings PROPERTIES FOLDER "godot-cpp")
119121
endfunction()
120122

121123
#[[ Generate doc_data.cpp
@@ -145,19 +147,19 @@ function(generate_doc_source OUTPUT_PATH SOURCES)
145147
COMMAND "${Python3_EXECUTABLE}" "-c" "${PYTHON_SCRIPT}"
146148
VERBATIM
147149
WORKING_DIRECTORY "${godot-cpp_SOURCE_DIR}"
148-
DEPENDS
149150
DEPENDS #
150151
"${godot-cpp_SOURCE_DIR}/doc_source_generator.py"
151152
"${SOURCES}"
152153
COMMENT "Generating: ${OUTPUT_PATH}"
153154
)
155+
add_custom_target(generate_doc_source DEPENDS "${OUTPUT_PATH}")
156+
set_target_properties(generate_doc_source PROPERTIES FOLDER "godot-cpp")
154157
endfunction()
155158

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

172-
# Create a dummy target that depends on the source so that users can
173-
# test the file generation task.
174-
if(TARGET doc_gen)
175-
else()
176-
add_custom_target(doc_gen)
177-
endif()
178-
target_sources(doc_gen PRIVATE "${DOC_SOURCE_FILE}")
174+
# Without adding this dependency to the doc_source_generator, XCode will complain.
175+
add_dependencies(${TARGET} generate_doc_source)
179176
endfunction()

cmake/godotcpp.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,6 @@ function(godotcpp_generate)
271271
"${CMAKE_CURRENT_BINARY_DIR}"
272272
)
273273

274-
add_custom_target(godot-cpp.generate_bindings DEPENDS ${GENERATED_FILES_LIST})
275-
set_target_properties(godot-cpp.generate_bindings PROPERTIES FOLDER "godot-cpp")
276-
277274
### Platform is derived from the toolchain target
278275
# See GeneratorExpressions PLATFORM_ID and CMAKE_SYSTEM_NAME
279276
string(
@@ -332,6 +329,9 @@ function(godotcpp_generate)
332329
# the godot-cpp.* library targets
333330
add_library(godot-cpp STATIC)
334331

332+
# Without adding this dependency to the binding generator, XCode will complain.
333+
add_dependencies(godot-cpp generate_bindings)
334+
335335
# Added for backwards compatibility with prior cmake solution so that builds dont immediately break
336336
# from a missing target.
337337
add_library(godot::cpp ALIAS godot-cpp)

test/CMakeLists.txt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@ The Test target used to validate changes in the GitHub CI.
77

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

10-
# Generate Doc Data
11-
file(GLOB_RECURSE DOC_XML LIST_DIRECTORIES NO CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/doc_classes/*.xml")
12-
13-
set(DOC_SOURCE_FILE "${CMAKE_CURRENT_BINARY_DIR}/gen/doc_source.cpp")
14-
15-
generate_doc_source( "${DOC_SOURCE_FILE}" ${DOC_XML} )
16-
1710
set(TARGET_NAME "godot-cpp-test")
1811

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

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

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

0 commit comments

Comments
 (0)