Turn python_callouts.cmake into GodotCPPModule.cmake

Move the find_package for python into it.
Recommend adding godot-cpp/cmake to CMAKE_MODULE_PATH and using include( GodotCPPModule ) to use functions.
Add target_doc_sources function to simplify the addition of documentation to a binary.
This commit is contained in:
Samuel Nicholas
2025-02-09 16:55:25 +10:30
parent f398ebb8ce
commit 35469fd839
4 changed files with 55 additions and 21 deletions

View File

@@ -13,9 +13,6 @@ file( GLOB_RECURSE DOC_XML
CONFIGURE_DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/doc_classes/*.xml" )
set( DOC_DATA_SOURCE "${CMAKE_CURRENT_BINARY_DIR}/src/gen/doc_data.gen.cpp" )
generate_doc_source( "${DOC_DATA_SOURCE}" "${DOC_XML}" )
foreach( TARGET_ALIAS template_debug template_release editor )
set( TARGET_NAME "godot-cpp.test.${TARGET_ALIAS}" )
@@ -30,13 +27,13 @@ foreach( TARGET_ALIAS template_debug template_release editor )
src/tests.h
)
set( OUTPUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/project/bin/" )
# conditionally add doc data to compile output
if( TARGET_ALIAS MATCHES "editor|template_debug" )
target_sources( ${TARGET_NAME} PRIVATE "${DOC_DATA_SOURCE}" )
target_doc_sources( ${TARGET_NAME} ${DOC_XML} )
endif()
set( OUTPUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/project/bin/" )
# Link to godot-cpp target
set( LINK_TARGET "godot-cpp::${TARGET_ALIAS}" )
target_link_libraries( ${TARGET_NAME} PRIVATE ${LINK_TARGET} )