Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .devcontainer
Submodule .devcontainer added at af6b86
30 changes: 30 additions & 0 deletions .github/workflows/xpbuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build
on:
push:
branches: [ "dev" ]
pull_request:
branches: [ "dev" ]
workflow_dispatch:
jobs:
linux:
uses: externpro/externpro/.github/workflows/build-linux.yml@25.06
with:
cmake-workflow-preset: Linux
runon: ubuntu-latest
secrets: inherit
linux-arm64:
uses: externpro/externpro/.github/workflows/build-linux.yml@25.06
with:
cmake-workflow-preset: Linux
runon: ubuntu-24.04-arm
secrets: inherit
macos:
uses: externpro/externpro/.github/workflows/build-macos.yml@25.06
with:
cmake-workflow-preset: Darwin
secrets: inherit
windows:
uses: externpro/externpro/.github/workflows/build-windows.yml@25.06
with:
cmake-workflow-preset: Windows
secrets: inherit
20 changes: 20 additions & 0 deletions .github/workflows/xprelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Release
on:
workflow_dispatch:
inputs:
workflow_run_url:
description: 'URL of the workflow run containing artifacts to upload (e.g., https://github.com/owner/repo/actions/runs/123456789)'
required: true
type: string
jobs:
# Upload build artifacts as release assets
release-from-build:
uses: externpro/externpro/.github/workflows/release-from-build.yml@25.06
with:
workflow_run_url: ${{ github.event.inputs.workflow_run_url }}
artifact_pattern: "*.tar.xz"
permissions:
contents: write
id-token: write
attestations: write
secrets: inherit
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ tags
libssh2.pc
TAGS
*~
# externpro
.env
_bld*/
docker-compose.override.yml
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule ".devcontainer"]
path = .devcontainer
url = https://github.com/externpro/externpro
24 changes: 14 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,28 @@

cmake_minimum_required(VERSION 2.8.11...3.21)

if(DEFINED CMAKE_MODULE_PATH)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
else()
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
endif()
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(CMAKE_PROJECT_TOP_LEVEL_INCLUDES .devcontainer/cmake/xproinc.cmake)

project(libssh2 C)
set(PROJECT_URL "https://www.libssh2.org/")
set(PROJECT_DESCRIPTION "The SSH library")
include(GNUInstallDirs)
include(xpflags)
set(targetsFile Libssh2Config)
if(NOT DEFINED XP_INSTALL_CMAKEDIR)
set(XP_INSTALL_CMAKEDIR ${CMAKE_INSTALL_DATADIR}/cmake/${PROJECT_NAME})
endif()
if(DEFINED XP_NAMESPACE)
set(XP_OPT_INSTALL EXCLUDE_FROM_ALL)
set(XP_OPT_INSTALL FALSE)
set(nameSpace ${XP_NAMESPACE}::)
xpPackageDevel(TARGETS_FILE ${targetsFile} DEPS openssl zlib
LIBRARIES ${XP_NAMESPACE}::${PROJECT_NAME}
)
else()
set(XP_OPT_INSTALL TRUE)
set(nameSpace Libssh2::)
endif()
if(NOT DEFINED XP_INSTALL_CMAKEDIR)
set(XP_INSTALL_CMAKEDIR ${CMAKE_INSTALL_DATADIR}/cmake/${PROJECT_NAME})
endif()

if (CMAKE_VERSION VERSION_LESS "3.1")
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
Expand Down Expand Up @@ -91,7 +94,6 @@ if(NOT LIBSSH2_VERSION OR
"${CMAKE_CURRENT_SOURCE_DIR}/include/libssh2.h")
endif()

include(GNUInstallDirs)
install(
FILES docs/AUTHORS COPYING docs/HACKING README RELEASE-NOTES NEWS
DESTINATION ${CMAKE_INSTALL_DOCDIR})
Expand Down Expand Up @@ -120,4 +122,6 @@ set(CPACK_PACKAGE_VERSION_MAJOR ${LIBSSH2_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${LIBSSH2_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${LIBSSH2_VERSION_PATCH})
set(CPACK_PACKAGE_VERSION ${LIBSSH2_VERSION})
if(XP_OPT_INSTALL)
include(CPack)
endif()
8 changes: 8 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"version": 8,
"include": [
".devcontainer/cmake/presets/xpLinuxNinja.json",
".devcontainer/cmake/presets/xpDarwinNinja.json",
".devcontainer/cmake/presets/xpWindowsVs2022.json"
]
}
22 changes: 22 additions & 0 deletions CMakePresetsBase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"version": 8,
"configurePresets": [
{
"name": "config-base",
"hidden": true,
"binaryDir": "${sourceDir}/_bld-${presetName}",
"cacheVariables": {
"BUILD_TESTING": "OFF",
"CRYPTO_BACKEND": "OpenSSL",
"ENABLE_ZLIB_COMPRESSION": "ON",
"XP_NAMESPACE": "xpro"
}
}
],
"buildPresets": [
{
"name": "build-base",
"hidden": true
}
]
}
1 change: 1 addition & 0 deletions docker-compose.sh
1 change: 1 addition & 0 deletions docker-compose.yml
4 changes: 3 additions & 1 deletion docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,6 @@ set(MAN_PAGES
libssh2_version.3)

include(GNUInstallDirs)
install(FILES ${MAN_PAGES} ${XP_OPT_INSTALL} DESTINATION ${CMAKE_INSTALL_MANDIR}/man3)
if(XP_OPT_INSTALL)
install(FILES ${MAN_PAGES} DESTINATION ${CMAKE_INSTALL_MANDIR}/man3)
endif()
29 changes: 12 additions & 17 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@ endif()

if(CRYPTO_BACKEND STREQUAL "OpenSSL" OR NOT CRYPTO_BACKEND)

if(COMMAND xpFindPkg)
xpFindPkg(PKGS openssl)
else()
find_package(OpenSSL ${SPECIFIC_CRYPTO_REQUIREMENT})
endif()
find_package(OpenSSL ${SPECIFIC_CRYPTO_REQUIREMENT})

if(OPENSSL_FOUND)
set(CRYPTO_BACKEND "OpenSSL")
Expand Down Expand Up @@ -244,13 +240,11 @@ option(ENABLE_ZLIB_COMPRESSION "Use zlib for compression")
add_feature_info(Compression ENABLE_ZLIB_COMPRESSION
"using zlib for compression")
if(ENABLE_ZLIB_COMPRESSION)
if(COMMAND xpFindPkg)
xpFindPkg(PKGS zlib)
else()
find_package(ZLIB REQUIRED)
target_include_directories(libssh2 PRIVATE ${ZLIB_INCLUDE_DIRS})
endif()
find_package(ZLIB REQUIRED)

if(NOT TARGET xpro::zlib)
target_include_directories(libssh2 PRIVATE ${ZLIB_INCLUDE_DIRS})
endif()
list(APPEND LIBRARIES ${ZLIB_LIBRARIES})
list(APPEND PC_REQUIRES_PRIVATE zlib)
if(ZLIB_FOUND)
Expand Down Expand Up @@ -384,7 +378,7 @@ install(FILES
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})

install(TARGETS libssh2
EXPORT Libssh2Config
EXPORT ${targetsFile}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
Expand All @@ -399,13 +393,13 @@ set(RUNTIME_DEPENDENCIES ${_RUNTIME_DEPENDENCIES} CACHE INTERNAL
# Package config

## During package installation, install Libssh2Config.cmake
install(EXPORT Libssh2Config
install(EXPORT ${targetsFile}
NAMESPACE ${nameSpace}
DESTINATION ${XP_INSTALL_CMAKEDIR})

## During build, register directly from build tree
# create Libssh2Config.cmake
export(TARGETS libssh2 NAMESPACE ${nameSpace} FILE Libssh2Config.cmake)
export(TARGETS libssh2 NAMESPACE ${nameSpace} FILE ${targetsFile}.cmake)
export(PACKAGE Libssh2) # register it

## Export a .pc file for client projects not using CMaek
Expand All @@ -416,10 +410,11 @@ if(PC_LIBS)
string(REPLACE ";" " " PC_LIBS "${PC_LIBS}")
endif()
configure_file(libssh2.pc.in libssh2.pc @ONLY)
if(XP_OPT_INSTALL)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/libssh2.pc
${XP_OPT_INSTALL}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
endif()

## Versioning

Expand All @@ -429,9 +424,9 @@ set_target_properties(libssh2 PROPERTIES

include(CMakePackageConfigHelpers)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/Libssh2ConfigVersion.cmake
${CMAKE_CURRENT_BINARY_DIR}/${targetsFile}Version.cmake
VERSION "${LIBSSH2_VERSION_MAJOR}.${LIBSSH2_VERSION_MINOR}.${LIBSSH2_VERSION_PATCH}"
COMPATIBILITY SameMajorVersion)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/Libssh2ConfigVersion.cmake
FILES ${CMAKE_CURRENT_BINARY_DIR}/${targetsFile}Version.cmake
DESTINATION ${XP_INSTALL_CMAKEDIR})
6 changes: 1 addition & 5 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,7 @@ endif()

if(CRYPTO_BACKEND STREQUAL "OpenSSL" OR NOT CRYPTO_BACKEND)

if(COMMAND xpFindPkg)
xpFindPkg(PKGS openssl)
else()
find_package(OpenSSL ${SPECIFIC_CRYPTO_REQUIREMENT})
endif()
find_package(OpenSSL ${SPECIFIC_CRYPTO_REQUIREMENT})

if(OPENSSL_FOUND)
set(CRYPTO_BACKEND "OpenSSL")
Expand Down