From 5d6cab4b14cc496382166b4fdfdf237621c93f2a Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 12 Feb 2013 13:31:42 +0100 Subject: [PATCH] cmake: Add cmake config files for new find_package() mode. --- CMakeLists.txt | 16 ++++++++++++++++ cmake/Modules/DefineInstallationPaths.cmake | 5 +++++ libssh-build-tree-settings.cmake.in | 1 + libssh-config-version.cmake.in | 11 +++++++++++ libssh-config.cmake.in | 11 +++++++++++ 5 files changed, 44 insertions(+) create mode 100644 libssh-build-tree-settings.cmake.in create mode 100644 libssh-config-version.cmake.in create mode 100644 libssh-config.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index c4830c37..81ac5884 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,6 +89,22 @@ install( pkgconfig ) +# cmake config files +configure_file(libssh-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/libssh-config.cmake @ONLY) +configure_file(libssh-config-version.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/libssh-config-version.cmake @ONLY) +install( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/libssh-config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/libssh-config-version.cmake + DESTINATION + ${CMAKE_INSTALL_DIR} + COMPONENT + devel +) + +# in tree build settings +configure_file(libssh-build-tree-settings.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/libssh-build-tree-settings.cmake @ONLY) + add_subdirectory(examples) if (WITH_TESTING) diff --git a/cmake/Modules/DefineInstallationPaths.cmake b/cmake/Modules/DefineInstallationPaths.cmake index d857871e..7e22f611 100644 --- a/cmake/Modules/DefineInstallationPaths.cmake +++ b/cmake/Modules/DefineInstallationPaths.cmake @@ -4,6 +4,7 @@ if (WIN32) set(SBIN_INSTALL_DIR "." CACHE PATH "-") set(LIB_INSTALL_DIR "lib" CACHE PATH "-") set(INCLUDE_INSTALL_DIR "include" CACHE PATH "-") + set(CMAKE_INSTALL_DIR "CMake" CACHE PATH "-") set(PLUGIN_INSTALL_DIR "plugins" CACHE PATH "-") set(HTML_INSTALL_DIR "doc/HTML" CACHE PATH "-") set(ICON_INSTALL_DIR "." CACHE PATH "-") @@ -58,6 +59,10 @@ elseif (UNIX OR OS2) CACHE PATH "The subdirectory to the header prefix (default prefix/include)" ) + set(CMAKE_INSTALL_DIR + "${LIB_INSTALL_DIR}/cmake" + CACHE PATH "The subdirectory to install cmake config files") + SET(DATA_INSTALL_DIR "${DATA_INSTALL_PREFIX}" CACHE PATH "The parent directory where applications can install their data (default prefix/share/${APPLICATION_NAME})" diff --git a/libssh-build-tree-settings.cmake.in b/libssh-build-tree-settings.cmake.in new file mode 100644 index 00000000..be348b58 --- /dev/null +++ b/libssh-build-tree-settings.cmake.in @@ -0,0 +1 @@ +set(LIBSSH_INLUDE_DIRS @PROJECT_SOURCE_DIR@/include) diff --git a/libssh-config-version.cmake.in b/libssh-config-version.cmake.in new file mode 100644 index 00000000..98f292c0 --- /dev/null +++ b/libssh-config-version.cmake.in @@ -0,0 +1,11 @@ +set(PACKAGE_VERSION @APPLICATION_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() diff --git a/libssh-config.cmake.in b/libssh-config.cmake.in new file mode 100644 index 00000000..d0fb0da8 --- /dev/null +++ b/libssh-config.cmake.in @@ -0,0 +1,11 @@ +get_filename_component(LIBSSH_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) + +if (EXISTS "${LIBSSH_CMAKE_DIR}/CMakeCache.txt") + # In build tree + include(${LIBSSH_CMAKE_DIR}/libssh-build-tree-settings.cmake) +else() + set(LIBSSH_INCLUDE_DIRS @INCLUDE_INSTALL_DIR@) +endif() + +set(LIBSSH_LIRBARY @LIB_INSTALL_DIR@/libssh.so) +set(LIBSSH_LIRBARIES @LIB_INSTALL_DIR@/libssh.so)