From c16092fe8ad2332a3f2ba0e703c9b854a133bb79 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Mon, 19 Aug 2019 18:49:59 -0600 Subject: [PATCH] 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. --- pandatool/src/assimp/CMakeLists.txt | 6 +++++- pandatool/src/egg-palettize/CMakeLists.txt | 6 +++++- pandatool/src/ptloader/CMakeLists.txt | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/pandatool/src/assimp/CMakeLists.txt b/pandatool/src/assimp/CMakeLists.txt index 4daec301cd..d4758f2f61 100644 --- a/pandatool/src/assimp/CMakeLists.txt +++ b/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 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() diff --git a/pandatool/src/egg-palettize/CMakeLists.txt b/pandatool/src/egg-palettize/CMakeLists.txt index 6f799a4d3c..778ff0fc6c 100644 --- a/pandatool/src/egg-palettize/CMakeLists.txt +++ b/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) set_target_properties(p3txafile PROPERTIES DEFINE_SYMBOL BUILDING_MISC) 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() diff --git a/pandatool/src/ptloader/CMakeLists.txt b/pandatool/src/ptloader/CMakeLists.txt index 66dd3b0b1a..0d98ee8377 100644 --- a/pandatool/src/ptloader/CMakeLists.txt +++ b/pandatool/src/ptloader/CMakeLists.txt @@ -24,4 +24,8 @@ if(HAVE_FCOLLADA) target_compile_definitions(p3ptloader PRIVATE HAVE_FCOLLADA) 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()