CMake: Refactor interrogate.cmake a little

In particular, rely on INTERROGATE_PYTHON_INTERFACE, not
HAVE_PYTHON AND HAVE_INTERROGATE.
This commit is contained in:
Sam Edwards 2018-02-11 12:48:17 -07:00
parent 897e3b9e5b
commit f8c63dbe2b

View File

@ -8,7 +8,7 @@
# add_python_module(module [lib1 [lib2 ...]]) # add_python_module(module [lib1 [lib2 ...]])
# #
set(IGATE_FLAGS -DCPPPARSER -D__cplusplus -Dvolatile -Dmutable -python-native) set(IGATE_FLAGS -DCPPPARSER -D__cplusplus -Dvolatile -Dmutable)
# In addition, Interrogate needs to know if this is a 64-bit build: # In addition, Interrogate needs to know if this is a 64-bit build:
include(CheckTypeSize) include(CheckTypeSize)
@ -48,7 +48,6 @@ set(ALL_INTERROGATE_MODULES CACHE INTERNAL "Internal variable")
# target are added. # target are added.
# #
function(target_interrogate target) function(target_interrogate target)
if(HAVE_PYTHON AND HAVE_INTERROGATE)
set(sources) set(sources)
set(extensions) set(extensions)
set(want_all OFF) set(want_all OFF)
@ -102,11 +101,10 @@ function(target_interrogate target)
# an IGATE_ prefix. # an IGATE_ prefix.
set_target_properties("${target}" PROPERTIES TARGET_SRCDIR set_target_properties("${target}" PROPERTIES TARGET_SRCDIR
"${CMAKE_CURRENT_SOURCE_DIR}") "${CMAKE_CURRENT_SOURCE_DIR}")
endif()
endfunction(target_interrogate) endfunction(target_interrogate)
# #
# Function: interrogate_sources(target output database module) # Function: interrogate_sources(target output database language_flags module)
# #
# This function actually runs a component-level interrogation against 'target'. # This function actually runs a component-level interrogation against 'target'.
# It generates the outfile.cxx (output) and dbfile.in (database) files, which # It generates the outfile.cxx (output) and dbfile.in (database) files, which
@ -116,8 +114,7 @@ endfunction(target_interrogate)
# The target must first have had sources selected with target_interrogate. # The target must first have had sources selected with target_interrogate.
# Failure to do so will result in an error. # Failure to do so will result in an error.
# #
function(interrogate_sources target output database module) function(interrogate_sources target output database language_flags)
if(HAVE_PYTHON AND HAVE_INTERROGATE)
get_target_property(sources "${target}" IGATE_SOURCES) get_target_property(sources "${target}" IGATE_SOURCES)
get_target_property(extensions "${target}" IGATE_EXTENSIONS) get_target_property(extensions "${target}" IGATE_EXTENSIONS)
@ -200,9 +197,10 @@ function(interrogate_sources target output database module)
-oc "${output}" -oc "${output}"
-od "${database}" -od "${database}"
-srcdir "${srcdir}" -srcdir "${srcdir}"
-module ${module} -library ${target} -library ${target}
${INTERROGATE_OPTIONS} ${INTERROGATE_OPTIONS}
${IGATE_FLAGS} ${IGATE_FLAGS}
${language_flags}
${define_flags} ${define_flags}
-S "${PROJECT_BINARY_DIR}/include" -S "${PROJECT_BINARY_DIR}/include"
-S "${PROJECT_SOURCE_DIR}/dtool/src/parser-inc" -S "${PROJECT_SOURCE_DIR}/dtool/src/parser-inc"
@ -213,7 +211,6 @@ function(interrogate_sources target output database module)
DEPENDS interrogate ${sources} ${extensions} ${nfiles} DEPENDS interrogate ${sources} ${extensions} ${nfiles}
COMMENT "Interrogating ${target}" COMMENT "Interrogating ${target}"
) )
endif()
endfunction(interrogate_sources) endfunction(interrogate_sources)
# #
@ -223,7 +220,7 @@ endfunction(interrogate_sources)
# listed before. # listed before.
# #
function(add_python_module module) function(add_python_module module)
if(HAVE_PYTHON AND HAVE_INTERROGATE) if(INTERROGATE_PYTHON_INTERFACE)
set(targets) set(targets)
set(link_targets) set(link_targets)
set(infiles) set(infiles)
@ -245,13 +242,11 @@ function(add_python_module module)
endif() endif()
foreach(target ${targets}) foreach(target ${targets})
interrogate_sources(${target} "${target}_igate.cxx" "${target}.in" "${module}") interrogate_sources(${target} "${target}_igate.cxx" "${target}.in"
-python-native -module "panda3d.${module}")
get_target_property(target_extensions "${target}" IGATE_EXTENSIONS) get_target_property(target_extensions "${target}" IGATE_EXTENSIONS)
list(APPEND infiles "${target}.in") list(APPEND infiles "${target}.in")
list(APPEND sources "${target}_igate.cxx" ${target_extensions}) list(APPEND sources "${target}_igate.cxx" ${target_extensions})
#get_target_property(target_links "${target}" LINK_LIBRARIES)
#target_link_libraries(${target}_igate ${target_links})
endforeach(target) endforeach(target)
add_custom_command( add_custom_command(