Browse Source

CMake: Workaround for some export errors when doing a static build

This refuses to export/install the p3assimp/p3ptloader/p3txafile
libraries when building statically, because they depend on libraries
that are never installed, and static linkage would require all of the
dependencies to be available.

A more proper fix would involve installing these base libraries, but
only when doing a static build. I suspect nobody will ask for that,
so I haven't done it.
Sam Edwards 6 years ago
parent
commit
c16092fe8a

+ 5 - 1
pandatool/src/assimp/CMakeLists.txt

@@ -26,4 +26,8 @@ set_target_properties(p3assimp PROPERTIES DEFINE_SYMBOL BUILDING_ASSIMP)
 target_link_libraries(p3assimp PRIVATE p3pandatoolbase)
 target_link_libraries(p3assimp PRIVATE p3pandatoolbase)
 target_link_libraries(p3assimp PUBLIC PKG::ASSIMP)
 target_link_libraries(p3assimp PUBLIC PKG::ASSIMP)
 
 
-install(TARGETS p3assimp EXPORT Tools COMPONENT Tools DESTINATION ${MODULE_DESTINATION})
+if(BUILD_SHARED_LIBS)
+  # We can't install this if we're doing a static build, because it depends on
+  # a static library that isn't installed.
+  install(TARGETS p3assimp EXPORT Tools COMPONENT Tools DESTINATION ${MODULE_DESTINATION})
+endif()

+ 5 - 1
pandatool/src/egg-palettize/CMakeLists.txt

@@ -9,4 +9,8 @@ install(TARGETS egg-palettize EXPORT Tools COMPONENT Tools DESTINATION bin)
 add_library(p3txafile txaFileFilter.cxx txaFileFilter.h txaFileFilter.I)
 add_library(p3txafile txaFileFilter.cxx txaFileFilter.h txaFileFilter.I)
 set_target_properties(p3txafile PROPERTIES DEFINE_SYMBOL BUILDING_MISC)
 set_target_properties(p3txafile PROPERTIES DEFINE_SYMBOL BUILDING_MISC)
 target_link_libraries(p3txafile PRIVATE p3palettizer)
 target_link_libraries(p3txafile PRIVATE p3palettizer)
-install(TARGETS p3txafile EXPORT Tools COMPONENT Tools DESTINATION lib RUNTIME DESTINATION bin)
+if(BUILD_SHARED_LIBS)
+  # We can't install this if we're doing a static build, because it depends on
+  # a static library that isn't installed.
+  install(TARGETS p3txafile EXPORT Tools COMPONENT Tools DESTINATION lib RUNTIME DESTINATION bin)
+endif()

+ 5 - 1
pandatool/src/ptloader/CMakeLists.txt

@@ -24,4 +24,8 @@ if(HAVE_FCOLLADA)
   target_compile_definitions(p3ptloader PRIVATE HAVE_FCOLLADA)
   target_compile_definitions(p3ptloader PRIVATE HAVE_FCOLLADA)
 endif()
 endif()
 
 
-install(TARGETS p3ptloader EXPORT Tools COMPONENT Tools DESTINATION ${MODULE_DESTINATION})
+if(BUILD_SHARED_LIBS)
+  # We can't install this if we're doing a static build, because it depends on
+  # a bunch of static libraries that aren't installed.
+  install(TARGETS p3ptloader EXPORT Tools COMPONENT Tools DESTINATION ${MODULE_DESTINATION})
+endif()