mirror of
https://github.com/libssh2/libssh2.git
synced 2025-10-24 14:53:03 +03:00
cmake: add LIBSSH2_DISABLE_INSTALL option
To disable all installation targets. Closes #1638
This commit is contained in:
committed by
Viktor Szakats
parent
0ec6b3e842
commit
dd50a41152
@@ -172,12 +172,15 @@ if(NOT LIBSSH2_VERSION OR
|
||||
message(FATAL_ERROR "Unable to parse version from ${PROJECT_SOURCE_DIR}/include/libssh2.h")
|
||||
endif()
|
||||
|
||||
include(GNUInstallDirs)
|
||||
install(
|
||||
FILES
|
||||
COPYING NEWS README RELEASE-NOTES
|
||||
docs/AUTHORS docs/BINDINGS.md docs/HACKING.md
|
||||
DESTINATION ${CMAKE_INSTALL_DOCDIR})
|
||||
option(LIBSSH2_DISABLE_INSTALL "Disable installation targets" OFF)
|
||||
if(NOT LIBSSH2_DISABLE_INSTALL)
|
||||
include(GNUInstallDirs)
|
||||
install(
|
||||
FILES
|
||||
COPYING NEWS README RELEASE-NOTES
|
||||
docs/AUTHORS docs/BINDINGS.md docs/HACKING.md
|
||||
DESTINATION ${CMAKE_INSTALL_DOCDIR})
|
||||
endif()
|
||||
|
||||
include(PickyWarnings)
|
||||
|
||||
|
||||
@@ -40,5 +40,7 @@ libssh2_transform_makefile_inc("Makefile.am" "${CMAKE_CURRENT_BINARY_DIR}/Makefi
|
||||
# Get dist_man_MANS variable
|
||||
include("${CMAKE_CURRENT_BINARY_DIR}/Makefile.am.cmake")
|
||||
|
||||
include(GNUInstallDirs)
|
||||
install(FILES ${dist_man_MANS} DESTINATION "${CMAKE_INSTALL_MANDIR}/man3")
|
||||
if(NOT LIBSSH2_DISABLE_INSTALL)
|
||||
include(GNUInstallDirs)
|
||||
install(FILES ${dist_man_MANS} DESTINATION "${CMAKE_INSTALL_MANDIR}/man3")
|
||||
endif()
|
||||
|
||||
@@ -177,231 +177,233 @@ add_library(${LIB_NAME} ALIAS ${LIB_SELECTED})
|
||||
|
||||
## Installation
|
||||
|
||||
install(FILES
|
||||
"${PROJECT_SOURCE_DIR}/include/libssh2.h"
|
||||
"${PROJECT_SOURCE_DIR}/include/libssh2_publickey.h"
|
||||
"${PROJECT_SOURCE_DIR}/include/libssh2_sftp.h"
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
if(NOT LIBSSH2_DISABLE_INSTALL)
|
||||
install(FILES
|
||||
"${PROJECT_SOURCE_DIR}/include/libssh2.h"
|
||||
"${PROJECT_SOURCE_DIR}/include/libssh2_publickey.h"
|
||||
"${PROJECT_SOURCE_DIR}/include/libssh2_sftp.h"
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
|
||||
if(BUILD_STATIC_LIBS)
|
||||
install(TARGETS ${LIB_STATIC}
|
||||
EXPORT "${PROJECT_NAME}-targets"
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
if(BUILD_SHARED_LIBS)
|
||||
install(TARGETS ${LIB_SHARED}
|
||||
EXPORT "${PROJECT_NAME}-targets"
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
|
||||
list(APPEND __runtime_dependencies $<TARGET_FILE:${LIB_SHARED}>)
|
||||
endif()
|
||||
|
||||
set(_runtime_dependencies ${__runtime_dependencies} CACHE INTERNAL
|
||||
"Files that must be in the same directory as the executables at runtime.")
|
||||
|
||||
# Package config
|
||||
|
||||
## During package installation, install libssh2-targets.cmake
|
||||
install(EXPORT "${PROJECT_NAME}-targets"
|
||||
NAMESPACE "${PROJECT_NAME}::"
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
|
||||
|
||||
## During build, register directly from build tree
|
||||
# create libssh2-targets.cmake
|
||||
export(TARGETS ${_libssh2_export} NAMESPACE "${PROJECT_NAME}::" FILE "${PROJECT_NAME}-targets.cmake")
|
||||
export(PACKAGE ${PROJECT_NAME}) # register it
|
||||
|
||||
# Generate libssh2-config.cmake into build tree and install it with dependencies
|
||||
configure_file("${PROJECT_SOURCE_DIR}/cmake/libssh2-config.cmake.in" "${PROJECT_NAME}-config.cmake" @ONLY)
|
||||
install(
|
||||
FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
|
||||
"${PROJECT_SOURCE_DIR}/cmake/FindLibgcrypt.cmake"
|
||||
"${PROJECT_SOURCE_DIR}/cmake/FindMbedTLS.cmake"
|
||||
"${PROJECT_SOURCE_DIR}/cmake/FindWolfSSL.cmake"
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
|
||||
|
||||
# Calculate variables for pkg-config
|
||||
set(LIBSSH2_PC_LIBS_PRIVATE "")
|
||||
|
||||
set(_ldflags "")
|
||||
|
||||
# Avoid getting unnecessary -L options for known system directories.
|
||||
set(_sys_libdirs "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}")
|
||||
foreach(_libdir IN LISTS CMAKE_SYSTEM_PREFIX_PATH)
|
||||
if(_libdir MATCHES "/$")
|
||||
string(APPEND _libdir "lib")
|
||||
else()
|
||||
string(APPEND _libdir "/lib")
|
||||
if(BUILD_STATIC_LIBS)
|
||||
install(TARGETS ${LIB_STATIC}
|
||||
EXPORT "${PROJECT_NAME}-targets"
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
if(IS_DIRECTORY "${_libdir}")
|
||||
list(APPEND _sys_libdirs "${_libdir}")
|
||||
if(BUILD_SHARED_LIBS)
|
||||
install(TARGETS ${LIB_SHARED}
|
||||
EXPORT "${PROJECT_NAME}-targets"
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
|
||||
list(APPEND __runtime_dependencies $<TARGET_FILE:${LIB_SHARED}>)
|
||||
endif()
|
||||
if(DEFINED CMAKE_LIBRARY_ARCHITECTURE)
|
||||
string(APPEND _libdir "/${CMAKE_LIBRARY_ARCHITECTURE}")
|
||||
|
||||
set(_runtime_dependencies ${__runtime_dependencies} CACHE INTERNAL
|
||||
"Files that must be in the same directory as the executables at runtime.")
|
||||
|
||||
# Package config
|
||||
|
||||
## During package installation, install libssh2-targets.cmake
|
||||
install(EXPORT "${PROJECT_NAME}-targets"
|
||||
NAMESPACE "${PROJECT_NAME}::"
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
|
||||
|
||||
## During build, register directly from build tree
|
||||
# create libssh2-targets.cmake
|
||||
export(TARGETS ${_libssh2_export} NAMESPACE "${PROJECT_NAME}::" FILE "${PROJECT_NAME}-targets.cmake")
|
||||
export(PACKAGE ${PROJECT_NAME}) # register it
|
||||
|
||||
# Generate libssh2-config.cmake into build tree and install it with dependencies
|
||||
configure_file("${PROJECT_SOURCE_DIR}/cmake/libssh2-config.cmake.in" "${PROJECT_NAME}-config.cmake" @ONLY)
|
||||
install(
|
||||
FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
|
||||
"${PROJECT_SOURCE_DIR}/cmake/FindLibgcrypt.cmake"
|
||||
"${PROJECT_SOURCE_DIR}/cmake/FindMbedTLS.cmake"
|
||||
"${PROJECT_SOURCE_DIR}/cmake/FindWolfSSL.cmake"
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
|
||||
|
||||
# Calculate variables for pkg-config
|
||||
set(LIBSSH2_PC_LIBS_PRIVATE "")
|
||||
|
||||
set(_ldflags "")
|
||||
|
||||
# Avoid getting unnecessary -L options for known system directories.
|
||||
set(_sys_libdirs "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}")
|
||||
foreach(_libdir IN LISTS CMAKE_SYSTEM_PREFIX_PATH)
|
||||
if(_libdir MATCHES "/$")
|
||||
string(APPEND _libdir "lib")
|
||||
else()
|
||||
string(APPEND _libdir "/lib")
|
||||
endif()
|
||||
if(IS_DIRECTORY "${_libdir}")
|
||||
list(APPEND _sys_libdirs "${_libdir}")
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
set(_implicit_libs "")
|
||||
if(NOT MINGW AND NOT UNIX)
|
||||
set(_implicit_libs "${CMAKE_C_IMPLICIT_LINK_LIBRARIES}")
|
||||
endif()
|
||||
|
||||
set(_explicit_libdirs "")
|
||||
set(LIBSSH2_PC_REQUIRES_PRIVATE "")
|
||||
foreach(_lib IN LISTS LIBSSH2_LIBS _implicit_libs)
|
||||
if(TARGET "${_lib}")
|
||||
set(_explicit_libs "")
|
||||
get_target_property(_imported "${_lib}" IMPORTED)
|
||||
if(NOT _imported)
|
||||
# Reading the LOCATION property on non-imported target will error out.
|
||||
# Assume the user will not need this information in the .pc file.
|
||||
continue()
|
||||
endif()
|
||||
get_target_property(_libname "${_lib}" LOCATION)
|
||||
if(_libname)
|
||||
set(_explicit_libs "${_libname}")
|
||||
else()
|
||||
get_target_property(_libs "${_lib}" INTERFACE_LINK_LIBRARIES)
|
||||
if(_libs)
|
||||
set(_explicit_libs "${_libs}")
|
||||
if(DEFINED CMAKE_LIBRARY_ARCHITECTURE)
|
||||
string(APPEND _libdir "/${CMAKE_LIBRARY_ARCHITECTURE}")
|
||||
if(IS_DIRECTORY "${_libdir}")
|
||||
list(APPEND _sys_libdirs "${_libdir}")
|
||||
endif()
|
||||
get_target_property(_libdirs "${_lib}" INTERFACE_LINK_DIRECTORIES)
|
||||
if(_libdirs)
|
||||
list(APPEND _explicit_libdirs "${_libdirs}")
|
||||
endif()
|
||||
endif()
|
||||
if(NOT _libname AND NOT _libs AND NOT _libdirs)
|
||||
message(WARNING "Bad lib in library list: ${_lib}")
|
||||
endif()
|
||||
get_target_property(_modules "${_lib}" INTERFACE_LIBSSH2_PC_MODULES)
|
||||
if(_modules)
|
||||
list(APPEND LIBSSH2_PC_REQUIRES_PRIVATE "${_modules}")
|
||||
endif()
|
||||
|
||||
foreach(_lib IN LISTS _explicit_libs)
|
||||
if(_lib MATCHES "/")
|
||||
# This gets a bit more complex, because we want to specify the
|
||||
# directory separately, and only once per directory
|
||||
get_filename_component(_libdir ${_lib} DIRECTORY)
|
||||
get_filename_component(_libname ${_lib} NAME_WE)
|
||||
if(_libname MATCHES "^lib")
|
||||
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.20)
|
||||
cmake_path(SET _libdir NORMALIZE "${_libdir}")
|
||||
endif()
|
||||
list(FIND _sys_libdirs "${_libdir}" _libdir_index)
|
||||
if(_libdir_index LESS 0)
|
||||
list(APPEND _ldflags "-L${_libdir}")
|
||||
endif()
|
||||
string(REGEX REPLACE "^lib" "" _libname "${_libname}")
|
||||
list(APPEND LIBSSH2_PC_LIBS_PRIVATE "-l${_libname}")
|
||||
else()
|
||||
list(APPEND LIBSSH2_PC_LIBS_PRIVATE "${_lib}")
|
||||
endif()
|
||||
else()
|
||||
list(APPEND LIBSSH2_PC_LIBS_PRIVATE "-l${_lib}")
|
||||
endif()
|
||||
endforeach()
|
||||
elseif(_lib MATCHES "^-") # '-framework <name>'
|
||||
list(APPEND _ldflags "${_lib}")
|
||||
else()
|
||||
list(APPEND LIBSSH2_PC_LIBS_PRIVATE "-l${_lib}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
foreach(_libdir IN LISTS _explicit_libdirs)
|
||||
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.20)
|
||||
cmake_path(SET _libdir NORMALIZE "${_libdir}")
|
||||
endif()
|
||||
list(FIND _sys_libdirs "${_libdir}" _libdir_index)
|
||||
if(_libdir_index LESS 0)
|
||||
list(APPEND _ldflags "-L${_libdir}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(LIBSSH2_PC_REQUIRES_PRIVATE)
|
||||
list(REMOVE_DUPLICATES LIBSSH2_PC_REQUIRES_PRIVATE)
|
||||
string(REPLACE ";" "," LIBSSH2_PC_REQUIRES_PRIVATE "${LIBSSH2_PC_REQUIRES_PRIVATE}")
|
||||
endif()
|
||||
if(LIBSSH2_PC_LIBS_PRIVATE)
|
||||
# Remove duplicates listed next to each other
|
||||
set(_libs "")
|
||||
set(_prev "")
|
||||
foreach(_lib IN LISTS LIBSSH2_PC_LIBS_PRIVATE)
|
||||
if(NOT _prev STREQUAL _lib)
|
||||
list(APPEND _libs "${_lib}")
|
||||
set(_prev "${_lib}")
|
||||
endif()
|
||||
endforeach()
|
||||
set(LIBSSH2_PC_LIBS_PRIVATE "${_libs}")
|
||||
|
||||
string(REPLACE ";" " " LIBSSH2_PC_LIBS_PRIVATE "${LIBSSH2_PC_LIBS_PRIVATE}")
|
||||
endif()
|
||||
if(_ldflags)
|
||||
list(REMOVE_DUPLICATES _ldflags)
|
||||
string(REPLACE ";" " " _ldflags "${_ldflags}")
|
||||
set(LIBSSH2_PC_LIBS_PRIVATE "${_ldflags} ${LIBSSH2_PC_LIBS_PRIVATE}")
|
||||
string(STRIP "${LIBSSH2_PC_LIBS_PRIVATE}" LIBSSH2_PC_LIBS_PRIVATE)
|
||||
endif()
|
||||
set(_implicit_libs "")
|
||||
if(NOT MINGW AND NOT UNIX)
|
||||
set(_implicit_libs "${CMAKE_C_IMPLICIT_LINK_LIBRARIES}")
|
||||
endif()
|
||||
|
||||
# Merge pkg-config private fields into public ones when static-only
|
||||
if(BUILD_SHARED_LIBS)
|
||||
set(LIBSSH2_PC_REQUIRES "")
|
||||
set(LIBSSH2_PC_LIBS "")
|
||||
else()
|
||||
set(LIBSSH2_PC_REQUIRES "${LIBSSH2_PC_REQUIRES_PRIVATE}")
|
||||
set(LIBSSH2_PC_LIBS "${LIBSSH2_PC_LIBS_PRIVATE}")
|
||||
endif()
|
||||
set(_explicit_libdirs "")
|
||||
set(LIBSSH2_PC_REQUIRES_PRIVATE "")
|
||||
foreach(_lib IN LISTS LIBSSH2_LIBS _implicit_libs)
|
||||
if(TARGET "${_lib}")
|
||||
set(_explicit_libs "")
|
||||
get_target_property(_imported "${_lib}" IMPORTED)
|
||||
if(NOT _imported)
|
||||
# Reading the LOCATION property on non-imported target will error out.
|
||||
# Assume the user will not need this information in the .pc file.
|
||||
continue()
|
||||
endif()
|
||||
get_target_property(_libname "${_lib}" LOCATION)
|
||||
if(_libname)
|
||||
set(_explicit_libs "${_libname}")
|
||||
else()
|
||||
get_target_property(_libs "${_lib}" INTERFACE_LINK_LIBRARIES)
|
||||
if(_libs)
|
||||
set(_explicit_libs "${_libs}")
|
||||
endif()
|
||||
get_target_property(_libdirs "${_lib}" INTERFACE_LINK_DIRECTORIES)
|
||||
if(_libdirs)
|
||||
list(APPEND _explicit_libdirs "${_libdirs}")
|
||||
endif()
|
||||
endif()
|
||||
if(NOT _libname AND NOT _libs AND NOT _libdirs)
|
||||
message(WARNING "Bad lib in library list: ${_lib}")
|
||||
endif()
|
||||
get_target_property(_modules "${_lib}" INTERFACE_LIBSSH2_PC_MODULES)
|
||||
if(_modules)
|
||||
list(APPEND LIBSSH2_PC_REQUIRES_PRIVATE "${_modules}")
|
||||
endif()
|
||||
|
||||
set(prefix "${CMAKE_INSTALL_PREFIX}")
|
||||
set(exec_prefix "\${prefix}")
|
||||
if(IS_ABSOLUTE ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
set(includedir "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
else()
|
||||
set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
endif()
|
||||
if(IS_ABSOLUTE ${CMAKE_INSTALL_LIBDIR})
|
||||
set(libdir "${CMAKE_INSTALL_LIBDIR}")
|
||||
else()
|
||||
set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
|
||||
endif()
|
||||
foreach(_lib IN LISTS _explicit_libs)
|
||||
if(_lib MATCHES "/")
|
||||
# This gets a bit more complex, because we want to specify the
|
||||
# directory separately, and only once per directory
|
||||
get_filename_component(_libdir ${_lib} DIRECTORY)
|
||||
get_filename_component(_libname ${_lib} NAME_WE)
|
||||
if(_libname MATCHES "^lib")
|
||||
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.20)
|
||||
cmake_path(SET _libdir NORMALIZE "${_libdir}")
|
||||
endif()
|
||||
list(FIND _sys_libdirs "${_libdir}" _libdir_index)
|
||||
if(_libdir_index LESS 0)
|
||||
list(APPEND _ldflags "-L${_libdir}")
|
||||
endif()
|
||||
string(REGEX REPLACE "^lib" "" _libname "${_libname}")
|
||||
list(APPEND LIBSSH2_PC_LIBS_PRIVATE "-l${_libname}")
|
||||
else()
|
||||
list(APPEND LIBSSH2_PC_LIBS_PRIVATE "${_lib}")
|
||||
endif()
|
||||
else()
|
||||
list(APPEND LIBSSH2_PC_LIBS_PRIVATE "-l${_lib}")
|
||||
endif()
|
||||
endforeach()
|
||||
elseif(_lib MATCHES "^-") # '-framework <name>'
|
||||
list(APPEND _ldflags "${_lib}")
|
||||
else()
|
||||
list(APPEND LIBSSH2_PC_LIBS_PRIVATE "-l${_lib}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Generate a pkg-config file for client projects not using CMake.
|
||||
# Consumed variables:
|
||||
# exec_prefix
|
||||
# includedir
|
||||
# LIBSSH2_PC_LIBS
|
||||
# LIBSSH2_PC_LIBS_PRIVATE
|
||||
# LIBSSH2_PC_REQUIRES
|
||||
# LIBSSH2_PC_REQUIRES_PRIVATE
|
||||
# LIBSSH2_VERSION
|
||||
# libdir
|
||||
# prefix
|
||||
configure_file("${PROJECT_SOURCE_DIR}/libssh2.pc.in" "libssh2.pc" @ONLY)
|
||||
install(
|
||||
FILES "${CMAKE_CURRENT_BINARY_DIR}/libssh2.pc"
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
||||
foreach(_libdir IN LISTS _explicit_libdirs)
|
||||
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.20)
|
||||
cmake_path(SET _libdir NORMALIZE "${_libdir}")
|
||||
endif()
|
||||
list(FIND _sys_libdirs "${_libdir}" _libdir_index)
|
||||
if(_libdir_index LESS 0)
|
||||
list(APPEND _ldflags "-L${_libdir}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Consumed variables:
|
||||
# CRYPTO_BACKEND
|
||||
# LIB_NAME
|
||||
# LIB_SELECTED
|
||||
# LIB_SHARED
|
||||
# LIB_STATIC
|
||||
# LIBSSH2_USE_PKGCONFIG
|
||||
# ZLIB_FOUND
|
||||
include(CMakePackageConfigHelpers)
|
||||
write_basic_package_version_file(
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
|
||||
VERSION "${LIBSSH2_VERSION_MAJOR}.${LIBSSH2_VERSION_MINOR}.${LIBSSH2_VERSION_PATCH}"
|
||||
COMPATIBILITY SameMajorVersion)
|
||||
install(
|
||||
FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
|
||||
if(LIBSSH2_PC_REQUIRES_PRIVATE)
|
||||
list(REMOVE_DUPLICATES LIBSSH2_PC_REQUIRES_PRIVATE)
|
||||
string(REPLACE ";" "," LIBSSH2_PC_REQUIRES_PRIVATE "${LIBSSH2_PC_REQUIRES_PRIVATE}")
|
||||
endif()
|
||||
if(LIBSSH2_PC_LIBS_PRIVATE)
|
||||
# Remove duplicates listed next to each other
|
||||
set(_libs "")
|
||||
set(_prev "")
|
||||
foreach(_lib IN LISTS LIBSSH2_PC_LIBS_PRIVATE)
|
||||
if(NOT _prev STREQUAL _lib)
|
||||
list(APPEND _libs "${_lib}")
|
||||
set(_prev "${_lib}")
|
||||
endif()
|
||||
endforeach()
|
||||
set(LIBSSH2_PC_LIBS_PRIVATE "${_libs}")
|
||||
|
||||
string(REPLACE ";" " " LIBSSH2_PC_LIBS_PRIVATE "${LIBSSH2_PC_LIBS_PRIVATE}")
|
||||
endif()
|
||||
if(_ldflags)
|
||||
list(REMOVE_DUPLICATES _ldflags)
|
||||
string(REPLACE ";" " " _ldflags "${_ldflags}")
|
||||
set(LIBSSH2_PC_LIBS_PRIVATE "${_ldflags} ${LIBSSH2_PC_LIBS_PRIVATE}")
|
||||
string(STRIP "${LIBSSH2_PC_LIBS_PRIVATE}" LIBSSH2_PC_LIBS_PRIVATE)
|
||||
endif()
|
||||
|
||||
# Merge pkg-config private fields into public ones when static-only
|
||||
if(BUILD_SHARED_LIBS)
|
||||
set(LIBSSH2_PC_REQUIRES "")
|
||||
set(LIBSSH2_PC_LIBS "")
|
||||
else()
|
||||
set(LIBSSH2_PC_REQUIRES "${LIBSSH2_PC_REQUIRES_PRIVATE}")
|
||||
set(LIBSSH2_PC_LIBS "${LIBSSH2_PC_LIBS_PRIVATE}")
|
||||
endif()
|
||||
|
||||
set(prefix "${CMAKE_INSTALL_PREFIX}")
|
||||
set(exec_prefix "\${prefix}")
|
||||
if(IS_ABSOLUTE ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
set(includedir "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
else()
|
||||
set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
endif()
|
||||
if(IS_ABSOLUTE ${CMAKE_INSTALL_LIBDIR})
|
||||
set(libdir "${CMAKE_INSTALL_LIBDIR}")
|
||||
else()
|
||||
set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
|
||||
endif()
|
||||
|
||||
# Generate a pkg-config file for client projects not using CMake.
|
||||
# Consumed variables:
|
||||
# exec_prefix
|
||||
# includedir
|
||||
# LIBSSH2_PC_LIBS
|
||||
# LIBSSH2_PC_LIBS_PRIVATE
|
||||
# LIBSSH2_PC_REQUIRES
|
||||
# LIBSSH2_PC_REQUIRES_PRIVATE
|
||||
# LIBSSH2_VERSION
|
||||
# libdir
|
||||
# prefix
|
||||
configure_file("${PROJECT_SOURCE_DIR}/libssh2.pc.in" "libssh2.pc" @ONLY)
|
||||
install(
|
||||
FILES "${CMAKE_CURRENT_BINARY_DIR}/libssh2.pc"
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
||||
|
||||
# Consumed variables:
|
||||
# CRYPTO_BACKEND
|
||||
# LIB_NAME
|
||||
# LIB_SELECTED
|
||||
# LIB_SHARED
|
||||
# LIB_STATIC
|
||||
# LIBSSH2_USE_PKGCONFIG
|
||||
# ZLIB_FOUND
|
||||
include(CMakePackageConfigHelpers)
|
||||
write_basic_package_version_file(
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
|
||||
VERSION "${LIBSSH2_VERSION_MAJOR}.${LIBSSH2_VERSION_MINOR}.${LIBSSH2_VERSION_PATCH}"
|
||||
COMPATIBILITY SameMajorVersion)
|
||||
install(
|
||||
FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user