CMake: Build dtool metalibs as metalibs

This commit is contained in:
Sam Edwards 2018-04-19 00:04:21 -06:00
parent 5a31844e11
commit 218d0e8ade
15 changed files with 40 additions and 39 deletions

View File

@ -20,7 +20,9 @@ function(target_link_libraries target)
endif()
foreach(library ${ARGN})
if(library MATCHES "^[A-Za-z0-9]+$")
# This is a quick and dirty regex to tell targets apart from other stuff.
# It just checks if it's alphanumeric and starts with p3/panda.
if(library MATCHES "^(p3|panda)[A-Za-z0-9]*$")
# We need to add "library"'s include directories to "target"
# (and transitively to INTERFACE_INCLUDE_DIRECTORIES so further
# dependencies will work)

View File

@ -292,7 +292,7 @@ function(add_python_module module)
add_library(${module} STATIC "${module}_module.cxx" ${sources})
endif()
target_link_libraries(${module}
${link_targets} ${PYTHON_LIBRARIES} p3interrogatedb)
${link_targets} ${PYTHON_LIBRARIES} p3dtool)
set_target_properties(${module} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/panda3d"

View File

@ -1,4 +1,3 @@
add_library(p3dtool dtool.cxx)
target_link_libraries(p3dtool p3dtoolutil p3dtoolbase)
add_metalib(p3dtool dtool.cxx COMPONENTS p3dtoolutil p3dtoolbase)
install(TARGETS p3dtool DESTINATION lib)

View File

@ -1,4 +1,10 @@
add_definitions(-DBUILDING_DTOOLCONFIG)
# First, dtoolconfig:
set(DTOOLCONFIG_LINK_TARGETS p3prc p3dconfig p3interrogatedb)
add_metalib(p3dtoolconfig dtoolconfig.cxx COMPONENTS ${DTOOLCONFIG_LINK_TARGETS})
install(TARGETS p3dtoolconfig DESTINATION lib)
# Next, panda3d.interrogatedb:
if(BUILD_SHARED_LIBS)
set(libtype MODULE)
@ -7,21 +13,15 @@ else()
endif()
if(HAVE_PYTHON)
add_library(p3dtoolconfig ${libtype} dtoolconfig.cxx pydtool.cxx)
else()
add_library(p3dtoolconfig ${libtype} dtoolconfig.cxx)
endif()
add_library(interrogatedb ${libtype} pydtool.cxx)
target_use_packages(interrogatedb PYTHON)
target_link_libraries(interrogatedb p3dtoolconfig)
target_use_packages(p3dtoolconfig PYTHON)
target_link_libraries(p3dtoolconfig p3prc p3dconfig p3interrogatedb)
set_target_properties(p3dtoolconfig PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/panda3d"
PREFIX ""
OUTPUT_NAME "interrogatedb"
)
set_target_properties(interrogatedb PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/panda3d"
PREFIX ""
OUTPUT_NAME "interrogatedb"
)
if(HAVE_PYTHON)
install(TARGETS p3dtoolconfig DESTINATION "${PYTHON_ARCH_INSTALL_DIR}/panda3d")
else()
install(TARGETS p3dtoolconfig DESTINATION lib)
install(TARGETS interrogatedb DESTINATION "${PYTHON_ARCH_INSTALL_DIR}/panda3d")
endif()

View File

@ -40,6 +40,6 @@ set(P3CPPPARSER_SOURCES
composite_sources(p3cppParser P3CPPPARSER_SOURCES)
add_library(p3cppParser STATIC ${P3CPPPARSER_HEADERS} ${P3CPPPARSER_SOURCES})
target_link_libraries(p3cppParser p3dtoolutil)
target_link_libraries(p3cppParser p3dtool)
install(TARGETS p3cppParser DESTINATION lib)

View File

@ -6,8 +6,8 @@ set(P3DCONFIG_SOURCES
composite_sources(p3dconfig P3DCONFIG_SOURCES)
add_library(p3dconfig ${P3DCONFIG_HEADERS} ${P3DCONFIG_SOURCES})
set_target_properties(p3dconfig PROPERTIES DEFINE_SYMBOL BUILDING_DTOOL_DCONFIG)
add_component_library(p3dconfig SYMBOL BUILDING_DTOOL_DCONFIG
${P3DCONFIG_HEADERS} ${P3DCONFIG_SOURCES})
target_link_libraries(p3dconfig p3prc)
install(TARGETS p3dconfig DESTINATION lib)

View File

@ -69,8 +69,8 @@ set(P3DTOOLBASE_IGATEEXT
composite_sources(p3dtoolbase P3DTOOLBASE_SOURCES)
add_library(p3dtoolbase ${P3DTOOLBASE_HEADERS} ${P3DTOOLBASE_SOURCES})
set_target_properties(p3dtoolbase PROPERTIES DEFINE_SYMBOL BUILDING_DTOOL_DTOOLBASE)
add_component_library(p3dtoolbase SYMBOL BUILDING_DTOOL_DTOOLBASE
${P3DTOOLBASE_HEADERS} ${P3DTOOLBASE_SOURCES})
# The extensions need py_panda.h and extension.h from interrogatedb
target_include_directories(p3dtoolbase PUBLIC
$<TARGET_PROPERTY:p3interrogatedb,INTERFACE_INCLUDE_DIRECTORIES>)

View File

@ -71,8 +71,9 @@ set(P3DTOOLUTIL_IGATEEXT
composite_sources(p3dtoolutil P3DTOOLUTIL_SOURCES)
add_library(p3dtoolutil ${P3DTOOLUTIL_HEADERS} ${P3DTOOLUTIL_SOURCES})
set_target_properties(p3dtoolutil PROPERTIES DEFINE_SYMBOL BUILDING_DTOOL_DTOOLUTIL)
add_component_library(p3dtoolutil SYMBOL BUILDING_DTOOL_DTOOLUTIL
${P3DTOOLUTIL_HEADERS} ${P3DTOOLUTIL_SOURCES})
target_include_directories(p3dtoolutil PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
# The extensions need py_panda.h and extension.h from interrogatedb
target_include_directories(p3dtoolutil PUBLIC
$<TARGET_PROPERTY:p3interrogatedb,INTERFACE_INCLUDE_DIRECTORIES>)

View File

@ -53,12 +53,10 @@ composite_sources(interrogate INTERROGATE_SOURCES)
add_executable(interrogate ${INTERROGATE_HEADERS} ${INTERROGATE_SOURCES})
target_link_libraries(interrogate
p3cppParser p3interrogatedb p3dconfig p3prc p3dtoolutil p3dtoolbase
p3pystub ${_OPENSSL_LIBRARIES})
p3cppParser p3dtoolconfig p3pystub ${_OPENSSL_LIBRARIES})
install(TARGETS interrogate DESTINATION bin)
add_executable(interrogate_module interrogate_module.cxx)
target_link_libraries(interrogate_module
p3cppParser p3interrogatedb p3dconfig p3prc p3dtoolutil p3dtoolbase
p3pystub ${_OPENSSL_LIBRARIES})
p3cppParser p3dtoolconfig p3pystub ${_OPENSSL_LIBRARIES})
install(TARGETS interrogate_module DESTINATION bin)

View File

@ -40,7 +40,8 @@ set(P3INTERROGATEDB_IGATE_SOURCES
interrogateType.cxx interrogate_datafile.cxx
interrogate_interface.cxx interrogate_request.cxx)
add_library(p3interrogatedb ${P3INTERROGATEDB_HEADERS} ${P3INTERROGATEDB_SOURCES})
add_component_library(p3interrogatedb SYMBOL SYMBOL BUILDING_INTERROGATEDB
${P3INTERROGATEDB_HEADERS} ${P3INTERROGATEDB_SOURCES})
target_link_libraries(p3interrogatedb p3dconfig)
target_use_packages(p3interrogatedb PYTHON)
target_interrogate(p3interrogatedb ${P3INTERROGATEDB_IGATE_SOURCES})

View File

@ -70,12 +70,12 @@ set(P3PRC_IGATEEXT
composite_sources(p3prc P3PRC_SOURCES)
add_library(p3prc ${P3PRC_HEADERS} ${P3PRC_SOURCES})
set_target_properties(p3prc PROPERTIES DEFINE_SYMBOL BUILDING_DTOOL_PRC)
add_component_library(p3prc SYMBOL BUILDING_DTOOL_PRC
${P3PRC_HEADERS} ${P3PRC_SOURCES})
# The extensions need py_panda.h and extension.h from interrogatedb
target_include_directories(p3prc PUBLIC
$<TARGET_PROPERTY:p3interrogatedb,INTERFACE_INCLUDE_DIRECTORIES>)
target_link_libraries(p3prc p3dtoolutil p3dtoolbase ${_OPENSSL_LIBRARIES})
target_link_libraries(p3prc p3dtool ${_OPENSSL_LIBRARIES})
target_interrogate(p3prc ALL EXTENSIONS ${P3PRC_IGATEEXT})
install(TARGETS p3prc DESTINATION lib)

View File

@ -2,5 +2,5 @@ set(P3PYSTUB_HEADERS pystub.h)
set(P3PYSTUB_SOURCES pystub.cxx)
add_library(p3pystub STATIC ${P3PYSTUB_HEADERS} ${P3PYSTUB_SOURCES})
target_link_libraries(p3pystub p3dtoolbase)
target_link_libraries(p3pystub p3dtool)
install(FILES ${P3PYSTUB_HEADERS} DESTINATION include/panda3d)

View File

@ -150,7 +150,7 @@ add_component_library(p3express SYMBOL BUILDING_PANDAEXPRESS
# p3express needs to include from p3interrogatedb for py_panda.h and extension.h
target_include_directories(p3express PUBLIC
$<TARGET_PROPERTY:p3interrogatedb,INTERFACE_INCLUDE_DIRECTORIES>)
target_link_libraries(p3express p3pandabase p3dtool p3prc p3dconfig)
target_link_libraries(p3express p3pandabase p3dtoolconfig p3dtool)
target_use_packages(p3express TAR ZLIB)
target_interrogate(p3express ALL EXTENSIONS ${P3EXPRESS_IGATEEXT})

View File

@ -44,7 +44,7 @@ set(P3MOVIES_SOURCES
composite_sources(p3movies P3MOVIES_SOURCES)
add_component_library(p3movies SYMBOL BUILDING_PANDA_MOVIES
${P3MOVIES_HEADERS} ${P3MOVIES_SOURCES})
target_link_libraries(p3movies p3pandabase p3express p3pstatclient p3gobj p3dconfig p3prc)
target_link_libraries(p3movies p3pstatclient p3gobj p3express p3pandabase)
target_interrogate(p3movies ALL)
install(TARGETS p3movies DESTINATION lib)

View File

@ -7,7 +7,7 @@ set(P3PANDABASE_SOURCES
)
add_component_library(p3pandabase ${P3PANDABASE_HEADERS} ${P3PANDABASE_SOURCES})
target_link_libraries(p3pandabase p3dtoolbase)
target_link_libraries(p3pandabase p3dtool)
install(TARGETS p3pandabase DESTINATION lib)
install(FILES ${P3PANDABASE_HEADERS} DESTINATION include/panda3d)