aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2013-02-12 13:31:42 +0100
committerAndreas Schneider <asn@cryptomilk.org>2013-02-12 13:32:34 +0100
commit5d6cab4b14cc496382166b4fdfdf237621c93f2a (patch)
tree3d5a4a9efff5a0b0303cf40789193a4d89db3f8d
parentafe4c92bbff2bd46f5c48e50ccf2af893dc3d51b (diff)
downloadlibssh-5d6cab4b14cc496382166b4fdfdf237621c93f2a.tar.gz
libssh-5d6cab4b14cc496382166b4fdfdf237621c93f2a.tar.xz
libssh-5d6cab4b14cc496382166b4fdfdf237621c93f2a.zip
cmake: Add cmake config files for new find_package() mode.
-rw-r--r--CMakeLists.txt16
-rw-r--r--cmake/Modules/DefineInstallationPaths.cmake5
-rw-r--r--libssh-build-tree-settings.cmake.in1
-rw-r--r--libssh-config-version.cmake.in11
-rw-r--r--libssh-config.cmake.in11
5 files changed, 44 insertions, 0 deletions
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)