aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorChristophe Giboudeaux <christophe@krop.fr>2018-11-06 12:47:33 +0100
committerAndreas Schneider <asn@cryptomilk.org>2018-11-06 13:53:43 +0100
commitaa899f8ec06e21980403526fdb979071ecd9a65e (patch)
treed362d1793e148a7ba4018086a10ef0e9be3f1f78 /CMakeLists.txt
parentc88fb4c55b546eaa0063f651d470ed28daff0b2c (diff)
downloadlibssh-aa899f8ec06e21980403526fdb979071ecd9a65e.tar.gz
libssh-aa899f8ec06e21980403526fdb979071ecd9a65e.tar.xz
libssh-aa899f8ec06e21980403526fdb979071ecd9a65e.zip
cmake: Refresh the CMake Config files
This commit fixes a couple issues in the CMake configuration files and uses native features from CMake: * libssh-build-tree-settings.cmake is deleted. There was a typo that made this file unusable, anyway. * use the macros available in CMakePackageConfigHelpers.cmake to generate the version file and check that the files exist * Remove the LIBSSH_THREADS_LIBRARY variable, it used the non-existent LIBSSH_THREADS_LIBRARY_NAME variable. * Fix the in tree build. libssh can be used uninstalled again. Test plan: The values were tested after installing the new files and also without running 'make install'. Signed-off-by: Christophe Giboudeaux <christophe@krop.fr>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt24
1 files changed, 17 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index dbbf4c19..5f2be383 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -39,6 +39,9 @@ include(CompilerChecks.cmake)
include(MacroEnsureOutOfSourceBuild)
macro_ensure_out_of_source_build("${PROJECT_NAME} requires an out of source build. Please create a separate build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there.")
+# Copy library files to a lib sub-directory
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
+
# search for libraries
if (WITH_ZLIB)
find_package(ZLIB REQUIRED)
@@ -116,11 +119,22 @@ install(
)
endif (UNIX)
-# cmake config files
+# CMake config files
+include(CMakePackageConfigHelpers)
+
set(LIBSSH_LIBRARY_NAME ${CMAKE_SHARED_LIBRARY_PREFIX}ssh${CMAKE_SHARED_LIBRARY_SUFFIX})
-configure_file(${PROJECT_NAME}-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake @ONLY)
-configure_file(${PROJECT_NAME}-config-version.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake @ONLY)
+# libssh-config-version.cmake
+write_basic_package_version_file(libssh-config-version.cmake
+ VERSION ${PROJECT_VERSION}
+ COMPATIBILITY SameMajorVersion)
+
+# libssh-config.cmake
+configure_package_config_file(${PROJECT_NAME}-config.cmake.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
+ INSTALL_DESTINATION ${CMAKE_INSTALL_DIR}/${PROJECT_NAME}
+ PATH_VARS INCLUDE_INSTALL_DIR LIB_INSTALL_DIR)
+
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
@@ -131,10 +145,6 @@ install(
devel
)
-
-# in tree build settings
-configure_file(libssh-build-tree-settings.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/libssh-build-tree-settings.cmake @ONLY)
-
if (WITH_EXAMPLES)
add_subdirectory(examples)
endif (WITH_EXAMPLES)