Skip to content

Commit 3bebfb6

Browse files
Include dependencies for static library
1 parent 305b31b commit 3bebfb6

2 files changed

Lines changed: 39 additions & 4 deletions

File tree

configure/template.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
@PACKAGE_INIT@
22

3+
# For static libraries, consumers need to find dependencies
4+
if(NOT BUILD_SHARED_LIBS)
5+
include(CMakeFindDependencyMacro)
6+
find_dependency(ferror QUIET)
7+
find_dependency(collections QUIET)
8+
find_dependency(geompack QUIET)
9+
find_dependency(fstring QUIET)
10+
endif()
11+
312
if(NOT TARGET "@PROJECT_NAME@::@PROJECT_NAME@")
413
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake")
514
endif()

src/CMakeLists.txt

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,18 +163,44 @@ install(
163163
)
164164
install(DIRECTORY ${FPLOT_MOD_DIR} DESTINATION ${CMAKE_INSTALL_MODULEDIR})
165165

166-
if (${BUILD_FERROR} AND ${BUILD_SHARED_LIBS})
166+
# For static libraries, install dependency libraries
167+
if(NOT BUILD_SHARED_LIBS)
168+
# Install fetched dependency libraries if they were built
169+
if(${BUILD_FERROR})
170+
install(TARGETS ${FERROR_LIBRARIES}
171+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
172+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
173+
endif()
174+
if(${BUILD_COLLECTIONS})
175+
install(TARGETS ${COLLECTIONS_LIBRARIES}
176+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
177+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
178+
endif()
179+
if(${BUILD_GEOMPACK})
180+
install(TARGETS ${GEOMPACK_LIBRARIES}
181+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
182+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
183+
endif()
184+
if(${BUILD_FSTRING})
185+
install(TARGETS ${FSTRING_LIBRARIES}
186+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
187+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
188+
endif()
189+
endif()
190+
191+
# For shared libraries, install runtime artifacts
192+
if(${BUILD_FERROR} AND ${BUILD_SHARED_LIBS})
167193
install(IMPORTED_RUNTIME_ARTIFACTS ${FERROR_LIBRARIES})
168194
endif()
169195

170-
if (${BUILD_COLLECTIONS} AND ${BUILD_SHARED_LIBS})
196+
if(${BUILD_COLLECTIONS} AND ${BUILD_SHARED_LIBS})
171197
install(IMPORTED_RUNTIME_ARTIFACTS ${COLLECTIONS_LIBRARIES})
172198
endif()
173199

174-
if (${BUILD_GEOMPACK} AND ${BUILD_SHARED_LIBS})
200+
if(${BUILD_GEOMPACK} AND ${BUILD_SHARED_LIBS})
175201
install(IMPORTED_RUNTIME_ARTIFACTS ${GEOMPACK_LIBRARIES})
176202
endif()
177203

178-
if (${BUILD_FSTRING} AND ${BUILD_SHARED_LIBS})
204+
if(${BUILD_FSTRING} AND ${BUILD_SHARED_LIBS})
179205
install(IMPORTED_RUNTIME_ARTIFACTS ${FSTRING_LIBRARIES})
180206
endif()

0 commit comments

Comments
 (0)