Skip to content

Commit

Permalink
Add CMake config file
Browse files Browse the repository at this point in the history
  • Loading branch information
dschmidt authored and lfranchi committed Jul 29, 2012
1 parent 42db0f2 commit 80b668a
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 3 deletions.
38 changes: 35 additions & 3 deletions 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)

Expand Down Expand Up @@ -56,19 +63,44 @@ 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}
)

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
)
4 changes: 4 additions & 0 deletions QtKeychainBuildTreeSettings.cmake.in
@@ -0,0 +1,4 @@
set(QTKEYCHAIN_INCLUDE_DIRS
"@PROJECT_SOURCE_DIR@"
"@PROJECT_BINARY_DIR@"
)
20 changes: 20 additions & 0 deletions 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)
11 changes: 11 additions & 0 deletions 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()

0 comments on commit 80b668a

Please sign in to comment.