From 80b668a0740e6e896676cf5f5631ea707a3d9fd3 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Sun, 20 May 2012 14:13:40 +0200 Subject: [PATCH] Add CMake config file --- CMakeLists.txt | 38 +++++++++++++++++++++++++--- QtKeychainBuildTreeSettings.cmake.in | 4 +++ QtKeychainConfig.cmake.in | 20 +++++++++++++++ QtKeychainConfigVersion.cmake.in | 11 ++++++++ 4 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 QtKeychainBuildTreeSettings.cmake.in create mode 100644 QtKeychainConfig.cmake.in create mode 100644 QtKeychainConfigVersion.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 1442ae4..be9c526 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,13 @@ cmake_minimum_required(VERSION 2.8) project(qtkeychain) +### + +set(QTKEYCHAIN_VERSION 0) +set(QTKEYCHAIN_SOVERSION 0) + +### + set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${PROJECT_SOURCE_DIR}/cmake/Modules") include(GNUInstallDirs) @@ -56,15 +63,16 @@ else() endif() set_target_properties(qtkeychain PROPERTIES - VERSION 0 - SOVERSION 0 + VERSION ${QTKEYCHAIN_VERSION} + SOVERSION ${QTKEYCHAIN_SOVERSION} ) -install(FILES keychain.h +install(FILES keychain.h qkeychain_export.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/qtkeychain/ ) install(TARGETS qtkeychain + EXPORT QtKeychainLibraryDepends RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} @@ -72,3 +80,27 @@ install(TARGETS qtkeychain add_executable( testclient testclient.cpp ) target_link_libraries( testclient qtkeychain) + + +### +### CMake config file +### + +export(TARGETS qtkeychain FILE "${PROJECT_BINARY_DIR}/QtKeychainLibraryDepends.cmake") +export(PACKAGE QtKeychain) + +configure_file(QtKeychainBuildTreeSettings.cmake.in + "${PROJECT_BINARY_DIR}/QtKeychainBuildTreeSettings.cmake" @ONLY) +configure_file(QtKeychainConfig.cmake.in + "${PROJECT_BINARY_DIR}/QtKeychainConfig.cmake" @ONLY) +configure_file(QtKeychainConfigVersion.cmake.in + "${PROJECT_BINARY_DIR}/QtKeychainConfigVersion.cmake" @ONLY) + +install(EXPORT QtKeychainLibraryDepends + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/QtKeychain" +) + +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtKeychainConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/QtKeychainConfigVersion.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/QtKeychain +) diff --git a/QtKeychainBuildTreeSettings.cmake.in b/QtKeychainBuildTreeSettings.cmake.in new file mode 100644 index 0000000..3f9e9f6 --- /dev/null +++ b/QtKeychainBuildTreeSettings.cmake.in @@ -0,0 +1,4 @@ +set(QTKEYCHAIN_INCLUDE_DIRS + "@PROJECT_SOURCE_DIR@" + "@PROJECT_BINARY_DIR@" +) diff --git a/QtKeychainConfig.cmake.in b/QtKeychainConfig.cmake.in new file mode 100644 index 0000000..4f7f03c --- /dev/null +++ b/QtKeychainConfig.cmake.in @@ -0,0 +1,20 @@ +# - Config file for the FooBar package +# It defines the following variables +# FOOBAR_INCLUDE_DIRS - include directories for FooBar +# FOOBAR_LIBRARIES - libraries to link against +# FOOBAR_EXECUTABLE - the bar executable + +# Compute paths +get_filename_component(QTKEYCHAIN_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +if(EXISTS "${QTKEYCHAIN_CMAKE_DIR}/CMakeCache.txt") + # In build tree + include("${QTKEYCHAIN_CMAKE_DIR}/QtKeychainBuildTreeSettings.cmake") +else() + set(QTKEYCHAIN_INCLUDE_DIRS "@CMAKE_INSTALL_FULL_INCLUDEDIR@") +endif() + +# Our library dependencies (contains definitions for IMPORTED targets) +include("${QTKEYCHAIN_CMAKE_DIR}/QtKeychainLibraryDepends.cmake") + +# These are IMPORTED targets created by FooBarLibraryDepends.cmake +set(QTKEYCHAIN_LIBRARIES qtkeychain) diff --git a/QtKeychainConfigVersion.cmake.in b/QtKeychainConfigVersion.cmake.in new file mode 100644 index 0000000..fba821a --- /dev/null +++ b/QtKeychainConfigVersion.cmake.in @@ -0,0 +1,11 @@ +set(PACKAGE_VERSION "@QTKEYCHAIN_VERSION@") + +# Check whether the requested PACKAGE_FIND_VERSION is compatible +if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif()