Skip to content

Commit

Permalink
cmake package config (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
simutisernestas authored Apr 8, 2022
1 parent 7d50cf7 commit a32d7e2
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ target_sources("libxmlmm"
)

install(
TARGETS "libxmlmm"
TARGETS "libxmlmm" "LibXml2" EXPORT ${PROJECT_NAME}Targets
DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(
DIRECTORY "libxmlmm"
Expand Down
41 changes: 37 additions & 4 deletions src/libdbcppp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,52 @@ file(GLOB src

target_sources(${PROJECT_NAME}
PRIVATE ${header}
PUBLIC ${header_interface}
PRIVATE ${header_interface}
PRIVATE ${src} DBCX3AdaptStructs.inl
)
set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "${header_interface}")

include(GenerateExportHeader)
generate_export_header(${PROJECT_NAME})

# install
install(
TARGETS ${PROJECT_NAME}
DESTINATION ${CMAKE_INSTALL_LIBDIR})
TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Targets
DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dbcppp)
install(
FILES
$<TARGET_PROPERTY:${PROJECT_NAME},INTERFACE_SOURCES>
$<TARGET_PROPERTY:${PROJECT_NAME},INTERFACE_SOURCES>
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dbcppp)

include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake"
VERSION ${Upstream_VERSION}
COMPATIBILITY AnyNewerVersion
)

export(EXPORT ${PROJECT_NAME}Targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Targets.cmake"
)
configure_file(cmake/${PROJECT_NAME}Config.cmake
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Config.cmake"
@ONLY
)

set(ConfigPackageLocation lib/cmake/${PROJECT_NAME})
install(EXPORT ${PROJECT_NAME}Targets
FILE
${PROJECT_NAME}Targets.cmake
DESTINATION
${ConfigPackageLocation}
)
install(
FILES
cmake/${PROJECT_NAME}Config.cmake
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION
${ConfigPackageLocation}
COMPONENT
Devel
)
1 change: 1 addition & 0 deletions src/libdbcppp/cmake/libdbcpppConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include("${CMAKE_CURRENT_LIST_DIR}/libdbcpppTargets.cmake")

0 comments on commit a32d7e2

Please sign in to comment.