CMakeLists.txt 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. if(NOT BUILD_PANDA)
  2. message(FATAL_ERROR "Cannot build direct without panda! Please enable the BUILD_PANDA option.")
  3. endif()
  4. # Include source directories which have C++ components:
  5. add_subdirectory(src/dcparse)
  6. add_subdirectory(src/dcparser)
  7. add_subdirectory(src/deadrec)
  8. add_subdirectory(src/directbase)
  9. #add_subdirectory(src/directd)
  10. #add_subdirectory(src/directdServer)
  11. add_subdirectory(src/distributed)
  12. add_subdirectory(src/interval)
  13. add_subdirectory(src/motiontrail)
  14. add_subdirectory(src/showbase)
  15. set(P3DIRECT_COMPONENTS
  16. p3dcparser p3deadrec
  17. p3interval p3motiontrail p3showbase
  18. )
  19. if(HAVE_PYTHON)
  20. list(APPEND P3DIRECT_COMPONENTS p3distributed)
  21. endif()
  22. set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "DirectDevel")
  23. add_metalib(p3direct INIT init_libdirect direct.h COMPONENTS ${P3DIRECT_COMPONENTS})
  24. unset(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME)
  25. set_property(TARGET p3direct PROPERTY LINKER_LANGUAGE "CXX")
  26. # Installation:
  27. install(TARGETS p3direct
  28. EXPORT Direct COMPONENT Direct
  29. DESTINATION ${CMAKE_INSTALL_LIBDIR}
  30. RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  31. ARCHIVE COMPONENT DirectDevel)
  32. if(HAVE_PYTHON)
  33. # Now for the Python side of everything
  34. add_python_module(panda3d.direct
  35. p3dcparser p3deadrec p3distributed p3interval
  36. p3motiontrail p3showbase LINK p3direct IMPORT panda3d.core COMPONENT Direct)
  37. # Copy Python source files into the build directory
  38. install_python_package(direct SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/src" LIB COMPONENT Direct)
  39. # This bit is to generate the 'pandac' compatibility shim. It's deprecated now,
  40. # but in older versions of Panda3D, one would use
  41. # from pandac.PandaModules import *
  42. # instead of
  43. # from panda3d.FOO import *
  44. # Generate PandaModules:
  45. file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/pandac/PandaModules.py"
  46. "\"This module is deprecated. Import from panda3d.core and other panda3d.* modules instead.\"
  47. if __debug__:
  48. print(\"Warning: pandac.PandaModules is deprecated, import from panda3d.core instead\")\n")
  49. foreach(module ${ALL_INTERROGATE_MODULES})
  50. string(REGEX REPLACE "^.*\\." "" module_name "${module}")
  51. file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/pandac/PandaModules.py" "
  52. try:
  53. from ${module} import *
  54. except ImportError as err:
  55. if not (\"No module named\" in str(err) and \"${module_name}\" in str(err)):
  56. raise
  57. ")
  58. endforeach()
  59. file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/pandac/PandaModules.py"
  60. "from direct.showbase import DConfig
  61. def get_config_showbase():
  62. return DConfig
  63. def get_config_express():
  64. return DConfig
  65. getConfigShowbase = get_config_showbase
  66. getConfigExpress = get_config_express
  67. ")
  68. # Now install ourselves:
  69. install_python_package(pandac SOURCE "${CMAKE_CURRENT_BINARY_DIR}/pandac" LIB COMPONENT Direct)
  70. endif()
  71. # "Direct" component contains both the Python stuff and the non-Python stuff,
  72. # because direct has a pretty solid dependency on Python.
  73. export_targets(Direct NAMESPACE "Panda3D::Direct::" COMPONENT DirectDevel)