|
2 | 2 | # CMAKE_BUILD_TYPE: Compilation target (Debug or Release defaults to Debug)
|
3 | 3 | #
|
4 | 4 | # godot-cpp cmake arguments
|
5 |
| -# GODOT_HEADERS_DIR: Custom include path for the GDExtension. It should include interface header at this subpath: godot/gdextension_interface.h |
6 |
| -# GODOT_CUSTOM_API_FILE: Custom path for extension_api.json |
| 5 | +# GODOT_GDEXTENSION_DIR: Path to the directory containing GDExtension interface header and API JSON file |
| 6 | +# GODOT_CUSTOM_API_FILE: Path to a custom GDExtension API JSON file (takes precedence over `gdextension_dir`) |
7 | 7 | # FLOAT_TYPE Floating-point precision (32, 64)
|
8 | 8 | #
|
9 | 9 | # Android cmake arguments
|
@@ -57,9 +57,14 @@ if(NOT DEFINED BITS)
|
57 | 57 | endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
58 | 58 | endif()
|
59 | 59 |
|
60 |
| -# Input from user for godot headers and the api file |
61 |
| -set(GODOT_HEADERS_DIR "godot-headers" CACHE STRING "") |
62 |
| -set(GODOT_CUSTOM_API_FILE "godot-headers/extension_api.json" CACHE STRING "") |
| 60 | +# Input from user for GDExtension interface header and the API JSON file |
| 61 | +set(GODOT_GDEXTENSION_DIR "gdextension" CACHE STRING "") |
| 62 | +set(GODOT_CUSTOM_API_FILE "" CACHE STRING "") |
| 63 | + |
| 64 | +set(GODOT_GDEXTENSION_API_FILE "${GODOT_GDEXTENSION_DIR}/extension_api.json") |
| 65 | +if (NOT "${GODOT_CUSTOM_API_FILE}" STREQUAL "") # User-defined override. |
| 66 | + set(GODOT_GDEXTENSION_API_FILE "${GODOT_CUSTOM_API_FILE}") |
| 67 | +endif() |
63 | 68 |
|
64 | 69 | set(GODOT_COMPILE_FLAGS )
|
65 | 70 | set(GODOT_LINKER_FLAGS )
|
@@ -125,16 +130,16 @@ else()
|
125 | 130 | set(GENERATE_BINDING_PARAMETERS "False")
|
126 | 131 | endif()
|
127 | 132 |
|
128 |
| -execute_process(COMMAND "${Python3_EXECUTABLE}" "-c" "import binding_generator; binding_generator.print_file_list(\"${GODOT_CUSTOM_API_FILE}\", \"${CMAKE_CURRENT_BINARY_DIR}\", headers=True, sources=True)" |
| 133 | +execute_process(COMMAND "${Python3_EXECUTABLE}" "-c" "import binding_generator; binding_generator.print_file_list(\"${GODOT_GDEXTENSION_API_FILE}\", \"${CMAKE_CURRENT_BINARY_DIR}\", headers=True, sources=True)" |
129 | 134 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
130 | 135 | OUTPUT_VARIABLE GENERATED_FILES_LIST
|
131 | 136 | )
|
132 | 137 |
|
133 | 138 | add_custom_command(OUTPUT ${GENERATED_FILES_LIST}
|
134 |
| - COMMAND "${Python3_EXECUTABLE}" "-c" "import binding_generator; binding_generator.generate_bindings(\"${GODOT_CUSTOM_API_FILE}\", \"${GENERATE_BINDING_PARAMETERS}\", \"${BITS}\", \"${FLOAT_TYPE_FLAG}\", \"${CMAKE_CURRENT_BINARY_DIR}\")" |
| 139 | + COMMAND "${Python3_EXECUTABLE}" "-c" "import binding_generator; binding_generator.generate_bindings(\"${GODOT_GDEXTENSION_API_FILE}\", \"${GENERATE_BINDING_PARAMETERS}\", \"${BITS}\", \"${FLOAT_TYPE_FLAG}\", \"${CMAKE_CURRENT_BINARY_DIR}\")" |
135 | 140 | VERBATIM
|
136 | 141 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
137 |
| - MAIN_DEPENDENCY ${GODOT_CUSTOM_API_FILE} |
| 142 | + MAIN_DEPENDENCY ${GODOT_GDEXTENSION_API_FILE} |
138 | 143 | DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/binding_generator.py
|
139 | 144 | COMMENT "Generating bindings"
|
140 | 145 | )
|
@@ -173,7 +178,7 @@ target_include_directories(${PROJECT_NAME} PUBLIC
|
173 | 178 | # Put godot headers as SYSTEM PUBLIC to exclude warnings from irrelevant headers
|
174 | 179 | target_include_directories(${PROJECT_NAME}
|
175 | 180 | SYSTEM PUBLIC
|
176 |
| - ${GODOT_HEADERS_DIR} |
| 181 | + ${GODOT_GDEXTENSION_DIR} |
177 | 182 | )
|
178 | 183 |
|
179 | 184 | # Add the compile flags
|
|
0 commit comments