Browse Source

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.
Sam Edwards 7 years ago
parent
commit
29bc62bf9b

+ 4 - 4
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}"
   )
 

+ 6 - 20
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.

+ 13 - 2
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()

+ 2 - 2
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"
 )