From 536a581d9eb9067b2c959ca95e98bdef5d740a25 Mon Sep 17 00:00:00 2001 From: Todor Prokopov Date: Mon, 21 Nov 2022 16:56:52 +0200 Subject: [PATCH] Install CMake export --- CMakeLists.txt | 2 ++ backend/CMakeLists.txt | 19 +++++++++++++++++-- zint-config.cmake.in | 5 +++++ 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 zint-config.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 246dd646..e01905ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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. diff --git a/backend/CMakeLists.txt b/backend/CMakeLists.txt index 184e89a0..7a365f69 100644 --- a/backend/CMakeLists.txt +++ b/backend/CMakeLists.txt @@ -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 + $ + $ +) + 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) diff --git a/zint-config.cmake.in b/zint-config.cmake.in new file mode 100644 index 00000000..0ad7a579 --- /dev/null +++ b/zint-config.cmake.in @@ -0,0 +1,5 @@ +if(@ZINT_USE_PNG@) + include(CMakeFindDependencyMacro) + find_dependency(PNG) +endif() +include("${CMAKE_CURRENT_LIST_DIR}/zint-targets.cmake")