diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index af233d7..7250417 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,12 +35,17 @@ jobs: python scripts/build_single_file.py --check || python scripts/build_single_file.py echo "Generated dist/single_file/ab.cmake" + - name: Generate vcpkg registry port + shell: pwsh + run: ./scripts/build_vcpkg_port.ps1 -Tag "${{ steps.version.outputs.tag }}" + - name: Upload release artifact uses: actions/upload-artifact@v4 with: name: abcmake-${{ steps.version.outputs.tag }} path: | dist/single_file/ab.cmake + dist/vcpkg-port/ - name: Create GitHub Release uses: softprops/action-gh-release@v2 @@ -49,6 +54,8 @@ jobs: body: | Automated release for ${{ steps.version.outputs.tag }}. The single-file module and CMake package are attached as assets. + + **vcpkg port**: ready-to-use port files are in the release artifacts. files: | dist/single_file/ab.cmake env: diff --git a/CHANGELOG.md b/CHANGELOG.md index b968776..fa47f36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [6.4.0] - 2026-02-08 + +### Added + +- vcpkg port files (`ports/abcmake/`) for installation via vcpkg. + +### Changed + +- Install layout: LICENSE and README now placed in the cmake package directory instead of the install prefix root, for vcpkg compatibility. + ## [6.3.0] - 2025-11-18 ### Added diff --git a/CMakeLists.txt b/CMakeLists.txt index ba1ba44..f6f7c07 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,15 +33,10 @@ install(FILES ) -# Copy installer and docs to package root (CMAKE_INSTALL_PREFIX) -install(CODE " - file(COPY ${CMAKE_CURRENT_LIST_DIR}/LICENSE - DESTINATION \"\${CMAKE_INSTALL_PREFIX}\") - file(COPY ${CMAKE_CURRENT_LIST_DIR}/README.md - DESTINATION \"\${CMAKE_INSTALL_PREFIX}\") - - message(STATUS \"Package root files installed to: \${CMAKE_INSTALL_PREFIX}\") -") +# Install docs alongside the cmake package +install(FILES LICENSE README.md + DESTINATION ${ABCMAKE_INSTALL_CMAKEDIR} +) # Display installation information message(STATUS "abcmake version ${PROJECT_VERSION}") diff --git a/README.md b/README.md index b7a0fcf..4adf10c 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,18 @@ add_component(mylib) Download [`ab.cmake`](https://github.com/an-dr/abcmake/releases/latest/download/ab.cmake) to your project root. -#### Option B: User/System-Wide +#### Option B: Package Manager (vcpkg, CPM) + +```bash +vcpkg install abcmake # vcpkg +``` + +```cmake +CPMAddPackage("gh:an-dr/abcmake@6.4.0" DOWNLOAD_ONLY YES) # CPM +include(${abcmake_SOURCE_DIR}/src/ab.cmake) +``` + +#### Option C: User/System-Wide ```bash git clone https://github.com/an-dr/abcmake.git diff --git a/docs/installation.md b/docs/installation.md index c308c60..8ba2666 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -4,16 +4,71 @@ This guide covers different methods to install and use abcmake in your projects. ## Table of Contents -- [Quick Installation](#quick-installation) +- [Using Package Managers](#using-package-managers) + - [vcpkg](#vcpkg) + - [CPM](#cpm) - [Project-Scoped Installation](#project-scoped-installation) - [User-Scoped Installation](#user-scoped-installation) - [System-Wide Installation](#system-wide-installation) - [Verification](#verification) - [Troubleshooting](#troubleshooting) -## Quick Installation +## Using Package Managers -For most users, the **project-scoped** approach is the simplest and most portable option. +If your project already uses a C++ package manager, this is the easiest way to get abcmake. + +### vcpkg + +Install via the [vcpkg](https://vcpkg.io) registry: + +```bash +vcpkg install abcmake +``` + +Or use the overlay port shipped in this repository: + +```bash +vcpkg install abcmake --overlay-ports=/path/to/abcmake/ports +``` + +Then in your CMakeLists.txt: + +```cmake +cmake_minimum_required(VERSION 3.15) +project(MyProject) + +find_package(abcmake REQUIRED) +add_main_component(${PROJECT_NAME}) +``` + +Configure with the vcpkg toolchain file as usual: + +```bash +cmake -B build -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake +``` + +### CPM + +Add abcmake with [CPM.cmake](https://github.com/cpm-cmake/CPM.cmake): + +```cmake +cmake_minimum_required(VERSION 3.15) +project(MyProject) + +include(cmake/CPM.cmake) # or however you bootstrap CPM + +CPMAddPackage( + NAME abcmake + GITHUB_REPOSITORY an-dr/abcmake + VERSION 6.4.0 + DOWNLOAD_ONLY YES +) +include(${abcmake_SOURCE_DIR}/src/ab.cmake) + +add_main_component(${PROJECT_NAME}) +``` + +`DOWNLOAD_ONLY YES` is used because abcmake is a pure CMake module - no compilation needed. ## Project-Scoped Installation diff --git a/ports/abcmake/portfile.cmake b/ports/abcmake/portfile.cmake new file mode 100644 index 0000000..7de9e1a --- /dev/null +++ b/ports/abcmake/portfile.cmake @@ -0,0 +1,19 @@ +# This overlay port installs abcmake from the local source tree. +# For the official vcpkg registry, see the release artifacts which +# contain a portfile with the correct REF and SHA512. + +set(SOURCE_PATH "${CMAKE_CURRENT_LIST_DIR}/../..") + +# abcmake is a pure CMake module - no compilation needed +set(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" +) + +vcpkg_cmake_install() + +# Remove empty directories that vcpkg doesn't expect +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug") + +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") diff --git a/ports/abcmake/vcpkg.json b/ports/abcmake/vcpkg.json new file mode 100644 index 0000000..eee1baf --- /dev/null +++ b/ports/abcmake/vcpkg.json @@ -0,0 +1,13 @@ +{ + "name": "abcmake", + "version": "6.4.0", + "description": "Simple, component-first CMake helper for small & medium C/C++ projects", + "homepage": "https://github.com/an-dr/abcmake", + "license": "MIT", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + } + ] +} diff --git a/scripts/build_vcpkg_port.ps1 b/scripts/build_vcpkg_port.ps1 new file mode 100644 index 0000000..0fcc754 --- /dev/null +++ b/scripts/build_vcpkg_port.ps1 @@ -0,0 +1,93 @@ + +<# +.SYNOPSIS + Generates a vcpkg registry port for abcmake with the correct SHA512 hash. + +.DESCRIPTION + Downloads the GitHub source tarball for a given tag, computes its SHA512, + and writes a ready-to-use portfile.cmake + vcpkg.json into dist/vcpkg-port/. + + Can be run locally or from CI. + +.PARAMETER Tag + The git tag to build the port for (e.g. "v6.4.0"). + Defaults to the tag matching the version in src/version.cmake. + +.EXAMPLE + .\scripts\build_vcpkg_port.ps1 + .\scripts\build_vcpkg_port.ps1 -Tag v6.4.0 +#> + +param( + [string]$Tag +) + +$ErrorActionPreference = "Stop" +Set-Location "$PSScriptRoot/.." + +$RepoRoot = (Resolve-Path ".").Path +$OutDir = Join-Path $RepoRoot "dist/vcpkg-port" + +# Read version from source if no tag provided +if (-not $Tag) { + $VersionLine = Get-Content (Join-Path $RepoRoot "src/version.cmake") -Raw + if ($VersionLine -match 'set\(ABCMAKE_VERSION\s+([^\)]+)\)') { + $Tag = "v$($Matches[1])" + } else { + Write-Error "Could not parse version from src/version.cmake" + exit 1 + } +} + +$Version = $Tag.TrimStart("v") +$Url = "https://github.com/an-dr/abcmake/archive/refs/tags/${Tag}.tar.gz" + +Write-Host "Tag: $Tag" +Write-Host "Version: $Version" +Write-Host "URL: $Url" + +# Download and compute SHA512 +Write-Host "Downloading tarball..." +$TempFile = [System.IO.Path]::GetTempFileName() +try { + Invoke-WebRequest -Uri $Url -OutFile $TempFile -UseBasicParsing + $Hash = (Get-FileHash -Path $TempFile -Algorithm SHA512).Hash.ToLower() + Write-Host "SHA512: $Hash" +} finally { + Remove-Item $TempFile -ErrorAction SilentlyContinue +} + +# Generate output +if (Test-Path $OutDir) { Remove-Item $OutDir -Recurse -Force } +New-Item -ItemType Directory -Path $OutDir | Out-Null + +# portfile.cmake +$Portfile = @" +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO an-dr/abcmake + REF "$Tag" + SHA512 $Hash +) + +set(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled) + +vcpkg_cmake_configure( + SOURCE_PATH "`${SOURCE_PATH}" +) + +vcpkg_cmake_install() + +file(REMOVE_RECURSE "`${CURRENT_PACKAGES_DIR}/debug") + +vcpkg_install_copyright(FILE_LIST "`${SOURCE_PATH}/LICENSE") +"@ + +Set-Content -Path (Join-Path $OutDir "portfile.cmake") -Value $Portfile -NoNewline + +# vcpkg.json +$OverlayJson = Get-Content (Join-Path $RepoRoot "ports/abcmake/vcpkg.json") -Raw +$RegistryJson = $OverlayJson -replace '"version":\s*"[^"]*"', "`"version`": `"$Version`"" +Set-Content -Path (Join-Path $OutDir "vcpkg.json") -Value $RegistryJson -NoNewline + +Write-Host "Generated port in: $OutDir" diff --git a/src/version.cmake b/src/version.cmake index 48c7802..5a4d8f8 100644 --- a/src/version.cmake +++ b/src/version.cmake @@ -1 +1 @@ -set(ABCMAKE_VERSION 6.3.0) +set(ABCMAKE_VERSION 6.4.0)