Browse Source

Merge branch 'cmake' of https://github.com/panda3d/panda3d into cmake

Donny Lawrence 7 years ago
parent
commit
af6c69b474

+ 9 - 2
CMakeLists.txt

@@ -33,6 +33,13 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
 
+# Runtime code assumes that dynamic modules have a "lib" prefix; Windows
+# assumes that debug libraries have a _d suffix.
+set(CMAKE_SHARED_MODULE_PREFIX "lib")
+if(WIN32)
+  set(CMAKE_DEBUG_POSTFIX "_d")
+endif()
+
 # Include global modules needed for configure scripts
 include(PackageConfig)      # Defines package_option AND target_use_packages
 
@@ -83,7 +90,7 @@ if(BUILD_MODELS)
     DESTINATION "${PROJECT_BINARY_DIR}/models/maps"
   )
   run_pzip(models
-    "${CMAKE_CURRENT_SOURCE_DIR}/models"
+    "${CMAKE_CURRENT_SOURCE_DIR}/models/"
     "${PROJECT_BINARY_DIR}/models"
     *.egg
   )
@@ -92,7 +99,7 @@ if(BUILD_MODELS)
     FILES_MATCHING PATTERN *.rgb PATTERN *.png PATTERN *.jpg PATTERN *.wav
   )
   run_pzip(dmodels
-    "${CMAKE_CURRENT_SOURCE_DIR}/dmodels/src"
+    "${CMAKE_CURRENT_SOURCE_DIR}/dmodels/src/"
     "${PROJECT_BINARY_DIR}/models"
     *.egg
   )

+ 8 - 0
cmake/macros/RunPzip.cmake

@@ -1,4 +1,12 @@
 function(run_pzip target_name source destination glob)
+  if(NOT TARGET pzip)
+    # If pzip isn't built, we just copy instead.
+    file(COPY "${source}"
+      DESTINATION "${destination}"
+      FILES_MATCHING PATTERN "${glob}")
+    return()
+  endif()
+
   file(GLOB_RECURSE files RELATIVE "${source}" "${source}/${glob}")
 
   set(dstfiles "")

+ 11 - 5
direct/CMakeLists.txt

@@ -10,18 +10,24 @@ add_subdirectory(src/deadrec)
 #add_subdirectory(src/directdServer)
 #add_subdirectory(src/directd)
 add_subdirectory(src/distributed)
-#add_subdirectory(src/heapq)
-#add_subdirectory(src/http)
 add_subdirectory(src/interval)
-#add_subdirectory(src/motiontrail)
+add_subdirectory(src/motiontrail)
 add_subdirectory(src/showbase)
 
 # TODO: p3direct needs a source file!
-add_metalib(p3direct COMPONENTS p3dcparser p3deadrec p3distributed p3interval p3showbase)
+set(P3DIRECT_COMPONENTS
+  p3dcparser p3deadrec p3directbase
+  p3interval p3motiontrail p3showbase)
+if(HAVE_PYTHON)
+  list(APPEND P3DIRECT_COMPONENTS p3distributed)
+endif()
+add_metalib(p3direct COMPONENTS ${P3DIRECT_COMPONENTS})
 set_property(TARGET p3direct PROPERTY LINKER_LANGUAGE "CXX")
 
 if(HAVE_PYTHON)
-  add_python_module(direct p3dcparser p3deadrec p3distributed p3interval p3showbase LINK p3direct IMPORT panda3d.core)
+  add_python_module(direct
+    p3dcparser p3deadrec p3distributed p3interval
+    p3motiontrail p3showbase LINK p3direct IMPORT panda3d.core)
 
   # Make an __init__.py pointing at the source directory so users can run
   # Panda3D code straight from their build path:

+ 6 - 0
direct/src/dcparse/CMakeLists.txt

@@ -1,3 +1,9 @@
+if(WIN32)
+  # We can't build dcparse on Windows, because the dcparser symbols aren't
+  # properly exported from p3direct.dll.
+  return()
+endif()
+
 add_executable(dcparse dcparse.cxx)
 target_compile_definitions(dcparse PUBLIC WITHIN_PANDA)
 target_link_libraries(dcparse p3direct)

+ 1 - 1
direct/src/directbase/CMakeLists.txt

@@ -7,7 +7,7 @@ set(P3DIRECTBASE_HEADERS
 )
 
 # Not worth compositing sources, there's really only one.
-add_library(p3directbase ${P3DIRECTBASE_HEADERS} ${P3DIRECTBASE_SOURCES})
+add_component_library(p3directbase ${P3DIRECTBASE_HEADERS} ${P3DIRECTBASE_SOURCES})
 target_link_libraries(p3directbase panda)
 
 install(TARGETS p3directbase DESTINATION lib)

+ 15 - 0
direct/src/motiontrail/CMakeLists.txt

@@ -0,0 +1,15 @@
+set(P3MOTIONTRAIL_HEADERS
+    config_motiontrail.h
+    cMotionTrail.h)
+
+set(P3MOTIONTRAIL_SOURCES
+    config_motiontrail.cxx
+    cMotionTrail.cxx)
+
+add_component_library(p3motiontrail SYMBOL BUILDING_DIRECT_MOTIONTRAIL
+  ${P3MOTIONTRAIL_HEADERS} ${P3MOTIONTRAIL_SOURCES})
+target_link_libraries(p3motiontrail p3directbase panda)
+target_interrogate(p3motiontrail ALL)
+
+install(TARGETS p3motiontrail DESTINATION lib)
+install(FILES ${P3MOTIONTRAIL_HEADERS} DESTINATION include/panda3d)

+ 6 - 5
panda/metalibs/pandagl/CMakeLists.txt

@@ -10,20 +10,21 @@ if(HAVE_GL)
   set(PANDAGL_LINK_TARGETS p3glgsg)
 
   if(HAVE_GLX)
-    list(APPEND PANDAGL_LINK_TARGETS p3glxdisplay)
+    list(APPEND PANDAGL_LINK_TARGETS p3glxdisplay p3x11display)
   endif()
+
   if(HAVE_WGL)
-    list(APPEND PANDAGL_LINK_TARGETS p3wgldisplay)
+    list(APPEND PANDAGL_LINK_TARGETS p3wgldisplay p3windisplay)
   endif()
 
   if(HAVE_COCOA)
-    set(PANDAGL_LINK_TARGETS ${PANDAGL_LINK_TARGETS} p3cocoadisplay)
+    list(APPEND PANDAGL_LINK_TARGETS p3cocoadisplay)
   endif()
   if(HAVE_CARBON)
-    set(PANDAGL_LINK_TARGETS ${PANDAGL_LINK_TARGETS} p3osxdisplay)
+    list(APPEND PANDAGL_LINK_TARGETS p3osxdisplay)
   endif()
 
-  add_metalib(pandagl pandagl.cxx COMPONENTS ${PANDAGL_LINK_TARGETS})
+  add_metalib(pandagl ${MODULE_TYPE} pandagl.cxx COMPONENTS ${PANDAGL_LINK_TARGETS})
   set_target_properties(pandagl PROPERTIES DEFINE_SYMBOL BUILDING_PANDAGL)
 
   install(TARGETS pandagl DESTINATION lib)

+ 1 - 1
panda/src/wgldisplay/CMakeLists.txt

@@ -21,4 +21,4 @@ set(P3WGLDISPLAY_SOURCES
 composite_sources(p3wgldisplay P3WGLDISPLAY_SOURCES)
 add_component_library(p3wgldisplay SYMBOL BUILDING_PANDAGL
   ${P3WGLDISPLAY_HEADERS} ${P3WGLDISPLAY_SOURCES})
-target_link_libraries(p3wgldisplay p3display p3putil p3windisplay p3glgsg)
+target_link_libraries(p3wgldisplay p3glgsg p3windisplay)

+ 1 - 1
panda/src/windisplay/CMakeLists.txt

@@ -16,4 +16,4 @@ set(P3WINDISPLAY_SOURCES
 composite_sources(p3windisplay P3WINDISPLAY_SOURCES)
 add_component_library(p3windisplay SYMBOL BUILDING_PANDAWIN
   ${P3WINDISPLAY_HEADERS} ${P3WINDISPLAY_SOURCES})
-target_link_libraries(p3windisplay p3display p3putil Imm32.lib)
+target_link_libraries(p3windisplay panda User32.lib Imm32.lib)