Install CMake export

This commit is contained in:
Todor Prokopov 2022-11-21 16:56:52 +02:00
parent 66431d8ec1
commit 536a581d9e
3 changed files with 24 additions and 2 deletions

View file

@ -192,6 +192,8 @@ else()
endif()
install(FILES cmake/modules/FindZint.cmake DESTINATION ${CMAKE_MODULES_INSTALL_PATH} COMPONENT Devel)
configure_file("zint-config.cmake.in" "zint-config.cmake" @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/zint-config.cmake" DESTINATION "${SHARE_INSTALL_PREFIX}/zint")
# This needs to be run very last so other parts of the scripts can take
# advantage of this.

View file

@ -48,6 +48,15 @@ function(zint_target_compile_definitions scope definition)
endif()
endfunction()
function(zint_target_include_directories scope directory)
if(ZINT_SHARED)
target_include_directories(zint ${scope} ${directory})
endif()
if(ZINT_STATIC)
target_include_directories(zint-static ${scope} ${directory})
endif()
endfunction()
if(ZINT_SHARED)
set_target_properties(zint PROPERTIES SOVERSION "${ZINT_VERSION_MAJOR}.${ZINT_VERSION_MINOR}"
VERSION ${ZINT_VERSION})
@ -76,12 +85,18 @@ if(MSVC)
target_compile_definitions(zint PRIVATE DLL_EXPORT)
endif()
zint_target_include_directories(PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${INCLUDE_INSTALL_DIR}>
)
if(ZINT_SHARED)
install(TARGETS zint ${INSTALL_TARGETS_DEFAULT_ARGS})
install(TARGETS zint EXPORT zint-targets ${INSTALL_TARGETS_DEFAULT_ARGS})
endif()
if(ZINT_STATIC)
install(TARGETS zint-static ${INSTALL_TARGETS_DEFAULT_ARGS})
install(TARGETS zint-static EXPORT zint-targets ${INSTALL_TARGETS_DEFAULT_ARGS})
endif()
install(EXPORT zint-targets NAMESPACE zint:: DESTINATION "${SHARE_INSTALL_PREFIX}/zint")
install(FILES zint.h DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel)
if(ZINT_TEST)

5
zint-config.cmake.in Normal file
View file

@ -0,0 +1,5 @@
if(@ZINT_USE_PNG@)
include(CMakeFindDependencyMacro)
find_dependency(PNG)
endif()
include("${CMAKE_CURRENT_LIST_DIR}/zint-targets.cmake")