Skip to content

Commit

Permalink
Merge pull request #6 from kestred/cmake-cfs-install
Browse files Browse the repository at this point in the history
CMake: Add installation target rules
  • Loading branch information
CFSworks committed Mar 3, 2014
2 parents ea36b87 + 493dde6 commit ba86e28
Show file tree
Hide file tree
Showing 73 changed files with 248 additions and 20 deletions.
14 changes: 8 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,24 @@ enable_testing()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/macros/")

# Include global modules needed for configure scripts
include(PackageConfig) # Defines package_option AND target_use_packages

# Configure Panda3D
include(dtool/PandaVersion.cmake)
include(dtool/Package.cmake)
include(dtool/Config.cmake)

# Include global modules
include(AutoInclude) # Implements automatic include_directories finding
include(AddBisonTarget) # Defines add_bison_target function
include(AddFlexTarget) # Defines add_flex_target function
include(CompositeSources) # Defines composite_sources function
include(PackageConfig) # Defines package_option AND target_use_packages
include(Interrogate) # Defines target_interrogate AND add_python_module

# Add the include path for source and header files generated by CMake
include_directories("${CMAKE_BINARY_DIR}/include")

# Configure Panda3D
include(dtool/PandaVersion.cmake)
include(dtool/Package.cmake)
include(dtool/Config.cmake)

# Determine which trees to build.
option(BUILD_DTOOL "Build the dtool source tree." ON)
option(BUILD_PANDA "Build the panda source tree." ON)
Expand Down
17 changes: 17 additions & 0 deletions cmake/macros/Interrogate.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ endif()

set(IMOD_FLAGS -python-native)

# This stores the names of every module added to the Interrogate system:
set(ALL_INTERROGATE_MODULES CACHE INTERNAL "Internal variable")

#
# Function: target_interrogate(target [ALL] [source1 [source2 ...]])
Expand Down Expand Up @@ -241,6 +243,7 @@ function(add_python_module module)
# 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})
Expand Down Expand Up @@ -269,5 +272,19 @@ function(add_python_module module)
if(WIN32 AND NOT CYGWIN)
set_target_properties(${module} PROPERTIES SUFFIX ".pyd")
endif()

list(APPEND ALL_INTERROGATE_MODULES "${module}")
set(ALL_INTERROGATE_MODULES "${ALL_INTERROGATE_MODULES}" CACHE INTERNAL "Internal variable")
endif()
endfunction(add_python_module)


if(HAVE_PYTHON)
# We have to create an __init__.py so that Python 2.x can recognize 'panda3d'
# as a package.
file(WRITE "${PROJECT_BINARY_DIR}/panda3d/__init__.py" "")

# The Interrogate path needs to be installed to the architecture-dependent
# Python directory.
install(DIRECTORY "${PROJECT_BINARY_DIR}/panda3d" DESTINATION "${PYTHON_ARCH_INSTALL_DIR}")
endif()
25 changes: 25 additions & 0 deletions direct/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,28 @@ add_subdirectory(src/interval)
add_subdirectory(src/showbase)

add_python_module(direct p3dcparser p3deadrec p3distributed p3interval p3showbase)

# Installation:
if(HAVE_PYTHON)
set(DIRECT_INSTALL_DIRECTORIES
actor cluster controls directbase directdevices directnotify directscripts
directtools directutil distributed extensions extensions_native ffi filter
fsm gui http interval leveleditor motiontrail p3d particles physics pyinst
showbase showutil stdpy task test tkpanels tkwidgets wxwidgets)

foreach(dir ${DIRECT_INSTALL_DIRECTORIES})
install(
DIRECTORY "src/${dir}"
DESTINATION "${PYTHON_LIB_INSTALL_DIR}/direct"
PATTERN "*.py")
endforeach()

# We also need an __init__.py file, which we have to generate:
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/__init__.py" "")
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/__init__.py"
DESTINATION "${PYTHON_LIB_INSTALL_DIR}/direct")
endif()

# pandac has its own installation steps necessary:
add_subdirectory(src/pandac)
2 changes: 2 additions & 0 deletions direct/src/autorestart/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ if(UNIX)
add_executable(autorestart autorestart.c)
set_target_properties(autorestart PROPERTIES COMPILE_DEFINITIONS WITHIN_PANDA)
target_link_libraries(autorestart p3dtool)

install(TARGETS autorestart DESTINATION bin)
endif()
1 change: 1 addition & 0 deletions direct/src/dcparse/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
add_executable(dcparse dcparse.cxx)
set_target_properties(dcparse PROPERTIES COMPILE_DEFINITIONS WITHIN_PANDA)
target_link_libraries(dcparse p3dcparser)
install(TARGETS dcparse DESTINATION bin)
2 changes: 2 additions & 0 deletions direct/src/dcparser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,5 @@ add_library(p3dcparser ${P3DCPARSER_SOURCES} ${P3DCPARSER_HEADERS}
set_target_properties(p3dcparser PROPERTIES COMPILE_DEFINITIONS WITHIN_PANDA)
target_link_libraries(p3dcparser p3directbase p3express p3pstatclient p3prc)
target_interrogate(p3dcparser ${P3DCPARSER_SOURCES} ${P3DCPARSER_HEADERS})

install(TARGETS p3dcparser DESTINATION lib)
2 changes: 2 additions & 0 deletions direct/src/deadrec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ set(P3DEADREC_SOURCES
add_library(p3deadrec ${P3DEADREC_HEADERS} ${P3DEADREC_SOURCES})
target_link_libraries(p3deadrec p3directbase p3linmath p3pgraph p3prc)
target_interrogate(p3deadrec ALL)

install(TARGETS p3deadrec DESTINATION lib)
2 changes: 2 additions & 0 deletions direct/src/directbase/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ set(P3DIRECTBASE_HEADERS
# Not worth compositing sources, there's really only one.
add_library(p3directbase ${P3DIRECTBASE_SOURCES} ${P3DIRECTBASE_HEADERS})
target_link_libraries(p3directbase p3pandabase)

install(TARGETS p3directbase DESTINATION lib)
6 changes: 2 additions & 4 deletions direct/src/directnotify/DirectNotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@ def setDconfigLevel(self, categoryName):
"""

# We use ConfigVariableString instead of base.config, in case
# we're running before ShowBase has finished initializing; and
# we import it directly from libpandaexpress, in case we're
# running before libpanda.dll is available.
from libpandaexpress import ConfigVariableString
# we're running before ShowBase has finished initializing
from panda3d.core import ConfigVariableString

dconfigParam = ("notify-level-" + categoryName)
cvar = ConfigVariableString(dconfigParam, "")
Expand Down
4 changes: 2 additions & 2 deletions direct/src/directnotify/Notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""
from LoggerGlobal import defaultLogger
from direct.showbase import PythonUtil
from libpandaexpress import ConfigVariableBool
from panda3d.core import ConfigVariableBool
import time
import types
import sys
Expand All @@ -18,7 +18,7 @@ class Notifier:
# with the C++ notify system.
streamWriter = None
if ConfigVariableBool('notify-integrate', True):
from libpandaexpress import StreamWriter, Notify
from panda3d.core import StreamWriter, Notify
streamWriter = StreamWriter(Notify.out(), False)

showTime = ConfigVariableBool('notify-timestamp', False)
Expand Down
2 changes: 2 additions & 0 deletions direct/src/distributed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ if(HAVE_PYTHON)
target_link_libraries(p3distributed p3net)
endif()
target_interrogate(p3distributed ALL)

install(TARGETS p3distributed DESTINATION lib)
endif()
2 changes: 2 additions & 0 deletions direct/src/interval/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ composite_sources(p3interval P3INTERVAL_SOURCES)
add_library(p3interval ${P3INTERVAL_HEADERS} ${P3INTERVAL_SOURCES})
target_link_libraries(p3interval p3directbase p3pstatclient p3pgraph p3chan p3dconfig p3prc)
target_interrogate(p3interval ALL)

install(TARGETS p3interval DESTINATION lib)
15 changes: 15 additions & 0 deletions direct/src/pandac/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
if(HAVE_PYTHON)
# Generate PandaModules:
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/PandaModules.py"
"# Generated by CMake; edits not preserved\n")
foreach(module ${ALL_INTERROGATE_MODULES})
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/PandaModules.py"
"from panda3d.${module} import *\n")
endforeach()

# Now install ourselves:
file(GLOB python_sources "${CMAKE_CURRENT_SOURCE_DIR}/*.py")
install(
FILES ${python_sources} "${CMAKE_CURRENT_BINARY_DIR}/PandaModules.py"
DESTINATION "${PYTHON_LIB_INSTALL_DIR}/pandac")
endif()
32 changes: 32 additions & 0 deletions direct/src/pandac/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# N.B. PandaModules is generated at build time by CMake
from PandaModules import *
import __builtin__

# Now import all extensions:
from direct.extensions_native.extension_native_helpers import *
extensions = [
'CInterval', 'EggGroupNode', 'EggPrimitive', 'HTTPChannel', 'Mat3',
'NodePath', 'NodePathCollection', 'OdeBody', 'OdeGeom', 'OdeJoint',
'OdeSpace', 'Ramfile', 'StreamReader', 'VBase3', 'VBase4'
]

# Prior to importing, we need to make the Dtool_funcToMethod function and
# the extended class available globally. This is hacky, but tacking it on
# __builtin__ works just fine:
import __builtin__
__builtin__.Dtool_funcToMethod = Dtool_funcToMethod
__builtin__.Dtool_ObjectToDict = Dtool_ObjectToDict

for extension in extensions:
if extension not in locals():
# Not a class we have compiled in, skip it!
continue

module = 'direct.extensions_native.%s_extensions' % extension

setattr(__builtin__, extension, locals()[extension])
__import__(module)
del __builtin__.__dict__[extension]

del __builtin__.Dtool_funcToMethod
del __builtin__.Dtool_ObjectToDict
2 changes: 2 additions & 0 deletions direct/src/showbase/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
add_library(p3showbase showBase.cxx showBase.h)
target_link_libraries(p3showbase p3directbase p3express p3event p3chan p3display p3dconfig p3prc)
target_interrogate(p3showbase ALL)

install(TARGETS p3showbase DESTINATION lib)
2 changes: 1 addition & 1 deletion direct/src/showbase/Messenger.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from direct.directnotify import DirectNotifyGlobal
import types

from libpandaexpress import ConfigVariableBool
from panda3d.core import ConfigVariableBool

# If using the Toontown ActiveX launcher, this must be set true.
# Also, Panda must be compiled with SIMPLE_THREADS or no HAVE_THREADS
Expand Down
2 changes: 1 addition & 1 deletion direct/src/showbase/ProfileSession.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pandac.libpandaexpressModules import TrueClock
from panda3d.core import TrueClock
from direct.directnotify.DirectNotifyGlobal import directNotify
from direct.showbase.PythonUtil import (
StdoutCapture, _installProfileCustomFuncs,_removeProfileCustomFuncs,
Expand Down
2 changes: 1 addition & 1 deletion direct/src/showbase/PythonUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
# Don't import libpandaexpressModules, which doesn't get built until
# genPyCode.
import direct.extensions_native.extension_native_helpers
from libpandaexpress import ConfigVariableBool
from panda3d.core import ConfigVariableBool

ScalarTypes = (types.FloatType, types.IntType, types.LongType)

Expand Down
2 changes: 1 addition & 1 deletion direct/src/showbase/VFSImporter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from libpandaexpress import Filename, VirtualFileSystem, VirtualFileMountSystem, OFileStream, copyStream
from panda3d.core import Filename, VirtualFileSystem, VirtualFileMountSystem, OFileStream, copyStream
import sys
import os
import marshal
Expand Down
25 changes: 22 additions & 3 deletions dtool/Config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -437,9 +437,28 @@ package_option(PYTHON DEFAULT ON
"Enables support for Python. If INTERROGATE_PYTHON_INTERFACE
is also enabled, Python bindings will be generated.")

# Always include Python, because we include it pretty much everywhere
# though we don't usually want to link it in as well.
include_directories(${PYTHON_INCLUDE_DIRS})
# Also detect the optimal install paths:
if(HAVE_PYTHON)
execute_process(
COMMAND ${PYTHON_EXECUTABLE}
-c "from distutils.sysconfig import get_python_lib; print get_python_lib(False)"
OUTPUT_VARIABLE _LIB_DIR)
execute_process(
COMMAND ${PYTHON_EXECUTABLE}
-c "from distutils.sysconfig import get_python_lib; print get_python_lib(True)"
OUTPUT_VARIABLE _ARCH_DIR)

set(PYTHON_LIB_INSTALL_DIR "${_LIB_DIR}" CACHE STRING
"Path to the Python architecture-independent package directory.")

set(PYTHON_ARCH_INSTALL_DIR "${_ARCH_DIR}" CACHE STRING
"Path to the Python architecture-dependent package directory.")

# Always include Python, because we include it pretty much everywhere
# though we don't usually want to link it in as well.
include_directories(${PYTHON_INCLUDE_DIRS})
endif()


# By default, we'll assume the user only wants to run with Debug
# python if he has to--that is, on Windows when building a debug build.
Expand Down
2 changes: 2 additions & 0 deletions dtool/metalibs/dtool/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
add_library(p3dtool dtool.cxx)
target_link_libraries(p3dtool p3dtoolutil p3dtoolbase)

install(TARGETS p3dtool DESTINATION lib)
2 changes: 2 additions & 0 deletions dtool/metalibs/dtoolconfig/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ else()
endif()

target_link_libraries(p3dtoolconfig p3prc p3dconfig p3interrogatedb)

install(TARGETS p3dtoolconfig DESTINATION lib)
2 changes: 2 additions & 0 deletions dtool/src/cppparser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ composite_sources(p3cppParser P3CPPPARSER_SOURCES)

add_library(p3cppParser STATIC ${P3CPPPARSER_HEADERS} ${P3CPPPARSER_SOURCES})
target_link_libraries(p3cppParser p3dtoolutil)

install(TARGETS p3cppParser DESTINATION lib)
2 changes: 2 additions & 0 deletions dtool/src/dconfig/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ composite_sources(p3dconfig P3DCONFIG_SOURCES)

add_library(p3dconfig ${P3DCONFIG_HEADERS} ${P3DCONFIG_SOURCES})
target_link_libraries(p3dconfig p3prc)

install(TARGETS p3dconfig DESTINATION lib)
2 changes: 2 additions & 0 deletions dtool/src/dtoolbase/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,5 @@ add_library(p3dtoolbase ${P3DTOOLBASE_HEADERS} ${P3DTOOLBASE_SOURCES})
if(HAVE_PYTHON)
target_link_libraries(p3dtoolbase ${PYTHON_LIBRARIES})
endif()

install(TARGETS p3dtoolbase DESTINATION lib)
2 changes: 2 additions & 0 deletions dtool/src/dtoolutil/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,5 @@ target_link_libraries(p3dtoolutil p3dtoolbase ${CMAKE_DL_LIBS})
if(HAVE_PYTHON)
target_link_libraries(p3dtoolutil ${PYTHON_LIBRARIES})
endif()

install(TARGETS p3dtoolutil DESTINATION lib)
2 changes: 2 additions & 0 deletions dtool/src/interrogate/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ add_executable(interrogate ${INTERROGATE_HEADERS} ${INTERROGATE_SOURCES})
target_link_libraries(interrogate
p3cppParser p3interrogatedb p3dconfig p3prc p3dtoolutil p3dtoolbase
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})
install(TARGETS interrogate DESTINATION bin)
2 changes: 2 additions & 0 deletions dtool/src/interrogatedb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ composite_sources(p3interrogatedb P3INTERROGATEDB_SOURCES)

add_library(p3interrogatedb ${P3INTERROGATEDB_HEADERS} ${P3INTERROGATEDB_SOURCES})
target_link_libraries(p3interrogatedb p3dconfig)

install(TARGETS p3interrogatedb DESTINATION lib)
2 changes: 2 additions & 0 deletions dtool/src/prc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,5 @@ composite_sources(p3prc P3PRC_SOURCES)

add_library(p3prc ${P3PRC_HEADERS} ${P3PRC_SOURCES})
target_link_libraries(p3prc p3dtoolutil p3dtoolbase ${_OPENSSL_LIBRARIES})

install(TARGETS p3prc DESTINATION lib)
2 changes: 2 additions & 0 deletions panda/metalibs/panda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ endif()

add_library(panda panda.cxx)
target_link_libraries(panda ${PANDA_LINK_TARGETS})

install(TARGETS panda DESTINATION lib)
2 changes: 2 additions & 0 deletions panda/metalibs/pandaegg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ if(HAVE_EGG)

add_library(pandaegg pandaegg.cxx)
target_link_libraries(pandaegg ${PANDAEGG_LINK_TARGETS})

install(TARGETS pandaegg DESTINATION lib)
endif()
2 changes: 2 additions & 0 deletions panda/metalibs/pandagl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ if(HAVE_GL)

add_library(pandagl pandagl.cxx)
target_link_libraries(pandagl ${PANDAGL_LINK_TARGETS})

install(TARGETS pandagl DESTINATION lib)
endif()
2 changes: 2 additions & 0 deletions panda/src/audio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ if(HAVE_AUDIO)
add_library(p3audio ${P3AUDIO_HEADERS} ${P3AUDIO_SOURCES})
target_link_libraries(p3audio p3putil p3event p3movies p3linmath)
target_interrogate(p3audio ALL)

install(TARGETS p3audio DESTINATION lib)
endif()
2 changes: 2 additions & 0 deletions panda/src/chan/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,5 @@ composite_sources(p3chan P3CHAN_SOURCES)
add_library(p3chan ${P3CHAN_HEADERS} ${P3CHAN_SOURCES})
target_link_libraries(p3chan p3pgraph)
target_interrogate(p3chan ALL)

install(TARGETS p3chan DESTINATION lib)
2 changes: 2 additions & 0 deletions panda/src/char/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ composite_sources(p3char P3CHAR_SOURCES)
add_library(p3char ${P3CHAR_HEADERS} ${P3CHAR_SOURCES})
target_link_libraries(p3char p3chan)
target_interrogate(p3char ALL)

install(TARGETS p3char DESTINATION lib)
2 changes: 2 additions & 0 deletions panda/src/collide/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ add_library(p3collide ${P3COLLIDE_SOURCES} ${P3COLLIDE_HEADERS})
target_link_libraries(p3collide p3tform)
target_interrogate(p3collide ALL)

install(TARGETS p3collide DESTINATION lib)

#begin test_bin_target
#define TARGET test_collide
#define LOCAL_LIBS
Expand Down
2 changes: 2 additions & 0 deletions panda/src/cull/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ composite_sources(p3cull P3CULL_SOURCES)
add_library(p3cull ${P3CULL_HEADERS} ${P3CULL_SOURCES})
target_link_libraries(p3cull p3pgraph)
target_interrogate(p3cull ALL)

install(TARGETS p3cull DESTINATION lib)
Loading

0 comments on commit ba86e28

Please sign in to comment.