From c9cddb8d922568f3b1a58fac382f1eb4757e0052 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 10 Aug 2024 16:15:58 +0200 Subject: [PATCH] CMake: Stop building interrogate from tree Instead, either build it externally (BUILD_INTERROGATE) or accept INTERROGATE_EXECUTABLE / INTERROGATE_MODULE_EXECUTABLE settings --- cmake/macros/Interrogate.cmake | 8 +-- dtool/CMakeLists.txt | 2 - dtool/Config.cmake | 77 ++++++++++++++++++++++++-- dtool/src/interrogatedb/CMakeLists.txt | 4 +- 4 files changed, 77 insertions(+), 14 deletions(-) diff --git a/cmake/macros/Interrogate.cmake b/cmake/macros/Interrogate.cmake index eea12f9568..5f26cebbe9 100644 --- a/cmake/macros/Interrogate.cmake +++ b/cmake/macros/Interrogate.cmake @@ -257,7 +257,7 @@ function(interrogate_sources target output database language_flags) make_directory "${output_directory}" COMMAND ${CMAKE_COMMAND} -E make_directory "${database_directory}" - COMMAND host_interrogate + COMMAND interrogate -oc "${output}" -od "${database}" -srcdir "${srcdir}" @@ -272,7 +272,7 @@ function(interrogate_sources target output database language_flags) ${include_flags} ${scan_sources} - DEPENDS host_interrogate ${sources} ${extensions} ${nfiles} + DEPENDS interrogate ${sources} ${extensions} ${nfiles} COMMENT "Interrogating ${target}") # Propagate the target's compile definitions to the output file @@ -362,13 +362,13 @@ function(add_python_module module) OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${PANDA_CFG_INTDIR}/${module}_module.cxx" COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/${PANDA_CFG_INTDIR}" - COMMAND host_interrogate_module + COMMAND interrogate_module -oc "${CMAKE_CURRENT_BINARY_DIR}/${PANDA_CFG_INTDIR}/${module}_module.cxx" -module ${module} -library ${modname} ${import_flags} ${INTERROGATE_MODULE_OPTIONS} ${IMOD_FLAGS} ${infiles_rel} - DEPENDS host_interrogate_module ${infiles_abs} + DEPENDS interrogate_module ${infiles_abs} COMMENT "Generating module ${module}") # CMake chokes on ${CMAKE_CFG_INTDIR} in source paths when unity builds are diff --git a/dtool/CMakeLists.txt b/dtool/CMakeLists.txt index 62308bd980..36e93a0be3 100644 --- a/dtool/CMakeLists.txt +++ b/dtool/CMakeLists.txt @@ -2,11 +2,9 @@ include(LocalSetup.cmake) # Include dtool source directories -add_subdirectory(src/cppparser) add_subdirectory(src/dconfig) add_subdirectory(src/dtoolbase) add_subdirectory(src/dtoolutil) -add_subdirectory(src/interrogate) add_subdirectory(src/interrogatedb) add_subdirectory(src/prc) diff --git a/dtool/Config.cmake b/dtool/Config.cmake index d269b62e3e..771e105be5 100644 --- a/dtool/Config.cmake +++ b/dtool/Config.cmake @@ -221,12 +221,6 @@ mark_as_advanced(DEFAULT_PRC_DIR PRC_DIR_ENVVARS PRC_PATH_ENVVARS # The following options relate to interrogate, the tool that is # used to generate bindings for non-C++ languages. -option(WANT_INTERROGATE - "Do you want to include Interrogate in the installation? This -program reads C++ source files and generates bindings for another -language. If you won't be building interfaces for other languages, -you don't need the program." ON) - cmake_dependent_option(INTERROGATE_PYTHON_INTERFACE "Do you want to generate a Python-callable interrogate interface? This is only necessary if you plan to make calls into Panda from a @@ -249,8 +243,79 @@ option(INTERROGATE_VERBOSE "Set this if you would like interrogate to generate advanced debugging information." OFF) +set(_default_build_interrogate OFF) +if (INTERROGATE_C_INTERFACE OR INTERROGATE_PYTHON_INTERFACE) + set(_default_build_interrogate ON) +endif() + +option(BUILD_INTERROGATE + "Do you want to build interrogate from source? This is necessary +if you wish to build Python or other bindings around Panda3D's C++ +interface. Set this to false if you already have a compatible +version of interrogate installed." ${_default_build_interrogate}) + mark_as_advanced(INTERROGATE_OPTIONS) +if(BUILD_INTERROGATE) + include(ExternalProject) + + set(_interrogate_dir "${PROJECT_BINARY_DIR}/interrogate") + + ExternalProject_Add( + panda3d-interrogate + + GIT_REPOSITORY https://github.com/panda3d/interrogate.git + GIT_TAG e297384b30f1eae8ab839ec096fc3bb6bdb3edeb + + PREFIX ${_interrogate_dir} + CMAKE_ARGS + -DHAVE_PYTHON=OFF + -DBUILD_SHARED_LIBS=OFF + -DCMAKE_INSTALL_PREFIX:PATH= + + EXCLUDE_FROM_ALL ON + BUILD_BYPRODUCTS "${_interrogate_dir}/bin/interrogate" + "${_interrogate_dir}/bin/interrogate_module" + ) + + add_executable(interrogate IMPORTED GLOBAL) + add_dependencies(interrogate panda3d-interrogate) + set_target_properties(interrogate PROPERTIES IMPORTED_LOCATION "${_interrogate_dir}/bin/interrogate") + + add_executable(interrogate_module IMPORTED GLOBAL) + add_dependencies(interrogate_module panda3d-interrogate) + set_target_properties(interrogate_module PROPERTIES IMPORTED_LOCATION "${_interrogate_dir}/bin/interrogate_module") + +else() + find_program(INTERROGATE_EXECUTABLE interrogate) + find_program(INTERROGATE_MODULE_EXECUTABLE interrogate_module) + + add_executable(interrogate IMPORTED GLOBAL) + if(INTERROGATE_EXECUTABLE) + set_target_properties(interrogate PROPERTIES + IMPORTED_LOCATION "${INTERROGATE_EXECUTABLE}") + + elseif(INTERROGATE_PYTHON_INTERFACE OR INTERROGATE_C_INTERFACE) + message(FATAL_ERROR + "Requested interrogate bindings, but interrogate not found. Set " + "BUILD_INTERROGATE to build interrogate from source, or set " + "INTERROGATE_EXECUTABLE to the location of this tool.") + endif() + + add_executable(interrogate_module IMPORTED GLOBAL) + if(INTERROGATE_MODULE_EXECUTABLE) + set_target_properties(interrogate_module PROPERTIES + IMPORTED_LOCATION "${INTERROGATE_MODULE_EXECUTABLE}") + + elseif(INTERROGATE_PYTHON_INTERFACE) + message(FATAL_ERROR + "Requested interrogate bindings, but interrogate not found. Set " + "BUILD_INTERROGATE to build interrogate from source, or set " + "INTERROGATE_MODULE_EXECUTABLE to the location of this tool.") + endif() + +endif() + # # The following options have to do with optional debugging features. # diff --git a/dtool/src/interrogatedb/CMakeLists.txt b/dtool/src/interrogatedb/CMakeLists.txt index adadd5a24b..4004680279 100644 --- a/dtool/src/interrogatedb/CMakeLists.txt +++ b/dtool/src/interrogatedb/CMakeLists.txt @@ -58,7 +58,7 @@ endif() add_custom_command( OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/interrogatedb_module.cxx" - COMMAND host_interrogate + COMMAND interrogate -D EXPCL_INTERROGATEDB= -nodb -python -promiscuous -module panda3d.interrogatedb @@ -68,7 +68,7 @@ add_custom_command( -oc "${CMAKE_CURRENT_BINARY_DIR}/interrogatedb_module.cxx" ${P3INTERROGATEDB_IGATE} - DEPENDS host_interrogate ${P3INTERROGATEDB_IGATE} + DEPENDS interrogate ${P3INTERROGATEDB_IGATE} COMMENT "Interrogating interrogatedb") add_python_target(panda3d.interrogatedb