diff --git a/.devcontainer b/.devcontainer new file mode 160000 index 0000000000..af6b864abe --- /dev/null +++ b/.devcontainer @@ -0,0 +1 @@ +Subproject commit af6b864abe2df4237df0d71df82a476c1daab1e5 diff --git a/.github/workflows/xpbuild.yml b/.github/workflows/xpbuild.yml new file mode 100644 index 0000000000..169ff5269c --- /dev/null +++ b/.github/workflows/xpbuild.yml @@ -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 diff --git a/.github/workflows/xprelease.yml b/.github/workflows/xprelease.yml new file mode 100644 index 0000000000..146191466e --- /dev/null +++ b/.github/workflows/xprelease.yml @@ -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 diff --git a/.gitignore b/.gitignore index 997e51e1a3..333bf5ecf6 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,7 @@ tags libssh2.pc TAGS *~ +# externpro +.env +_bld*/ +docker-compose.override.yml diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..18932abfb9 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule ".devcontainer"] + path = .devcontainer + url = https://github.com/externpro/externpro diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f57866e77..48ce563389 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") @@ -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}) @@ -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() diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000000..f82cfdd2cf --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,8 @@ +{ + "version": 8, + "include": [ + ".devcontainer/cmake/presets/xpLinuxNinja.json", + ".devcontainer/cmake/presets/xpDarwinNinja.json", + ".devcontainer/cmake/presets/xpWindowsVs2022.json" + ] +} diff --git a/CMakePresetsBase.json b/CMakePresetsBase.json new file mode 100644 index 0000000000..e193a06bc9 --- /dev/null +++ b/CMakePresetsBase.json @@ -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 + } + ] +} diff --git a/docker-compose.sh b/docker-compose.sh new file mode 120000 index 0000000000..85f182f0be --- /dev/null +++ b/docker-compose.sh @@ -0,0 +1 @@ +.devcontainer/compose.pro.sh \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 120000 index 0000000000..46c1f8918f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1 @@ +.devcontainer/compose.bld.yml \ No newline at end of file diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 5002089d28..9d505873bb 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -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() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4586671a5c..8f30081700 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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") @@ -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) @@ -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}) @@ -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 @@ -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 @@ -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}) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ffbd835bac..1463331568 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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")