[libssh]fix config.cmake error, add usage. (#5666)

This commit is contained in:
JackBoosY 2019-03-14 21:30:02 +08:00 committed by Phil Christensen
parent 62462f7162
commit 45aa34edb4
4 changed files with 87 additions and 3 deletions

View File

@ -1,5 +1,5 @@
Source: libssh Source: libssh
Version: 0.7.6 Version: 0.7.6-1
Description: libssh is a multiplatform C library implementing the SSHv2 and SSHv1 protocol on client and server side Description: libssh is a multiplatform C library implementing the SSHv2 and SSHv1 protocol on client and server side
Build-Depends: openssl Build-Depends: openssl

View File

@ -0,0 +1,77 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a063556..68e559e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,6 +11,8 @@ set(APPLICATION_VERSION_MINOR "7")
set(APPLICATION_VERSION_PATCH "6")
set(APPLICATION_VERSION "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}")
+set(CMAKE_INSTALL_DIR lib/cmake/libssh CACHE STRING
+ "The subdirectory where CMake package config files should be installed")
# SOVERSION scheme: CURRENT.AGE.REVISION
# If there was an incompatible interface change:
@@ -114,14 +116,29 @@ endif (UNIX)
set(LIBSSH_LIBRARY_NAME ${CMAKE_SHARED_LIBRARY_PREFIX}ssh${CMAKE_SHARED_LIBRARY_SUFFIX})
set(LIBSSH_THREADS_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)
+include(CMakePackageConfigHelpers)
+configure_package_config_file(
+ ${PROJECT_NAME}-config.cmake.in
+ ${PROJECT_NAME}-config.cmake
+ INSTALL_DESTINATION ${CMAKE_INSTALL_DIR}
+ PATH_VARS
+ INCLUDE_INSTALL_DIR
+ CMAKE_INSTALL_DIR
+)
+configure_package_config_file(
+ ${PROJECT_NAME}-config-version.cmake.in
+ ${PROJECT_NAME}-config-version.cmake
+ INSTALL_DESTINATION ${CMAKE_INSTALL_DIR}
+ PATH_VARS
+ INCLUDE_INSTALL_DIR
+ CMAKE_INSTALL_DIR
+)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
DESTINATION
- ${CMAKE_INSTALL_DIR}/${PROJECT_NAME}
+ ${CMAKE_INSTALL_DIR}
COMPONENT
devel
)
diff --git a/libssh-config.cmake.in b/libssh-config.cmake.in
index fa9cecf..b17fdbd 100644
--- a/libssh-config.cmake.in
+++ b/libssh-config.cmake.in
@@ -1,13 +1,22 @@
get_filename_component(LIBSSH_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
+get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../" ABSOLUTE)
if (EXISTS "${LIBSSH_CMAKE_DIR}/CMakeCache.txt")
# In build tree
include(${LIBSSH_CMAKE_DIR}/libssh-build-tree-settings.cmake)
else()
- set(LIBSSH_INCLUDE_DIR @INCLUDE_INSTALL_DIR@)
+ set(LIBSSH_INCLUDE_DIR "${PACKAGE_PREFIX_DIR}/include/")
+ set(LIBSSH_INCLUDE_DIRS "${PACKAGE_PREFIX_DIR}/include/")
endif()
-set(LIBSSH_LIBRARY @LIB_INSTALL_DIR@/@LIBSSH_LIBRARY_NAME@)
-set(LIBSSH_LIBRARIES @LIB_INSTALL_DIR@/@LIBSSH_LIBRARY_NAME@)
+if(CMAKE_BUILD_TYPE STREQUAL "Release")
+ set(LIBSSH_LIBRARY "${PACKAGE_PREFIX_DIR}/lib/ssh.lib")
+ set(LIBSSH_LIBRARIES "${PACKAGE_PREFIX_DIR}/lib/ssh.lib")
-set(LIBSSH_THREADS_LIBRARY @LIB_INSTALL_DIR@/@LIBSSH_THREADS_LIBRARY_NAME@)
+ set(LIBSSH_THREADS_LIBRARY "${PACKAGE_PREFIX_DIR}/lib/ssh.lib")
+elseif(CMAKE_BUILD_TYPE STREQUAL "Debug")
+ set(LIBSSH_LIBRARY "${PACKAGE_PREFIX_DIR}/debug/lib/ssh.lib")
+ set(LIBSSH_LIBRARIES "${PACKAGE_PREFIX_DIR}/debug/lib/ssh.lib")
+
+ set(LIBSSH_THREADS_LIBRARY "${PACKAGE_PREFIX_DIR}/debug/lib/ssh.lib")
+endif()

View File

@ -26,6 +26,7 @@ vcpkg_extract_source_archive_ex(
only-one-flavor-threads.patch only-one-flavor-threads.patch
"${WINPATCH}" "${WINPATCH}"
missing-includes.patch missing-includes.patch
fix-config-cmake.patch
) )
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" WITH_STATIC_LIB) string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" WITH_STATIC_LIB)
@ -46,6 +47,7 @@ vcpkg_configure_cmake(
-DWITH_NACL=OFF -DWITH_NACL=OFF
-DWITH_GSSAPI=OFF -DWITH_GSSAPI=OFF
-DWITH_ZLIB=${WITH_ZLIB} -DWITH_ZLIB=${WITH_ZLIB}
-DCMAKE_INSTALL_DIR=share/libssh
) )
vcpkg_install_cmake() vcpkg_install_cmake()
@ -69,7 +71,7 @@ file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/lib/static ${CURRENT_PACKAGES_DIR}/d
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
# The installed cmake config files are nonfunctional (0.7.5) # The installed cmake config files are nonfunctional (0.7.5)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/cmake ${CURRENT_PACKAGES_DIR}/cmake) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/lib/cmake ${CURRENT_PACKAGES_DIR}/lib/cmake)
file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/libssh RENAME copyright) file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/libssh RENAME copyright)
file(INSTALL ${CURRENT_PORT_DIR}/usage DESTINATION ${CURRENT_PACKAGES_DIR}/share/libssh)

5
ports/libssh/usage Normal file
View File

@ -0,0 +1,5 @@
The package libssh is compatible with built-in CMake targets:
find_package(libssh CONFIG REQUIRED)
target_link_libraries(main PRIVATE ${LIBSSH_LIBRARIES})
target_include_directories(main PRIVATE ${LIBSSH_INCLUDE_DIRS})