From 5314183bba3785c21d33fb0fe0f135887367985c Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 30 Mar 2014 04:17:16 -0600 Subject: [PATCH 1/5] CMake: Don't compile Interrogate extensions into the component libraries. --- panda/src/display/CMakeLists.txt | 4 ++-- panda/src/egg/CMakeLists.txt | 4 ++-- panda/src/express/CMakeLists.txt | 4 ++-- panda/src/ode/CMakeLists.txt | 2 +- panda/src/pgraph/CMakeLists.txt | 4 ++-- panda/src/pnmimage/CMakeLists.txt | 4 ++-- panda/src/putil/CMakeLists.txt | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/panda/src/display/CMakeLists.txt b/panda/src/display/CMakeLists.txt index 2f0004a5ce..2b37249258 100644 --- a/panda/src/display/CMakeLists.txt +++ b/panda/src/display/CMakeLists.txt @@ -97,9 +97,9 @@ if(APPLE) endif() composite_sources(p3display P3DISPLAY_SOURCES) -add_library(p3display ${P3DISPLAY_HEADERS} ${P3DISPLAY_SOURCES} ${P3DISPLAY_IGATEEXT}) +add_library(p3display ${P3DISPLAY_HEADERS} ${P3DISPLAY_SOURCES}) target_link_libraries(p3display p3cull p3pgraphnodes) -target_interrogate(p3display ALL) +target_interrogate(p3display ALL ${P3DISPLAY_IGATEEXT}) install(TARGETS p3display DESTINATION lib) diff --git a/panda/src/egg/CMakeLists.txt b/panda/src/egg/CMakeLists.txt index 66c67b1ae5..dec290f287 100644 --- a/panda/src/egg/CMakeLists.txt +++ b/panda/src/egg/CMakeLists.txt @@ -99,9 +99,9 @@ if(HAVE_EGG) lexer.cxx) composite_sources(p3egg P3EGG_SOURCES) - add_library(p3egg ${P3EGG_HEADERS} ${P3EGG_SOURCES} ${P3EGG_IGATEEXT} ${P3EGG_PARSER_SOURCES}) + add_library(p3egg ${P3EGG_HEADERS} ${P3EGG_SOURCES} ${P3EGG_PARSER_SOURCES}) target_link_libraries(p3egg p3prc p3pandabase p3express p3linmath p3mathutil) - target_interrogate(p3egg ${P3EGG_HEADERS} ${P3EGG_SOURCES} eggGroupNode_ext.h) + target_interrogate(p3egg ${P3EGG_HEADERS} ${P3EGG_SOURCES} ${P3EGG_IGATEEXT}) install(TARGETS p3egg DESTINATION lib) endif() diff --git a/panda/src/express/CMakeLists.txt b/panda/src/express/CMakeLists.txt index dc6ec21b51..855126cd45 100644 --- a/panda/src/express/CMakeLists.txt +++ b/panda/src/express/CMakeLists.txt @@ -133,10 +133,10 @@ set(P3EXPRESS_IGATEEXT composite_sources(p3express P3EXPRESS_SOURCES) -add_library(p3express ${P3EXPRESS_SOURCES} ${P3EXPRESS_HEADERS} ${P3EXPRESS_IGATEEXT}) +add_library(p3express ${P3EXPRESS_SOURCES} ${P3EXPRESS_HEADERS}) target_link_libraries(p3express p3pandabase p3dtool p3dtoolconfig ${_TAR_LIBRARY} ${_ZLIB_LIBRARY}) -target_interrogate(p3express ALL) +target_interrogate(p3express ALL ${P3EXPRESS_IGATEEXT}) if(WIN32) target_link_libraries(p3express advapi32.lib ws2_32.lib) diff --git a/panda/src/ode/CMakeLists.txt b/panda/src/ode/CMakeLists.txt index 5405857def..da02eac238 100755 --- a/panda/src/ode/CMakeLists.txt +++ b/panda/src/ode/CMakeLists.txt @@ -81,7 +81,7 @@ if(HAVE_ODE) list(REMOVE_ITEM P3ODE_IGATE_SOURCES "odeHelperStructs.h") composite_sources(p3ode P3ODE_SOURCES) - add_library(p3ode ${P3ODE_SOURCES} ${P3ODE_HEADERS} ${P3ODE_IGATEEXT}) + add_library(p3ode ${P3ODE_SOURCES} ${P3ODE_HEADERS}) set_target_properties(p3ode PROPERTIES COMPILE_DEFINITIONS dSINGLE) target_link_libraries(p3ode p3pgraph p3physics ${ODE_LIBRARY}) target_interrogate(p3ode ${P3ODE_IGATE_SOURCES} ${P3ODE_IGATEEXT}) diff --git a/panda/src/pgraph/CMakeLists.txt b/panda/src/pgraph/CMakeLists.txt index 2c66887118..8eca8b5c7b 100644 --- a/panda/src/pgraph/CMakeLists.txt +++ b/panda/src/pgraph/CMakeLists.txt @@ -206,9 +206,9 @@ set(P3PGRAPH_IGATEEXT ) composite_sources(p3pgraph P3PGRAPH_SOURCES) -add_library(p3pgraph ${P3PGRAPH_HEADERS} ${P3PGRAPH_SOURCES} ${P3PGRAPH_IGATEEXT}) +add_library(p3pgraph ${P3PGRAPH_HEADERS} ${P3PGRAPH_SOURCES}) target_link_libraries(p3pgraph p3gobj p3event p3gsgbase p3putil p3linmath p3downloader) -target_interrogate(p3pgraph ALL) +target_interrogate(p3pgraph ALL ${P3PGRAPH_IGATEEXT}) install(TARGETS p3pgraph DESTINATION lib) diff --git a/panda/src/pnmimage/CMakeLists.txt b/panda/src/pnmimage/CMakeLists.txt index 211172bdd7..bf88128a0c 100644 --- a/panda/src/pnmimage/CMakeLists.txt +++ b/panda/src/pnmimage/CMakeLists.txt @@ -30,8 +30,8 @@ set(P3PNMIMAGE_IGATEEXT ) composite_sources(p3pnmimage P3PNMIMAGE_SOURCES) -add_library(p3pnmimage ${P3PNMIMAGE_HEADERS} ${P3PNMIMAGE_SOURCES} ${P3PNMIMAGE_IGATEEXT}) +add_library(p3pnmimage ${P3PNMIMAGE_HEADERS} ${P3PNMIMAGE_SOURCES}) target_link_libraries(p3pnmimage p3mathutil) -target_interrogate(p3pnmimage ALL) +target_interrogate(p3pnmimage ALL ${P3PNMIMAGE_IGATEEXT}) install(TARGETS p3pnmimage DESTINATION lib) diff --git a/panda/src/putil/CMakeLists.txt b/panda/src/putil/CMakeLists.txt index 0a9cc12849..d38094029e 100644 --- a/panda/src/putil/CMakeLists.txt +++ b/panda/src/putil/CMakeLists.txt @@ -117,9 +117,9 @@ set(P3PUTIL_IGATEEXT ) composite_sources(p3putil P3PUTIL_SOURCES) -add_library(p3putil ${P3PUTIL_HEADERS} ${P3PUTIL_SOURCES} ${P3PUTIL_IGATEEXT}) +add_library(p3putil ${P3PUTIL_HEADERS} ${P3PUTIL_SOURCES}) target_link_libraries(p3putil p3pipeline) -target_interrogate(p3putil ALL) +target_interrogate(p3putil ALL ${P3PUTIL_IGATEEXT}) install(TARGETS p3putil DESTINATION lib) From 31d420515af885e2cd44059c4fcd4e56ff8c3439 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 30 Mar 2014 04:47:18 -0600 Subject: [PATCH 2/5] egg: Add CPPPARSER ifndef to eggGroupNode_ext.cxx to fix parse error. --- panda/src/egg/eggGroupNode_ext.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/panda/src/egg/eggGroupNode_ext.cxx b/panda/src/egg/eggGroupNode_ext.cxx index 457ea73ba3..e554bb243c 100644 --- a/panda/src/egg/eggGroupNode_ext.cxx +++ b/panda/src/egg/eggGroupNode_ext.cxx @@ -16,7 +16,9 @@ #ifdef HAVE_PYTHON +#ifndef CPPPARSER IMPORT_THIS struct Dtool_PyTypedObject Dtool_EggNode; +#endif //////////////////////////////////////////////////////////////////// // Function: EggGroupNode::get_children From b30084858935f6a1e90149e5da673998a700058c Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 30 Mar 2014 04:49:52 -0600 Subject: [PATCH 3/5] CMake: Add new "EXTENSIONS" syntax to target_interrogate(...) macro. --- cmake/macros/Interrogate.cmake | 52 +++++++++++++------------------ panda/src/display/CMakeLists.txt | 2 +- panda/src/egg/CMakeLists.txt | 2 +- panda/src/express/CMakeLists.txt | 2 +- panda/src/ode/CMakeLists.txt | 2 +- panda/src/pgraph/CMakeLists.txt | 2 +- panda/src/pnmimage/CMakeLists.txt | 2 +- panda/src/putil/CMakeLists.txt | 2 +- 8 files changed, 29 insertions(+), 37 deletions(-) diff --git a/cmake/macros/Interrogate.cmake b/cmake/macros/Interrogate.cmake index 0025cc9161..b88d6272d8 100644 --- a/cmake/macros/Interrogate.cmake +++ b/cmake/macros/Interrogate.cmake @@ -50,10 +50,16 @@ set(ALL_INTERROGATE_MODULES CACHE INTERNAL "Internal variable") function(target_interrogate target) if(HAVE_PYTHON AND HAVE_INTERROGATE) set(sources) + set(extensions) set(want_all OFF) + set(extensions_keyword OFF) foreach(arg ${ARGN}) if(arg STREQUAL "ALL") set(want_all ON) + elseif(arg STREQUAL "EXTENSIONS") + set(extensions_keyword ON) + elseif(extensions_keyword) + list(APPEND extensions "${arg}") else() list(APPEND sources "${arg}") endif() @@ -70,13 +76,20 @@ function(target_interrogate target) # Now let's get everything's absolute path, so that it can be passed # through a property while still preserving the reference. set(absolute_sources) + set(absolute_extensions) foreach(source ${sources}) get_source_file_property(location "${source}" LOCATION) - set(absolute_sources ${absolute_sources} ${location}) + list(APPEND absolute_sources ${location}) endforeach(source) + foreach(extension ${extensions}) + get_source_file_property(location "${extension}" LOCATION) + list(APPEND absolute_extensions ${location}) + endforeach(extension) set_target_properties("${target}" PROPERTIES IGATE_SOURCES "${absolute_sources}") + set_target_properties("${target}" PROPERTIES IGATE_EXTENSIONS + "${absolute_extensions}") # CMake has no property for determining the source directory where the # target was originally added. interrogate_sources makes use of this @@ -86,9 +99,6 @@ function(target_interrogate target) # an IGATE_ prefix. set_target_properties("${target}" PROPERTIES TARGET_SRCDIR "${CMAKE_CURRENT_SOURCE_DIR}") - - # HACK HACK HACK -- this is part of the below hack. - target_link_libraries(${target} ${target}_igate) endif() endfunction(target_interrogate) @@ -106,6 +116,7 @@ endfunction(target_interrogate) function(interrogate_sources target output database module) if(HAVE_PYTHON AND HAVE_INTERROGATE) get_target_property(sources "${target}" IGATE_SOURCES) + get_target_property(extensions "${target}" IGATE_EXTENSIONS) if(NOT sources) message(FATAL_ERROR @@ -189,14 +200,6 @@ function(interrogate_sources target output database module) list(APPEND define_flags "-DNDEBUG") endif() - # CMake offers no way to directly depend on the composite files from here, - # because the composite files are created in a different directory from - # where CMake itself is run. Therefore, we need to depend on the - # TARGET_composite target, if it exists. - if(TARGET ${target}_composite) - set(sources ${target}_composite ${sources}) - endif() - add_custom_command( OUTPUT "${output}" "${database}" COMMAND interrogate @@ -212,7 +215,8 @@ function(interrogate_sources target output database module) -S "${PROJECT_BINARY_DIR}/include/parser-inc" ${include_flags} ${scan_sources} - DEPENDS interrogate ${sources} ${nfiles} + ${extensions} + DEPENDS interrogate ${sources} ${extensions} ${nfiles} COMMENT "Interrogating ${target}" ) endif() @@ -230,7 +234,6 @@ function(add_python_module module) set(link_targets) set(infiles) set(sources) - set(HACKlinklibs) set(link_keyword OFF) foreach(arg ${ARGN}) @@ -249,22 +252,12 @@ function(add_python_module module) foreach(target ${targets}) interrogate_sources(${target} "${target}_igate.cxx" "${target}.in" "${module}") + get_target_property(target_extensions "${target}" IGATE_EXTENSIONS) list(APPEND infiles "${target}.in") - #list(APPEND sources "${target}_igate.cxx") + list(APPEND sources "${target}_igate.cxx" ${target_extensions}) - # HACK HACK HACK: - # Currently, the codebase has dependencies on the Interrogate-generated - # code when HAVE_PYTHON is enabled. rdb is working to remove this, but - # until then, the generated code must somehow be made available to the - # modules themselves. The workaround here is to put the _igate.cxx into - # its own micro-library, which is linked both here on the module and - # against the component library in question. - add_library(${target}_igate ${target}_igate.cxx) - list(APPEND HACKlinklibs "${target}_igate") - install(TARGETS ${target}_igate DESTINATION lib) - - get_target_property(target_links "${target}" LINK_LIBRARIES) - target_link_libraries(${target}_igate ${target_links}) + #get_target_property(target_links "${target}" LINK_LIBRARIES) + #target_link_libraries(${target}_igate ${target_links}) endforeach(target) add_custom_command( @@ -278,10 +271,9 @@ function(add_python_module module) COMMENT "Generating module ${module}" ) - add_library(${module} MODULE "${module}_module.cxx" ${sources}) + add_library(${module} "${module}_module.cxx" ${sources}) target_link_libraries(${module} ${link_targets} ${PYTHON_LIBRARIES} p3interrogatedb) - target_link_libraries(${module} ${HACKlinklibs}) set_target_properties(${module} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/panda3d" diff --git a/panda/src/display/CMakeLists.txt b/panda/src/display/CMakeLists.txt index 2b37249258..e2b71d3eee 100644 --- a/panda/src/display/CMakeLists.txt +++ b/panda/src/display/CMakeLists.txt @@ -99,7 +99,7 @@ endif() composite_sources(p3display P3DISPLAY_SOURCES) add_library(p3display ${P3DISPLAY_HEADERS} ${P3DISPLAY_SOURCES}) target_link_libraries(p3display p3cull p3pgraphnodes) -target_interrogate(p3display ALL ${P3DISPLAY_IGATEEXT}) +target_interrogate(p3display ALL EXTENSIONS ${P3DISPLAY_IGATEEXT}) install(TARGETS p3display DESTINATION lib) diff --git a/panda/src/egg/CMakeLists.txt b/panda/src/egg/CMakeLists.txt index dec290f287..caa59abeef 100644 --- a/panda/src/egg/CMakeLists.txt +++ b/panda/src/egg/CMakeLists.txt @@ -101,7 +101,7 @@ if(HAVE_EGG) composite_sources(p3egg P3EGG_SOURCES) add_library(p3egg ${P3EGG_HEADERS} ${P3EGG_SOURCES} ${P3EGG_PARSER_SOURCES}) target_link_libraries(p3egg p3prc p3pandabase p3express p3linmath p3mathutil) - target_interrogate(p3egg ${P3EGG_HEADERS} ${P3EGG_SOURCES} ${P3EGG_IGATEEXT}) + target_interrogate(p3egg ${P3EGG_HEADERS} ${P3EGG_SOURCES} EXTENSIONS ${P3EGG_IGATEEXT}) install(TARGETS p3egg DESTINATION lib) endif() diff --git a/panda/src/express/CMakeLists.txt b/panda/src/express/CMakeLists.txt index 855126cd45..1b0fd5673f 100644 --- a/panda/src/express/CMakeLists.txt +++ b/panda/src/express/CMakeLists.txt @@ -136,7 +136,7 @@ composite_sources(p3express P3EXPRESS_SOURCES) add_library(p3express ${P3EXPRESS_SOURCES} ${P3EXPRESS_HEADERS}) target_link_libraries(p3express p3pandabase p3dtool p3dtoolconfig ${_TAR_LIBRARY} ${_ZLIB_LIBRARY}) -target_interrogate(p3express ALL ${P3EXPRESS_IGATEEXT}) +target_interrogate(p3express ALL EXTENSIONS ${P3EXPRESS_IGATEEXT}) if(WIN32) target_link_libraries(p3express advapi32.lib ws2_32.lib) diff --git a/panda/src/ode/CMakeLists.txt b/panda/src/ode/CMakeLists.txt index da02eac238..25795f4fc0 100755 --- a/panda/src/ode/CMakeLists.txt +++ b/panda/src/ode/CMakeLists.txt @@ -84,7 +84,7 @@ if(HAVE_ODE) add_library(p3ode ${P3ODE_SOURCES} ${P3ODE_HEADERS}) set_target_properties(p3ode PROPERTIES COMPILE_DEFINITIONS dSINGLE) target_link_libraries(p3ode p3pgraph p3physics ${ODE_LIBRARY}) - target_interrogate(p3ode ${P3ODE_IGATE_SOURCES} ${P3ODE_IGATEEXT}) + target_interrogate(p3ode ${P3ODE_IGATE_SOURCES} EXTENSIONS ${P3ODE_IGATEEXT}) install(TARGETS p3ode DESTINATION lib) endif() diff --git a/panda/src/pgraph/CMakeLists.txt b/panda/src/pgraph/CMakeLists.txt index 8eca8b5c7b..bdc6c4d201 100644 --- a/panda/src/pgraph/CMakeLists.txt +++ b/panda/src/pgraph/CMakeLists.txt @@ -208,7 +208,7 @@ set(P3PGRAPH_IGATEEXT composite_sources(p3pgraph P3PGRAPH_SOURCES) add_library(p3pgraph ${P3PGRAPH_HEADERS} ${P3PGRAPH_SOURCES}) target_link_libraries(p3pgraph p3gobj p3event p3gsgbase p3putil p3linmath p3downloader) -target_interrogate(p3pgraph ALL ${P3PGRAPH_IGATEEXT}) +target_interrogate(p3pgraph ALL EXTENSIONS ${P3PGRAPH_IGATEEXT}) install(TARGETS p3pgraph DESTINATION lib) diff --git a/panda/src/pnmimage/CMakeLists.txt b/panda/src/pnmimage/CMakeLists.txt index bf88128a0c..d6fe2c0d4e 100644 --- a/panda/src/pnmimage/CMakeLists.txt +++ b/panda/src/pnmimage/CMakeLists.txt @@ -32,6 +32,6 @@ set(P3PNMIMAGE_IGATEEXT composite_sources(p3pnmimage P3PNMIMAGE_SOURCES) add_library(p3pnmimage ${P3PNMIMAGE_HEADERS} ${P3PNMIMAGE_SOURCES}) target_link_libraries(p3pnmimage p3mathutil) -target_interrogate(p3pnmimage ALL ${P3PNMIMAGE_IGATEEXT}) +target_interrogate(p3pnmimage ALL EXTENSIONS ${P3PNMIMAGE_IGATEEXT}) install(TARGETS p3pnmimage DESTINATION lib) diff --git a/panda/src/putil/CMakeLists.txt b/panda/src/putil/CMakeLists.txt index d38094029e..05a4fea19d 100644 --- a/panda/src/putil/CMakeLists.txt +++ b/panda/src/putil/CMakeLists.txt @@ -119,7 +119,7 @@ set(P3PUTIL_IGATEEXT composite_sources(p3putil P3PUTIL_SOURCES) add_library(p3putil ${P3PUTIL_HEADERS} ${P3PUTIL_SOURCES}) target_link_libraries(p3putil p3pipeline) -target_interrogate(p3putil ALL ${P3PUTIL_IGATEEXT}) +target_interrogate(p3putil ALL EXTENSIONS ${P3PUTIL_IGATEEXT}) install(TARGETS p3putil DESTINATION lib) From 1421627dd93d9a41d86496e9fa21690b101a4322 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 30 Mar 2014 04:50:14 -0600 Subject: [PATCH 4/5] CMake: Deprecate the FOO_composite pseudotarget -- the hack that needed it is no longer around. --- cmake/macros/CompositeSources.cmake | 6 ------ 1 file changed, 6 deletions(-) diff --git a/cmake/macros/CompositeSources.cmake b/cmake/macros/CompositeSources.cmake index 631de638f9..241a2a3d64 100644 --- a/cmake/macros/CompositeSources.cmake +++ b/cmake/macros/CompositeSources.cmake @@ -93,12 +93,6 @@ function(composite_sources target sources_var) endif() endwhile() - # This exists for Interrogate's benefit, which needs the composite files to - # exist before it can run. Unfortunately, CMake does not expose the - # add_custom_command outputs as targets outside of the directory, so we have - # to create our own pseudotarget that gets exposed. - add_custom_target(${target}_composite DEPENDS ${composite_files}) - #set_source_files_properties(${composite_files} PROPERTIES GENERATED YES) # The new files are added to the existing files, which means the old files From 841f3b8a49d99e778c34c326dfd4732883166bd4 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 30 Mar 2014 04:51:38 -0600 Subject: [PATCH 5/5] CMake: Link Interrogate modules against 'core'. --- direct/CMakeLists.txt | 1 + panda/CMakeLists.txt | 3 +++ 2 files changed, 4 insertions(+) diff --git a/direct/CMakeLists.txt b/direct/CMakeLists.txt index 6fc755a522..b293728ee1 100644 --- a/direct/CMakeLists.txt +++ b/direct/CMakeLists.txt @@ -18,6 +18,7 @@ add_subdirectory(src/interval) add_subdirectory(src/showbase) add_python_module(direct p3dcparser p3deadrec p3distributed p3interval p3showbase) +target_link_libraries(direct core) # Installation: if(HAVE_PYTHON) diff --git a/panda/CMakeLists.txt b/panda/CMakeLists.txt index 84184d1295..1283fa1b80 100644 --- a/panda/CMakeLists.txt +++ b/panda/CMakeLists.txt @@ -97,10 +97,13 @@ add_python_module(core ${CORE_MODULE_COMPONENTS} LINK panda) if(HAVE_EGG) add_python_module(egg p3egg p3egg2pg) + target_link_libraries(egg core) endif() add_python_module(physics p3physics p3particlesystem) +target_link_libraries(physics core) if(HAVE_ODE) add_python_module(ode p3ode) + target_link_libraries(ode core) endif()