Export xlnt::xlnt target when installed.

Usage:
find_package(Xlnt)
target_link_libraries(foo PRIVATE xlnt::xlnt)
This commit is contained in:
Aaron Bishop 2018-08-07 09:08:29 -04:00
parent 8f39375f4c
commit ecf402972b
2 changed files with 39 additions and 2 deletions

13
cmake/XlntConfig.cmake.in Normal file
View File

@ -0,0 +1,13 @@
set(XLNT_VERSION "@xlnt_VERSION@")
@PACKAGE_INIT@
get_filename_component(XLNT_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
set_and_check(XLNT_INCLUDE_DIR "@XLNT_INCLUDE_INSTALL_DIR@")
check_required_components(xlnt)
if(NOT TARGET xlnt::xlnt)
include("${XLNT_CMAKE_DIR}/XlntTargets.cmake")
endif()

View File

@ -159,7 +159,9 @@ endif()
#target_compile_features(xlnt PUBLIC cxx_std_${XLNT_CXX_LANG})
# Includes
target_include_directories(xlnt PUBLIC ${XLNT_INCLUDE_DIR})
target_include_directories(xlnt PUBLIC
$<BUILD_INTERFACE:${XLNT_INCLUDE_DIR}>
$<INSTALL_INTERFACE:include>)
target_include_directories(xlnt PRIVATE ${XLNT_SOURCE_DIR})
target_include_directories(xlnt PRIVATE ${XLNT_SOURCE_DIR}/../third-party/libstudxml)
target_include_directories(xlnt PRIVATE ${XLNT_SOURCE_DIR}/../third-party/utfcpp)
@ -236,11 +238,33 @@ if(NOT MAN_DEST_DIR)
endif()
# Install library
install(TARGETS xlnt
install(TARGETS xlnt EXPORT XlntTargets
LIBRARY DESTINATION ${LIB_DEST_DIR}
ARCHIVE DESTINATION ${LIB_DEST_DIR}
RUNTIME DESTINATION ${BIN_DEST_DIR})
install(EXPORT XlntTargets
FILE XlntTargets.cmake
NAMESPACE xlnt::
DESTINATION lib/cmake/xlnt)
include(CMakePackageConfigHelpers)
set(XLNT_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/)
configure_package_config_file(../cmake/XlntConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/XlntConfig.cmake
INSTALL_DESTINATION lib/cmake/xlnt
PATH_VARS XLNT_INCLUDE_DIR)
write_basic_package_version_file(XlntConfigVersion.cmake
COMPATIBILITY ExactVersion)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/XlntConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/XlntConfigVersion.cmake
DESTINATION lib/cmake/xlnt)
# Install include directory
install(DIRECTORY ${XLNT_INCLUDE_DIR}/xlnt
DESTINATION include