From 29bc62bf9bdb5531f32e53c6ba665a8ea68ca579 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Wed, 13 Jun 2018 18:51:12 -0600 Subject: [PATCH] CMake: Alias Interrogate This allows us to have a different name for Interrogate on the host vs. Interrogate on the target platform, which facilitates cross-compiling. --- cmake/macros/Interrogate.cmake | 8 ++++---- dtool/Config.cmake | 26 ++++++-------------------- dtool/src/interrogate/CMakeLists.txt | 15 +++++++++++++-- dtool/src/interrogatedb/CMakeLists.txt | 4 ++-- 4 files changed, 25 insertions(+), 28 deletions(-) diff --git a/cmake/macros/Interrogate.cmake b/cmake/macros/Interrogate.cmake index c45f99a950..5cbecfb626 100644 --- a/cmake/macros/Interrogate.cmake +++ b/cmake/macros/Interrogate.cmake @@ -208,7 +208,7 @@ function(interrogate_sources target output database language_flags) add_custom_command( OUTPUT "${output}" "${database}" - COMMAND interrogate + COMMAND host_interrogate -oc "${output}" -od "${database}" -srcdir "${srcdir}" @@ -223,7 +223,7 @@ function(interrogate_sources target output database language_flags) ${include_flags} ${scan_sources} ${extensions} - DEPENDS interrogate ${sources} ${extensions} ${nfiles} + DEPENDS host_interrogate ${sources} ${extensions} ${nfiles} COMMENT "Interrogating ${target}" ) endfunction(interrogate_sources) @@ -279,13 +279,13 @@ function(add_python_module module) add_custom_command( OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${module}_module.cxx" - COMMAND interrogate_module + COMMAND host_interrogate_module -oc "${CMAKE_CURRENT_BINARY_DIR}/${module}_module.cxx" -module ${module} -library ${module} ${import_flags} ${INTERROGATE_MODULE_OPTIONS} ${IMOD_FLAGS} ${infiles} - DEPENDS interrogate_module ${infiles} + DEPENDS host_interrogate_module ${infiles} COMMENT "Generating module ${module}" ) diff --git a/dtool/Config.cmake b/dtool/Config.cmake index 06e8a0448b..5e1ddaa55b 100644 --- a/dtool/Config.cmake +++ b/dtool/Config.cmake @@ -257,6 +257,12 @@ mark_as_advanced(HAVE_P3D_RTDIST PANDA_PACKAGE_VERSION PANDA_PACKAGE_HOST) # 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 @@ -270,12 +276,6 @@ a C calling convention. It should be useful for most other kinds of scripting language; the VR Studio used to use this to make calls into Panda from Squeak." OFF) -option(HAVE_INTERROGATE - "Do you even want to build interrogate at all? This is the program -that reads our C++ source files and generates one of the above -interfaces. If you won't be building the interfaces, you don't -need the program." ON) - set(INTERROGATE_OPTIONS "-fnames;-string;-refcount;-assert" CACHE STRING "What additional options should be passed to interrogate when generating either of the above two interfaces? Generally, you @@ -285,22 +285,8 @@ option(INTERROGATE_VERBOSE "Set this if you would like interrogate to generate advanced debugging information." OFF) -set(INTERROGATE "interrogate" CACHE STRING - "What's the name of the interrogate binary to run? The default -specified is the one that is built as part of DTOOL. If you have a -prebuilt binary standing by (for instance, if you are cross-compiling -and cannot run the built version), specify its name instead.") - -set(INTERROGATE_MODULE "interrogate_module" CACHE STRING - "Same as INTERROGATE, except for the interrogate_module binary.") - mark_as_advanced(INTERROGATE_OPTIONS) -if(NOT CMAKE_CROSSCOMPILING) - mark_as_advanced(INTERROGATE INTERROGATE_MODULE) -endif() - - # # The following options have to do with the memory allocation system # that will be used by Panda3D. diff --git a/dtool/src/interrogate/CMakeLists.txt b/dtool/src/interrogate/CMakeLists.txt index 79f7b91c20..cf54d19481 100644 --- a/dtool/src/interrogate/CMakeLists.txt +++ b/dtool/src/interrogate/CMakeLists.txt @@ -54,9 +54,20 @@ composite_sources(interrogate INTERROGATE_SOURCES) add_executable(interrogate ${INTERROGATE_HEADERS} ${INTERROGATE_SOURCES}) target_link_libraries(interrogate p3cppParser p3dtoolconfig p3pystub ${_OPENSSL_LIBRARIES}) -install(TARGETS interrogate DESTINATION bin) add_executable(interrogate_module interrogate_module.cxx) target_link_libraries(interrogate_module p3cppParser p3dtoolconfig p3pystub ${_OPENSSL_LIBRARIES}) -install(TARGETS interrogate_module DESTINATION bin) + +if(NOT CMAKE_CROSSCOMPILING) + add_executable(host_interrogate ALIAS interrogate) + add_executable(host_interrogate_module ALIAS interrogate_module) +endif() + +if(WANT_INTERROGATE) + install(TARGETS interrogate DESTINATION bin) + install(TARGETS interrogate_module DESTINATION bin) +else() + set_target_properties(interrogate interrogate_module + PROPERTIES EXCLUDE_FROM_ALL ON) +endif() diff --git a/dtool/src/interrogatedb/CMakeLists.txt b/dtool/src/interrogatedb/CMakeLists.txt index 736178008c..c4d02f25a0 100644 --- a/dtool/src/interrogatedb/CMakeLists.txt +++ b/dtool/src/interrogatedb/CMakeLists.txt @@ -52,7 +52,7 @@ endif() add_custom_command( OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/interrogatedb_module.cxx" - COMMAND interrogate + COMMAND host_interrogate -D EXPCL_INTERROGATEDB= -nodb -python -promiscuous -module panda3d.interrogatedb @@ -61,7 +61,7 @@ add_custom_command( -srcdir "${CMAKE_CURRENT_SOURCE_DIR}" -oc "${CMAKE_CURRENT_BINARY_DIR}/interrogatedb_module.cxx" ${P3INTERROGATEDB_IGATE} - DEPENDS interrogate ${P3INTERROGATEDB_IGATE} + DEPENDS host_interrogate ${P3INTERROGATEDB_IGATE} COMMENT "Interrogating interrogatedb" )