From 4044d1b1489f04a5b0b57e864a5646b501b58a0f Mon Sep 17 00:00:00 2001 From: Andrei Gramakov Date: Sun, 16 Nov 2025 01:16:05 +0100 Subject: [PATCH 1/7] wip --- CMakeLists.txt | 18 ++++++++++ LICENSE | 21 ++++++++++++ README.md | 72 +++++++++++++++++++++++++++++++++++++-- cmake/install.cmake.in | 61 +++++++++++++++++++++++++++++++++ scripts/build_package.ps1 | 2 +- 5 files changed, 171 insertions(+), 3 deletions(-) create mode 100644 LICENSE create mode 100644 cmake/install.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index e6ff035..0bbdd21 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,7 @@ install(FILES src/abcmake/add_component.cmake src/abcmake/register_components.cmake src/abcmake/target_link_components.cmake + LICENSE DESTINATION ${ABCMAKE_INSTALL_CMAKEDIR}/abcmake ) @@ -39,6 +40,13 @@ configure_package_config_file( PATH_VARS ABCMAKE_INSTALL_CMAKEDIR ) +# Configure install script +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/install.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/install.cmake + @ONLY +) + # Generate the version file for the config file write_basic_package_version_file( "${CMAKE_CURRENT_BINARY_DIR}/abcmakeConfigVersion.cmake" @@ -53,6 +61,16 @@ install(FILES DESTINATION ${ABCMAKE_INSTALL_CMAKEDIR} ) +# Copy installer and docs to package root +install(CODE " + file(COPY ${CMAKE_CURRENT_BINARY_DIR}/install.cmake + DESTINATION ${ABCMAKE_INSTALL_CMAKEDIR}) + file(COPY ${CMAKE_CURRENT_LIST_DIR}/LICENSE + DESTINATION ${ABCMAKE_INSTALL_CMAKEDIR}) + file(COPY ${CMAKE_CURRENT_LIST_DIR}/README.md + DESTINATION ${ABCMAKE_INSTALL_CMAKEDIR}) +") + # Display installation information message(STATUS "abcmake version ${PROJECT_VERSION}") message(STATUS "Install destination: ${CMAKE_INSTALL_PREFIX}") diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..29bfd8a --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Andrei Gramakov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index d7d4cc8..3fb7d37 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,32 @@ Simple, component‑first CMake helper for small & medium C/C++ projects. - Install step for each built target near the build dir. - Single-file distributable (`ab.cmake`) published per GitHub Release. -## Installation +- [abcmake](#abcmake) + - [Why abcmake?](#why-abcmake) + - [Features](#features) + - [Installation - Single File](#installation---single-file) + - [Installation - Packaged](#installation---packaged) + - [Automated (All Platforms)](#automated-all-platforms) + - [Environment Setup](#environment-setup) + - [Linux/macOS](#linuxmacos) + - [Windows (PowerShell)](#windows-powershell) + - [Quick Start](#quick-start) + - [Concepts](#concepts) + - [Public API](#public-api) + - [`add_main_component( [INCLUDE_DIR ...] [SOURCE_DIR ...])`](#add_main_componentname-include_dir--source_dir-) + - [`add_component( [SHARED] [INCLUDE_DIR ...] [SOURCE_DIR ...])`](#add_componentname-shared-include_dir--source_dir-) + - [`register_components( ...)`](#register_componentspath-) + - [`target_link_components( [PATH ...] [NAME ...])`](#target_link_componentstarget-path-path--name-comp-) + - [Auto Package Detection](#auto-package-detection) + - [Advanced Usage](#advanced-usage) + - [Configuration](#configuration) + - [Limitations](#limitations) + - [Release \& Single-File Build](#release--single-file-build) + - [Contributing](#contributing) + - [Changelog](#changelog) + - [License](#license) + +## Installation - Single File 1. Download `ab.cmake` from the latest [GitHub Release](https://github.com/an-dr/abcmake/releases). 2. Place it at your project root next to `CMakeLists.txt`. @@ -40,6 +65,48 @@ Simple, component‑first CMake helper for small & medium C/C++ projects. Optional (submodules / vendored): you can also keep the whole repository and include via `set(ABCMAKE_PATH path/to/src)` & `include(${ABCMAKE_PATH}/ab.cmake)`. +## Installation - Packaged + +### Automated (All Platforms) + +```bash +# Extract and run installer +unzip abcmake-package-v6_2_1.zip +cd abcmake-package-v6_2_1 +cmake -P install.cmake +``` + +**Installation paths:** +- **Linux/Unix**: `~/.local/share/cmake/abcmake` +- **macOS**: `~/Library/Application Support/CMake/share/cmake/abcmake` +- **Windows**: `%APPDATA%/CMake/share/cmake/abcmake` + +### Environment Setup + +#### Linux/macOS + +Add to `~/.bashrc` or `~/.zshrc`: + +```bash +export CMAKE_PREFIX_PATH="$HOME/.local:$CMAKE_PREFIX_PATH" # Linux +export CMAKE_PREFIX_PATH="$HOME/Library/Application Support/CMake:$CMAKE_PREFIX_PATH" # macOS +``` + +#### Windows (PowerShell) + +Add to your CMakeLists.txt: + +```cmake +list(APPEND CMAKE_PREFIX_PATH "$ENV{APPDATA}/CMake") +``` + +Or set permanently in PowerShell profile: + + +```powershell +$env:CMAKE_PREFIX_PATH = "$env:APPDATA\CMake;$env:CMAKE_PREFIX_PATH" +``` + ## Quick Start Minimal root `CMakeLists.txt`: @@ -47,7 +114,7 @@ Minimal root `CMakeLists.txt`: ```cmake cmake_minimum_required(VERSION 3.15) project(HelloWorld) -include(ab.cmake) +find_package(abcmake REQUIRED) # or include(ab.cmake) for single-file add_main_component(${PROJECT_NAME}) ``` @@ -176,3 +243,4 @@ See [CHANGELOG.md](CHANGELOG.md) for structured history. MIT License © Andrei Gramakov. +See [LICENSE](LICENSE) for details. diff --git a/cmake/install.cmake.in b/cmake/install.cmake.in new file mode 100644 index 0000000..9522f08 --- /dev/null +++ b/cmake/install.cmake.in @@ -0,0 +1,61 @@ +cmake_minimum_required(VERSION 3.16) + +set(ABCMAKE_VERSION "@ABCMAKE_VERSION@") + +# Detect OS and set installation paths +if(WIN32) + # Windows: Use %APPDATA% + if(DEFINED ENV{APPDATA}) + set(INSTALL_PREFIX "$ENV{APPDATA}/CMake") + else() + set(INSTALL_PREFIX "$ENV{USERPROFILE}/CMake") + endif() + set(INSTALL_PATH "${INSTALL_PREFIX}/share/cmake/abcmake") +elseif(APPLE) + # macOS: Use ~/Library + set(INSTALL_PREFIX "$ENV{HOME}/Library/Application Support/CMake") + set(INSTALL_PATH "${INSTALL_PREFIX}/share/cmake/abcmake") +else() + # Linux/Unix: Use ~/.local + set(INSTALL_PREFIX "$ENV{HOME}/.local") + set(INSTALL_PATH "${INSTALL_PREFIX}/share/cmake/abcmake") +endif() + +# Get script directory +get_filename_component(SCRIPT_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY) +set(SOURCE_DIR "${SCRIPT_DIR}/dist/package/share/cmake/abcmake") + +# Verify source exists +if(NOT EXISTS "${SOURCE_DIR}") + message(FATAL_ERROR "Source directory not found: ${SOURCE_DIR}\nRun this script from the extracted zip root.") +endif() + +# Remove old installation +if(EXISTS "${INSTALL_PATH}") + message(STATUS "Removing old installation: ${INSTALL_PATH}") + file(REMOVE_RECURSE "${INSTALL_PATH}") +endif() + +# Install +message(STATUS "Installing abcmake ${ABCMAKE_VERSION} to: ${INSTALL_PATH}") +file(COPY "${SOURCE_DIR}/" DESTINATION "${INSTALL_PATH}") + +# Verify installation +if(EXISTS "${INSTALL_PATH}/ab.cmake") + message(STATUS "[SUCCESS] abcmake ${ABCMAKE_VERSION} installed successfully!") + message(STATUS "") + message(STATUS "Usage in CMakeLists.txt:") + message(STATUS " find_package(abcmake @ABCMAKE_VERSION_MAJOR@.@ABCMAKE_VERSION_MINOR@ REQUIRED)") + message(STATUS " ab_component(mylib)") + message(STATUS "") + + if(WIN32) + message(STATUS "[WARNING] Windows users: Add to system PATH or set in CMakeLists.txt:") + message(STATUS " list(APPEND CMAKE_PREFIX_PATH \"${INSTALL_PREFIX}\")") + elseif(UNIX AND NOT APPLE) + message(STATUS "[WARNING] Linux: Add to ~/.bashrc or ~/.zshrc:") + message(STATUS " export CMAKE_PREFIX_PATH=\"${INSTALL_PREFIX}:\$CMAKE_PREFIX_PATH\"") + endif() +else() + message(FATAL_ERROR "Installation failed - ab.cmake not found") +endif() diff --git a/scripts/build_package.ps1 b/scripts/build_package.ps1 index bdca707..4891385 100644 --- a/scripts/build_package.ps1 +++ b/scripts/build_package.ps1 @@ -15,6 +15,6 @@ pushd $PSScriptRoot/.. mkdir -Force build -cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install -G "Ninja" +cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=dist/package -G "Ninja" cmake --build build --config Release --target all cmake --install build --config Release --prefix dist/package From 7f60ecc0b52be4bc391f89d7144b41d6c7272bea Mon Sep 17 00:00:00 2001 From: Andrei Gramakov Date: Sun, 16 Nov 2025 01:25:27 +0100 Subject: [PATCH 2/7] Update install script --- .github/workflows/release.yml | 28 ++++++++++++---------------- CMakeLists.txt | 16 ++++++++++++---- cmake/install.cmake.in | 6 +++--- scripts/build_package.ps1 | 26 +++++++++++++++++++++++++- 4 files changed, 52 insertions(+), 24 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index aa9490d..9de5baf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,26 +22,22 @@ jobs: sudo apt-get update sudo apt-get install -y cmake ninja-build zip - - name: Generate release artifact - run: | - python scripts/build_single_file.py --check || python scripts/build_single_file.py - echo "Generated dist/single_file/ab.cmake" - - - name: Build CMake package - run: | - pwsh scripts/build_package.ps1 - - name: Capture version id: version run: | TAG_REF="${GITHUB_REF##*/}" + VERSION="${TAG_REF#v}" echo "tag=$TAG_REF" >> $GITHUB_OUTPUT + echo "version=$VERSION" >> $GITHUB_OUTPUT - - name: Archive CMake package + - name: Generate release artifact + run: | + python scripts/build_single_file.py --check || python scripts/build_single_file.py + echo "Generated dist/single_file/ab.cmake" + + - name: Build CMake package run: | - TAG="${{ steps.version.outputs.tag }}" - mkdir -p dist/release - zip -r "dist/release/abcmake-package-${TAG}.zip" dist/package + pwsh scripts/build_package.ps1 -Version "${{ steps.version.outputs.version }}" - name: Upload release artifact uses: actions/upload-artifact@v4 @@ -49,7 +45,7 @@ jobs: name: abcmake-${{ steps.version.outputs.tag }} path: | dist/single_file/ab.cmake - dist/release/abcmake-package-${{ steps.version.outputs.tag }}.zip + dist/abcmake-package-v${{ steps.version.outputs.version }}.zip - name: Create GitHub Release uses: softprops/action-gh-release@v2 @@ -60,6 +56,6 @@ jobs: The single-file module and CMake package are attached as assets. files: | dist/single_file/ab.cmake - dist/release/abcmake-package-${{ steps.version.outputs.tag }}.zip + dist/abcmake-package-v${{ steps.version.outputs.version }}.zip env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 0bbdd21..dacbfe5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,14 +61,22 @@ install(FILES DESTINATION ${ABCMAKE_INSTALL_CMAKEDIR} ) -# Copy installer and docs to package root +# Install LICENSE to abcmake subdirectory +install(FILES + LICENSE + DESTINATION ${ABCMAKE_INSTALL_CMAKEDIR}/abcmake +) + +# Copy installer and docs to package root (CMAKE_INSTALL_PREFIX) install(CODE " file(COPY ${CMAKE_CURRENT_BINARY_DIR}/install.cmake - DESTINATION ${ABCMAKE_INSTALL_CMAKEDIR}) + DESTINATION \"\${CMAKE_INSTALL_PREFIX}\") file(COPY ${CMAKE_CURRENT_LIST_DIR}/LICENSE - DESTINATION ${ABCMAKE_INSTALL_CMAKEDIR}) + DESTINATION \"\${CMAKE_INSTALL_PREFIX}\") file(COPY ${CMAKE_CURRENT_LIST_DIR}/README.md - DESTINATION ${ABCMAKE_INSTALL_CMAKEDIR}) + DESTINATION \"\${CMAKE_INSTALL_PREFIX}\") + + message(STATUS \"Package root files installed to: \${CMAKE_INSTALL_PREFIX}\") ") # Display installation information diff --git a/cmake/install.cmake.in b/cmake/install.cmake.in index 9522f08..927c592 100644 --- a/cmake/install.cmake.in +++ b/cmake/install.cmake.in @@ -21,13 +21,13 @@ else() set(INSTALL_PATH "${INSTALL_PREFIX}/share/cmake/abcmake") endif() -# Get script directory +# Get script directory (should be package root) get_filename_component(SCRIPT_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY) -set(SOURCE_DIR "${SCRIPT_DIR}/dist/package/share/cmake/abcmake") +set(SOURCE_DIR "${SCRIPT_DIR}/share/cmake/abcmake") # Verify source exists if(NOT EXISTS "${SOURCE_DIR}") - message(FATAL_ERROR "Source directory not found: ${SOURCE_DIR}\nRun this script from the extracted zip root.") + message(FATAL_ERROR "Source directory not found: ${SOURCE_DIR}\nRun this script from the extracted package root (where install.cmake is located).") endif() # Remove old installation diff --git a/scripts/build_package.ps1 b/scripts/build_package.ps1 index 4891385..e8cfb17 100644 --- a/scripts/build_package.ps1 +++ b/scripts/build_package.ps1 @@ -11,10 +11,34 @@ # # ************************************************************************* +param( + [string]$Version = "X.X.X" +) pushd $PSScriptRoot/.. -mkdir -Force build +# Build package +mkdir -Force build | Out-Null cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=dist/package -G "Ninja" cmake --build build --config Release --target all cmake --install build --config Release --prefix dist/package + +# Create zip archive +$zipName = "abcmake-package-v$Version.zip" +$zipPath = Join-Path "dist" $zipName + +Write-Host "" +Write-Host "Creating archive: $zipName" -ForegroundColor Cyan + +# Remove existing zip if present +if (Test-Path $zipPath) { + Remove-Item $zipPath -Force +} + +# Create zip from package directory +Compress-Archive -Path "dist/package/*" -DestinationPath $zipPath -CompressionLevel Optimal + +Write-Host "Archive created successfully: $zipPath" -ForegroundColor Green +Write-Host "Archive size: $([math]::Round((Get-Item $zipPath).Length / 1KB, 2)) KB" -ForegroundColor Gray + +popd From 1e4ad91f1ccdbbbb54bdf775ff0ee3eb52902fec Mon Sep 17 00:00:00 2001 From: Andrei Gramakov Date: Sun, 16 Nov 2025 10:55:02 +0100 Subject: [PATCH 3/7] wip --- README.md | 82 +++++++++++++++++------------------ docs/README/header.drawio.svg | 48 ++++++++++++++++++++ 2 files changed, 89 insertions(+), 41 deletions(-) create mode 100644 docs/README/header.drawio.svg diff --git a/README.md b/README.md index 3fb7d37..0214c1a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# abcmake +
-
+![logo](docs/README/header.drawio.svg) Simple, component‑first CMake helper for small & medium C/C++ projects. @@ -13,13 +13,13 @@ Simple, component‑first CMake helper for small & medium C/C++ projects. ## Why abcmake? -| Problem | What abcmake Gives You | -|---------|------------------------| +| Problem | What abcmake Gives You | +| ----------------------------------------------- | ---------------------------------------------------------- | | Repeating `add_library` + globbing everywhere | Single `add_main_component()` + auto component discovery | -| Hard to reuse internal modules | Component folders become portable units | -| Tedious dependency wiring | `target_link_components()` + optional registry by name | -| Vendored CMake packages cumbersome | Auto‑detect `*Config.cmake` in `components/` and link | -| Monolithic CMakeLists.txt growth | Split naturally by component directory | +| Hard to reuse internal modules | Component folders become portable units | +| Tedious dependency wiring | `target_link_components()` + optional registry by name | +| Vendored CMake packages cumbersome | Auto‑detect `*Config.cmake` in `components/` and link | +| Monolithic CMakeLists.txt growth | Split naturally by component directory | ## Features @@ -31,31 +31,31 @@ Simple, component‑first CMake helper for small & medium C/C++ projects. - Generates `compile_commands.json`. - Install step for each built target near the build dir. - Single-file distributable (`ab.cmake`) published per GitHub Release. - - [abcmake](#abcmake) - - [Why abcmake?](#why-abcmake) - - [Features](#features) - - [Installation - Single File](#installation---single-file) - - [Installation - Packaged](#installation---packaged) - - [Automated (All Platforms)](#automated-all-platforms) - - [Environment Setup](#environment-setup) - - [Linux/macOS](#linuxmacos) - - [Windows (PowerShell)](#windows-powershell) - - [Quick Start](#quick-start) - - [Concepts](#concepts) - - [Public API](#public-api) - - [`add_main_component( [INCLUDE_DIR ...] [SOURCE_DIR ...])`](#add_main_componentname-include_dir--source_dir-) - - [`add_component( [SHARED] [INCLUDE_DIR ...] [SOURCE_DIR ...])`](#add_componentname-shared-include_dir--source_dir-) - - [`register_components( ...)`](#register_componentspath-) - - [`target_link_components( [PATH ...] [NAME ...])`](#target_link_componentstarget-path-path--name-comp-) - - [Auto Package Detection](#auto-package-detection) - - [Advanced Usage](#advanced-usage) - - [Configuration](#configuration) - - [Limitations](#limitations) - - [Release \& Single-File Build](#release--single-file-build) - - [Contributing](#contributing) - - [Changelog](#changelog) - - [License](#license) + + - [Why abcmake?](#why-abcmake) + - [Features](#features) + - [Installation - Single File](#installation---single-file) + - [Installation - Packaged](#installation---packaged) + - [Automated (All Platforms)](#automated-all-platforms) + - [Environment Setup](#environment-setup) + - [Linux/macOS](#linuxmacos) + - [Windows (PowerShell)](#windows-powershell) + - [Quick Start](#quick-start) + - [Concepts](#concepts) + - [Public API](#public-api) + - [`add_main_component( [INCLUDE_DIR ...] [SOURCE_DIR ...])`](#add_main_componentname-include_dir--source_dir-) + - [`add_component( [SHARED] [INCLUDE_DIR ...] [SOURCE_DIR ...])`](#add_componentname-shared-include_dir--source_dir-) + - [`register_components( ...)`](#register_componentspath-) + - [`target_link_components( [PATH ...] [NAME ...])`](#target_link_componentstarget-path-path--name-comp-) + - [Auto Package Detection](#auto-package-detection) + - [Advanced Usage](#advanced-usage) + - [Configuration](#configuration) + - [Limitations](#limitations) + - [Release \& Single-File Build](#release--single-file-build) + - [Contributing](#contributing) + - [Changelog](#changelog) + - [License](#license) ## Installation - Single File @@ -77,6 +77,7 @@ cmake -P install.cmake ``` **Installation paths:** + - **Linux/Unix**: `~/.local/share/cmake/abcmake` - **macOS**: `~/Library/Application Support/CMake/share/cmake/abcmake` - **Windows**: `%APPDATA%/CMake/share/cmake/abcmake` @@ -102,7 +103,6 @@ list(APPEND CMAKE_PREFIX_PATH "$ENV{APPDATA}/CMake") Or set permanently in PowerShell profile: - ```powershell $env:CMAKE_PREFIX_PATH = "$env:APPDATA\CMake;$env:CMAKE_PREFIX_PATH" ``` @@ -145,12 +145,12 @@ add_component(${PROJECT_NAME}) ## Concepts -| Term | Meaning | -|------|---------| -| Component | A folder with its own `CMakeLists.txt` that calls `add_component` or `add_main_component`. | -| Main component | The top-level executable (or library) defined with `add_main_component`. | -| Registry | A global list of discovered components (added via `register_components`). | -| Auto package | A directory under `components/` containing `*Config.cmake` -> treated as a CMake package. | +| Term | Meaning | +| -------------- | ------------------------------------------------------------------------------------------------ | +| Component | A folder with its own `CMakeLists.txt` that calls `add_component` or `add_main_component`. | +| Main component | The top-level executable (or library) defined with `add_main_component`. | +| Registry | A global list of discovered components (added via `register_components`). | +| Auto package | A directory under `components/` containing `*Config.cmake` -> treated as a CMake package. | ## Public API @@ -207,8 +207,8 @@ add_main_component(App SOURCE_DIR source INCLUDE_DIR include) Environment variables: -| Variable | Effect | -|----------|--------| +| Variable | Effect | +| ------------------- | --------------------------- | | `ABCMAKE_EMOJI=1` | Fancy emoji output in logs. | ## Limitations diff --git a/docs/README/header.drawio.svg b/docs/README/header.drawio.svg new file mode 100644 index 0000000..240d725 --- /dev/null +++ b/docs/README/header.drawio.svg @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ ABCmake +
+
+
+
+ + ABCmake + +
+
+
+
+ + + + + Text is not SVG - cannot display + + + +
From a4a8990af0147374b6be79fe429afae1c0b175cd Mon Sep 17 00:00:00 2001 From: Andrei Gramakov Date: Mon, 17 Nov 2025 10:56:15 +0100 Subject: [PATCH 4/7] wip 2 --- cmake/install.cmake.in | 61 ------------------------------------------ 1 file changed, 61 deletions(-) delete mode 100644 cmake/install.cmake.in diff --git a/cmake/install.cmake.in b/cmake/install.cmake.in deleted file mode 100644 index 927c592..0000000 --- a/cmake/install.cmake.in +++ /dev/null @@ -1,61 +0,0 @@ -cmake_minimum_required(VERSION 3.16) - -set(ABCMAKE_VERSION "@ABCMAKE_VERSION@") - -# Detect OS and set installation paths -if(WIN32) - # Windows: Use %APPDATA% - if(DEFINED ENV{APPDATA}) - set(INSTALL_PREFIX "$ENV{APPDATA}/CMake") - else() - set(INSTALL_PREFIX "$ENV{USERPROFILE}/CMake") - endif() - set(INSTALL_PATH "${INSTALL_PREFIX}/share/cmake/abcmake") -elseif(APPLE) - # macOS: Use ~/Library - set(INSTALL_PREFIX "$ENV{HOME}/Library/Application Support/CMake") - set(INSTALL_PATH "${INSTALL_PREFIX}/share/cmake/abcmake") -else() - # Linux/Unix: Use ~/.local - set(INSTALL_PREFIX "$ENV{HOME}/.local") - set(INSTALL_PATH "${INSTALL_PREFIX}/share/cmake/abcmake") -endif() - -# Get script directory (should be package root) -get_filename_component(SCRIPT_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY) -set(SOURCE_DIR "${SCRIPT_DIR}/share/cmake/abcmake") - -# Verify source exists -if(NOT EXISTS "${SOURCE_DIR}") - message(FATAL_ERROR "Source directory not found: ${SOURCE_DIR}\nRun this script from the extracted package root (where install.cmake is located).") -endif() - -# Remove old installation -if(EXISTS "${INSTALL_PATH}") - message(STATUS "Removing old installation: ${INSTALL_PATH}") - file(REMOVE_RECURSE "${INSTALL_PATH}") -endif() - -# Install -message(STATUS "Installing abcmake ${ABCMAKE_VERSION} to: ${INSTALL_PATH}") -file(COPY "${SOURCE_DIR}/" DESTINATION "${INSTALL_PATH}") - -# Verify installation -if(EXISTS "${INSTALL_PATH}/ab.cmake") - message(STATUS "[SUCCESS] abcmake ${ABCMAKE_VERSION} installed successfully!") - message(STATUS "") - message(STATUS "Usage in CMakeLists.txt:") - message(STATUS " find_package(abcmake @ABCMAKE_VERSION_MAJOR@.@ABCMAKE_VERSION_MINOR@ REQUIRED)") - message(STATUS " ab_component(mylib)") - message(STATUS "") - - if(WIN32) - message(STATUS "[WARNING] Windows users: Add to system PATH or set in CMakeLists.txt:") - message(STATUS " list(APPEND CMAKE_PREFIX_PATH \"${INSTALL_PREFIX}\")") - elseif(UNIX AND NOT APPLE) - message(STATUS "[WARNING] Linux: Add to ~/.bashrc or ~/.zshrc:") - message(STATUS " export CMAKE_PREFIX_PATH=\"${INSTALL_PREFIX}:\$CMAKE_PREFIX_PATH\"") - endif() -else() - message(FATAL_ERROR "Installation failed - ab.cmake not found") -endif() From eae8e7fade1789579b01cbb70b4a3fc429895c71 Mon Sep 17 00:00:00 2001 From: Andrei Gramakov Date: Mon, 17 Nov 2025 11:35:46 +0100 Subject: [PATCH 5/7] Clean up --- .github/workflows/release.yml | 10 +- CHANGELOG.md | 5 +- CMakeLists.txt | 7 - README copy.md | 246 ++++++++++++++++++++++++++++++++++ README.md | 151 ++++++++------------- docs/README/header.drawio.svg | 14 +- scripts/build_package.ps1 | 44 ------ 7 files changed, 315 insertions(+), 162 deletions(-) create mode 100644 README copy.md delete mode 100644 scripts/build_package.ps1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9de5baf..af233d7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,7 +3,7 @@ name: Generate Release on: push: tags: - - 'v*.*.*' + - "v*.*.*" jobs: build-release: @@ -15,7 +15,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.x' + python-version: "3.x" - name: Install CMake and Ninja run: | @@ -35,17 +35,12 @@ jobs: python scripts/build_single_file.py --check || python scripts/build_single_file.py echo "Generated dist/single_file/ab.cmake" - - name: Build CMake package - run: | - pwsh scripts/build_package.ps1 -Version "${{ steps.version.outputs.version }}" - - name: Upload release artifact uses: actions/upload-artifact@v4 with: name: abcmake-${{ steps.version.outputs.tag }} path: | dist/single_file/ab.cmake - dist/abcmake-package-v${{ steps.version.outputs.version }}.zip - name: Create GitHub Release uses: softprops/action-gh-release@v2 @@ -56,6 +51,5 @@ jobs: The single-file module and CMake package are attached as assets. files: | dist/single_file/ab.cmake - dist/abcmake-package-v${{ steps.version.outputs.version }}.zip env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 96197b2..3224850 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,10 @@ 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.2.1] - 2025-11-15 +## [Unreleased] -### Added +- ... -- Introduce abcmake CMake package ## [6.2.0] - 2025-09-17 diff --git a/CMakeLists.txt b/CMakeLists.txt index dacbfe5..cc4c2d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,13 +40,6 @@ configure_package_config_file( PATH_VARS ABCMAKE_INSTALL_CMAKEDIR ) -# Configure install script -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/cmake/install.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/install.cmake - @ONLY -) - # Generate the version file for the config file write_basic_package_version_file( "${CMAKE_CURRENT_BINARY_DIR}/abcmakeConfigVersion.cmake" diff --git a/README copy.md b/README copy.md new file mode 100644 index 0000000..0214c1a --- /dev/null +++ b/README copy.md @@ -0,0 +1,246 @@ +
+ +![logo](docs/README/header.drawio.svg) + +Simple, component‑first CMake helper for small & medium C/C++ projects. + +[![GitHub Release](https://img.shields.io/github/v/release/an-dr/abcmake?label=latest%20release)](https://github.com/an-dr/abcmake/releases) +[![Build Test](https://github.com/an-dr/abcmake/actions/workflows/test.yml/badge.svg)](https://github.com/an-dr/abcmake/actions/workflows/test.yml) + +
+ +`abcmake` (Andrei's Build CMake subsystem) lets you structure a codebase as independent *components* with minimal boilerplate: drop folders under `components/`, call one function, get targets, includes, and linking done automatically. + +## Why abcmake? + +| Problem | What abcmake Gives You | +| ----------------------------------------------- | ---------------------------------------------------------- | +| Repeating `add_library` + globbing everywhere | Single `add_main_component()` + auto component discovery | +| Hard to reuse internal modules | Component folders become portable units | +| Tedious dependency wiring | `target_link_components()` + optional registry by name | +| Vendored CMake packages cumbersome | Auto‑detect `*Config.cmake` in `components/` and link | +| Monolithic CMakeLists.txt growth | Split naturally by component directory | + +## Features + +- Zero external Python/CMake dependency beyond stock CMake (>= 3.5). +- Conventional project layout with overridable source/include directories. +- Automatic recursive discovery & linking of nested components. +- Registry for linking components by *name* rather than path. +- Auto-detection of vendored CMake packages (`*Config.cmake`). +- Generates `compile_commands.json`. +- Install step for each built target near the build dir. +- Single-file distributable (`ab.cmake`) published per GitHub Release. +- [abcmake](#abcmake) + + - [Why abcmake?](#why-abcmake) + - [Features](#features) + - [Installation - Single File](#installation---single-file) + - [Installation - Packaged](#installation---packaged) + - [Automated (All Platforms)](#automated-all-platforms) + - [Environment Setup](#environment-setup) + - [Linux/macOS](#linuxmacos) + - [Windows (PowerShell)](#windows-powershell) + - [Quick Start](#quick-start) + - [Concepts](#concepts) + - [Public API](#public-api) + - [`add_main_component( [INCLUDE_DIR ...] [SOURCE_DIR ...])`](#add_main_componentname-include_dir--source_dir-) + - [`add_component( [SHARED] [INCLUDE_DIR ...] [SOURCE_DIR ...])`](#add_componentname-shared-include_dir--source_dir-) + - [`register_components( ...)`](#register_componentspath-) + - [`target_link_components( [PATH ...] [NAME ...])`](#target_link_componentstarget-path-path--name-comp-) + - [Auto Package Detection](#auto-package-detection) + - [Advanced Usage](#advanced-usage) + - [Configuration](#configuration) + - [Limitations](#limitations) + - [Release \& Single-File Build](#release--single-file-build) + - [Contributing](#contributing) + - [Changelog](#changelog) + - [License](#license) + +## Installation - Single File + +1. Download `ab.cmake` from the latest [GitHub Release](https://github.com/an-dr/abcmake/releases). +2. Place it at your project root next to `CMakeLists.txt`. +3. `include(ab.cmake)` in your root `CMakeLists.txt`. + +Optional (submodules / vendored): you can also keep the whole repository and include via `set(ABCMAKE_PATH path/to/src)` & `include(${ABCMAKE_PATH}/ab.cmake)`. + +## Installation - Packaged + +### Automated (All Platforms) + +```bash +# Extract and run installer +unzip abcmake-package-v6_2_1.zip +cd abcmake-package-v6_2_1 +cmake -P install.cmake +``` + +**Installation paths:** + +- **Linux/Unix**: `~/.local/share/cmake/abcmake` +- **macOS**: `~/Library/Application Support/CMake/share/cmake/abcmake` +- **Windows**: `%APPDATA%/CMake/share/cmake/abcmake` + +### Environment Setup + +#### Linux/macOS + +Add to `~/.bashrc` or `~/.zshrc`: + +```bash +export CMAKE_PREFIX_PATH="$HOME/.local:$CMAKE_PREFIX_PATH" # Linux +export CMAKE_PREFIX_PATH="$HOME/Library/Application Support/CMake:$CMAKE_PREFIX_PATH" # macOS +``` + +#### Windows (PowerShell) + +Add to your CMakeLists.txt: + +```cmake +list(APPEND CMAKE_PREFIX_PATH "$ENV{APPDATA}/CMake") +``` + +Or set permanently in PowerShell profile: + +```powershell +$env:CMAKE_PREFIX_PATH = "$env:APPDATA\CMake;$env:CMAKE_PREFIX_PATH" +``` + +## Quick Start + +Minimal root `CMakeLists.txt`: + +```cmake +cmake_minimum_required(VERSION 3.15) +project(HelloWorld) +find_package(abcmake REQUIRED) # or include(ab.cmake) for single-file +add_main_component(${PROJECT_NAME}) +``` + +Project layout: + +```text +project/ + CMakeLists.txt + ab.cmake + src/ + main.cpp + include/ (optional public headers) + components/ + mylib/ + src/ ... + include/ ... + CMakeLists.txt (uses abcmake + add_component()) +``` + +Add a component (`components/mylib/CMakeLists.txt`): + +```cmake +cmake_minimum_required(VERSION 3.15) +project(mylib) +include($ENV{ABCMAKE_PATH}/ab.cmake) # or relative path if local copy +add_component(${PROJECT_NAME}) +``` + +## Concepts + +| Term | Meaning | +| -------------- | ------------------------------------------------------------------------------------------------ | +| Component | A folder with its own `CMakeLists.txt` that calls `add_component` or `add_main_component`. | +| Main component | The top-level executable (or library) defined with `add_main_component`. | +| Registry | A global list of discovered components (added via `register_components`). | +| Auto package | A directory under `components/` containing `*Config.cmake` -> treated as a CMake package. | + +## Public API + +### `add_main_component( [INCLUDE_DIR ...] [SOURCE_DIR ...])` + +Creates an executable (or top-level library) and automatically: + +- Adds sources from provided `SOURCE_DIR` list (default `src`). +- Adds include dirs (default `include` if exists). +- Discovers & links nested components in `components/`. + +### `add_component( [SHARED] [INCLUDE_DIR ...] [SOURCE_DIR ...])` + +Defines a static (default) or shared library component with the same discovery & inclusion mechanics. + +### `register_components( ...)` + +Registers components so you can later link by name instead of path. + +### `target_link_components( [PATH ...] [NAME ...])` + +Links components to a target via explicit paths and/or previously registered names. + +#### Auto Package Detection + +Any directory in `components/` containing a `*Config.cmake` is probed with `find_package( CONFIG PATHS NO_DEFAULT_PATH QUIET)`. Targets `` or `::` are auto-linked if present. + +## Advanced Usage + +Linking multiple sources & includes: + +```cmake +add_component(core \ + INCLUDE_DIR include public_api \ + SOURCE_DIR src generated) +``` + +Mix path + name linking: + +```cmake +register_components(${CMAKE_CURRENT_LIST_DIR}/libs/math) +target_link_components(app \ + PATH ${CMAKE_CURRENT_LIST_DIR}/libs/io \ + NAME math) +``` + +Custom project layout (no `src/`): + +```cmake +add_main_component(App SOURCE_DIR source INCLUDE_DIR include) +``` + +## Configuration + +Environment variables: + +| Variable | Effect | +| ------------------- | --------------------------- | +| `ABCMAKE_EMOJI=1` | Fancy emoji output in logs. | + +## Limitations + +- One logical component per `CMakeLists.txt` (keep them focused). +- Designed for small/medium modular trees; very large monorepos may prefer native CMake patterns. + +## Release & Single-File Build + +The single-file `ab.cmake` is generated automatically during tagged releases (`v*.*.*`). It is not stored in the repository. + +Generate locally: + +```bash +python scripts/build_single_file.py +``` + +Download instead: [GitHub Releases](https://github.com/an-dr/abcmake/releases) + +## Contributing + +1. Fork & branch. +2. Run the test suite: `python -m unittest discover -v` (from `tests/`). +3. Regenerate single file if you touch core logic: `python scripts/build_single_file.py` (optional for dev). +4. Keep PRs focused & update the **Unreleased** section in `CHANGELOG.md`. + +## Changelog + +See [CHANGELOG.md](CHANGELOG.md) for structured history. + +## License + +MIT License © Andrei Gramakov. + +See [LICENSE](LICENSE) for details. diff --git a/README.md b/README.md index 0214c1a..87add8c 100644 --- a/README.md +++ b/README.md @@ -13,108 +13,92 @@ Simple, component‑first CMake helper for small & medium C/C++ projects. ## Why abcmake? -| Problem | What abcmake Gives You | -| ----------------------------------------------- | ---------------------------------------------------------- | +| Problem | What abcmake Gives You | +| --------------------------------------------- | -------------------------------------------------------- | | Repeating `add_library` + globbing everywhere | Single `add_main_component()` + auto component discovery | -| Hard to reuse internal modules | Component folders become portable units | -| Tedious dependency wiring | `target_link_components()` + optional registry by name | -| Vendored CMake packages cumbersome | Auto‑detect `*Config.cmake` in `components/` and link | -| Monolithic CMakeLists.txt growth | Split naturally by component directory | +| Hard to reuse internal modules | Component folders become portable units | +| Tedious dependency wiring | `target_link_components()` + optional registry by name | +| Vendored CMake packages cumbersome | Auto‑detect `*Config.cmake` in `components/` and link | +| Monolithic CMakeLists.txt growth | Split naturally by component directory | ## Features -- Zero external Python/CMake dependency beyond stock CMake (>= 3.5). +- Zero external Python/CMake dependency beyond stock CMake (>= 3.15). - Conventional project layout with overridable source/include directories. - Automatic recursive discovery & linking of nested components. - Registry for linking components by *name* rather than path. - Auto-detection of vendored CMake packages (`*Config.cmake`). -- Generates `compile_commands.json`. +- Generates `compile_commands.json` by default. - Install step for each built target near the build dir. - Single-file distributable (`ab.cmake`) published per GitHub Release. -- [abcmake](#abcmake) - - - [Why abcmake?](#why-abcmake) - - [Features](#features) - - [Installation - Single File](#installation---single-file) - - [Installation - Packaged](#installation---packaged) - - [Automated (All Platforms)](#automated-all-platforms) - - [Environment Setup](#environment-setup) - - [Linux/macOS](#linuxmacos) - - [Windows (PowerShell)](#windows-powershell) - - [Quick Start](#quick-start) - - [Concepts](#concepts) - - [Public API](#public-api) + +## Table Of Contents + +- [Why abcmake?](#why-abcmake) +- [Features](#features) +- [Table Of Contents](#table-of-contents) +- [Quick Start](#quick-start) + - [Install](#install) + - [Use](#use) +- [Concepts](#concepts) +- [Public API](#public-api) - [`add_main_component( [INCLUDE_DIR ...] [SOURCE_DIR ...])`](#add_main_componentname-include_dir--source_dir-) - [`add_component( [SHARED] [INCLUDE_DIR ...] [SOURCE_DIR ...])`](#add_componentname-shared-include_dir--source_dir-) - [`register_components( ...)`](#register_componentspath-) - [`target_link_components( [PATH ...] [NAME ...])`](#target_link_componentstarget-path-path--name-comp-) - - [Auto Package Detection](#auto-package-detection) - - [Advanced Usage](#advanced-usage) - - [Configuration](#configuration) - - [Limitations](#limitations) - - [Release \& Single-File Build](#release--single-file-build) - - [Contributing](#contributing) - - [Changelog](#changelog) - - [License](#license) - -## Installation - Single File - -1. Download `ab.cmake` from the latest [GitHub Release](https://github.com/an-dr/abcmake/releases). -2. Place it at your project root next to `CMakeLists.txt`. -3. `include(ab.cmake)` in your root `CMakeLists.txt`. - -Optional (submodules / vendored): you can also keep the whole repository and include via `set(ABCMAKE_PATH path/to/src)` & `include(${ABCMAKE_PATH}/ab.cmake)`. - -## Installation - Packaged - -### Automated (All Platforms) + - [Auto Package Detection](#auto-package-detection) +- [Advanced Usage](#advanced-usage) +- [Limitations](#limitations) +- [Contributing](#contributing) +- [Changelog](#changelog) +- [License](#license) -```bash -# Extract and run installer -unzip abcmake-package-v6_2_1.zip -cd abcmake-package-v6_2_1 -cmake -P install.cmake -``` - -**Installation paths:** +## Quick Start -- **Linux/Unix**: `~/.local/share/cmake/abcmake` -- **macOS**: `~/Library/Application Support/CMake/share/cmake/abcmake` -- **Windows**: `%APPDATA%/CMake/share/cmake/abcmake` +### Install -### Environment Setup +**Project Scope**. Download a single-file distribution and put near your CMakeLists.txt: -#### Linux/macOS +- -Add to `~/.bashrc` or `~/.zshrc`: +**User Scope**. Clone the repo and install it in your system: ```bash -export CMAKE_PREFIX_PATH="$HOME/.local:$CMAKE_PREFIX_PATH" # Linux -export CMAKE_PREFIX_PATH="$HOME/Library/Application Support/CMake:$CMAKE_PREFIX_PATH" # macOS +git clone https://github.com/you/abcmake.git +cd abcmake +cmake -B build +cmake --install build --prefix ~/.local ``` -#### Windows (PowerShell) +For Windows: -Add to your CMakeLists.txt: +- Use `$env:LOCALAPPDATA\CMake` instead of `~/.local` also append the path: ```cmake -list(APPEND CMAKE_PREFIX_PATH "$ENV{APPDATA}/CMake") +list(APPEND CMAKE_PREFIX_PATH "$ENV{LOCALAPPDATA}/CMake") +find_package(abcmake REQUIRED) ``` -Or set permanently in PowerShell profile: +**System-wide Scope**. Change prefix to `/usr/local` (Linux) or `C:\Program Files\CMake` (Windows), run with elevated privileges -```powershell -$env:CMAKE_PREFIX_PATH = "$env:APPDATA\CMake;$env:CMAKE_PREFIX_PATH" +```bash +git clone https://github.com/you/abcmake.git +cd abcmake +cmake -B build +sudo cmake --install build --prefix /usr/local ``` -## Quick Start +### Use Minimal root `CMakeLists.txt`: ```cmake cmake_minimum_required(VERSION 3.15) project(HelloWorld) -find_package(abcmake REQUIRED) # or include(ab.cmake) for single-file + +find_package(abcmake REQUIRED) +# or include(ab.cmake) for single-file distribution + add_main_component(${PROJECT_NAME}) ``` @@ -139,18 +123,20 @@ Add a component (`components/mylib/CMakeLists.txt`): ```cmake cmake_minimum_required(VERSION 3.15) project(mylib) -include($ENV{ABCMAKE_PATH}/ab.cmake) # or relative path if local copy + +find_package(abcmake REQUIRED) + add_component(${PROJECT_NAME}) ``` ## Concepts -| Term | Meaning | -| -------------- | ------------------------------------------------------------------------------------------------ | +| Term | Meaning | +| -------------- | ------------------------------------------------------------------------------------------ | | Component | A folder with its own `CMakeLists.txt` that calls `add_component` or `add_main_component`. | -| Main component | The top-level executable (or library) defined with `add_main_component`. | -| Registry | A global list of discovered components (added via `register_components`). | -| Auto package | A directory under `components/` containing `*Config.cmake` -> treated as a CMake package. | +| Main component | The top-level executable (or library) defined with `add_main_component`. | +| Registry | A global list of discovered components (added via `register_components`). | +| Auto package | A directory under `components/` containing `*Config.cmake` -> treated as a CMake package. | ## Public API @@ -203,37 +189,16 @@ Custom project layout (no `src/`): add_main_component(App SOURCE_DIR source INCLUDE_DIR include) ``` -## Configuration - -Environment variables: - -| Variable | Effect | -| ------------------- | --------------------------- | -| `ABCMAKE_EMOJI=1` | Fancy emoji output in logs. | - ## Limitations - One logical component per `CMakeLists.txt` (keep them focused). - Designed for small/medium modular trees; very large monorepos may prefer native CMake patterns. -## Release & Single-File Build - -The single-file `ab.cmake` is generated automatically during tagged releases (`v*.*.*`). It is not stored in the repository. - -Generate locally: - -```bash -python scripts/build_single_file.py -``` - -Download instead: [GitHub Releases](https://github.com/an-dr/abcmake/releases) - ## Contributing 1. Fork & branch. 2. Run the test suite: `python -m unittest discover -v` (from `tests/`). -3. Regenerate single file if you touch core logic: `python scripts/build_single_file.py` (optional for dev). -4. Keep PRs focused & update the **Unreleased** section in `CHANGELOG.md`. +3. Keep PRs focused & update the **Unreleased** section in `CHANGELOG.md`. ## Changelog diff --git a/docs/README/header.drawio.svg b/docs/README/header.drawio.svg index 240d725..52bb734 100644 --- a/docs/README/header.drawio.svg +++ b/docs/README/header.drawio.svg @@ -1,7 +1,7 @@ - + - - + + @@ -9,9 +9,9 @@ - + - + @@ -19,9 +19,9 @@ - + - +
diff --git a/scripts/build_package.ps1 b/scripts/build_package.ps1 deleted file mode 100644 index e8cfb17..0000000 --- a/scripts/build_package.ps1 +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env pwsh -# ************************************************************************* -# -# Copyright (c) 2025 Andrei Gramakov. All rights reserved. -# -# This file is licensed under the terms of the MIT license. -# For a copy, see: https://opensource.org/licenses/MIT -# -# site: https://agramakov.me -# e-mail: mail@agramakov.me -# -# ************************************************************************* - -param( - [string]$Version = "X.X.X" -) - -pushd $PSScriptRoot/.. - -# Build package -mkdir -Force build | Out-Null -cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=dist/package -G "Ninja" -cmake --build build --config Release --target all -cmake --install build --config Release --prefix dist/package - -# Create zip archive -$zipName = "abcmake-package-v$Version.zip" -$zipPath = Join-Path "dist" $zipName - -Write-Host "" -Write-Host "Creating archive: $zipName" -ForegroundColor Cyan - -# Remove existing zip if present -if (Test-Path $zipPath) { - Remove-Item $zipPath -Force -} - -# Create zip from package directory -Compress-Archive -Path "dist/package/*" -DestinationPath $zipPath -CompressionLevel Optimal - -Write-Host "Archive created successfully: $zipPath" -ForegroundColor Green -Write-Host "Archive size: $([math]::Round((Get-Item $zipPath).Length / 1KB, 2)) KB" -ForegroundColor Gray - -popd From 3949d6c2a0feac8115a47f591d6173175a6b9cb6 Mon Sep 17 00:00:00 2001 From: Andrei Gramakov Date: Mon, 17 Nov 2025 11:48:07 +0100 Subject: [PATCH 6/7] Update readme --- README copy.md | 246 ---------------------------------- docs/README/header.drawio.svg | 55 +++++--- 2 files changed, 39 insertions(+), 262 deletions(-) delete mode 100644 README copy.md diff --git a/README copy.md b/README copy.md deleted file mode 100644 index 0214c1a..0000000 --- a/README copy.md +++ /dev/null @@ -1,246 +0,0 @@ -
- -![logo](docs/README/header.drawio.svg) - -Simple, component‑first CMake helper for small & medium C/C++ projects. - -[![GitHub Release](https://img.shields.io/github/v/release/an-dr/abcmake?label=latest%20release)](https://github.com/an-dr/abcmake/releases) -[![Build Test](https://github.com/an-dr/abcmake/actions/workflows/test.yml/badge.svg)](https://github.com/an-dr/abcmake/actions/workflows/test.yml) - -
- -`abcmake` (Andrei's Build CMake subsystem) lets you structure a codebase as independent *components* with minimal boilerplate: drop folders under `components/`, call one function, get targets, includes, and linking done automatically. - -## Why abcmake? - -| Problem | What abcmake Gives You | -| ----------------------------------------------- | ---------------------------------------------------------- | -| Repeating `add_library` + globbing everywhere | Single `add_main_component()` + auto component discovery | -| Hard to reuse internal modules | Component folders become portable units | -| Tedious dependency wiring | `target_link_components()` + optional registry by name | -| Vendored CMake packages cumbersome | Auto‑detect `*Config.cmake` in `components/` and link | -| Monolithic CMakeLists.txt growth | Split naturally by component directory | - -## Features - -- Zero external Python/CMake dependency beyond stock CMake (>= 3.5). -- Conventional project layout with overridable source/include directories. -- Automatic recursive discovery & linking of nested components. -- Registry for linking components by *name* rather than path. -- Auto-detection of vendored CMake packages (`*Config.cmake`). -- Generates `compile_commands.json`. -- Install step for each built target near the build dir. -- Single-file distributable (`ab.cmake`) published per GitHub Release. -- [abcmake](#abcmake) - - - [Why abcmake?](#why-abcmake) - - [Features](#features) - - [Installation - Single File](#installation---single-file) - - [Installation - Packaged](#installation---packaged) - - [Automated (All Platforms)](#automated-all-platforms) - - [Environment Setup](#environment-setup) - - [Linux/macOS](#linuxmacos) - - [Windows (PowerShell)](#windows-powershell) - - [Quick Start](#quick-start) - - [Concepts](#concepts) - - [Public API](#public-api) - - [`add_main_component( [INCLUDE_DIR ...] [SOURCE_DIR ...])`](#add_main_componentname-include_dir--source_dir-) - - [`add_component( [SHARED] [INCLUDE_DIR ...] [SOURCE_DIR ...])`](#add_componentname-shared-include_dir--source_dir-) - - [`register_components( ...)`](#register_componentspath-) - - [`target_link_components( [PATH ...] [NAME ...])`](#target_link_componentstarget-path-path--name-comp-) - - [Auto Package Detection](#auto-package-detection) - - [Advanced Usage](#advanced-usage) - - [Configuration](#configuration) - - [Limitations](#limitations) - - [Release \& Single-File Build](#release--single-file-build) - - [Contributing](#contributing) - - [Changelog](#changelog) - - [License](#license) - -## Installation - Single File - -1. Download `ab.cmake` from the latest [GitHub Release](https://github.com/an-dr/abcmake/releases). -2. Place it at your project root next to `CMakeLists.txt`. -3. `include(ab.cmake)` in your root `CMakeLists.txt`. - -Optional (submodules / vendored): you can also keep the whole repository and include via `set(ABCMAKE_PATH path/to/src)` & `include(${ABCMAKE_PATH}/ab.cmake)`. - -## Installation - Packaged - -### Automated (All Platforms) - -```bash -# Extract and run installer -unzip abcmake-package-v6_2_1.zip -cd abcmake-package-v6_2_1 -cmake -P install.cmake -``` - -**Installation paths:** - -- **Linux/Unix**: `~/.local/share/cmake/abcmake` -- **macOS**: `~/Library/Application Support/CMake/share/cmake/abcmake` -- **Windows**: `%APPDATA%/CMake/share/cmake/abcmake` - -### Environment Setup - -#### Linux/macOS - -Add to `~/.bashrc` or `~/.zshrc`: - -```bash -export CMAKE_PREFIX_PATH="$HOME/.local:$CMAKE_PREFIX_PATH" # Linux -export CMAKE_PREFIX_PATH="$HOME/Library/Application Support/CMake:$CMAKE_PREFIX_PATH" # macOS -``` - -#### Windows (PowerShell) - -Add to your CMakeLists.txt: - -```cmake -list(APPEND CMAKE_PREFIX_PATH "$ENV{APPDATA}/CMake") -``` - -Or set permanently in PowerShell profile: - -```powershell -$env:CMAKE_PREFIX_PATH = "$env:APPDATA\CMake;$env:CMAKE_PREFIX_PATH" -``` - -## Quick Start - -Minimal root `CMakeLists.txt`: - -```cmake -cmake_minimum_required(VERSION 3.15) -project(HelloWorld) -find_package(abcmake REQUIRED) # or include(ab.cmake) for single-file -add_main_component(${PROJECT_NAME}) -``` - -Project layout: - -```text -project/ - CMakeLists.txt - ab.cmake - src/ - main.cpp - include/ (optional public headers) - components/ - mylib/ - src/ ... - include/ ... - CMakeLists.txt (uses abcmake + add_component()) -``` - -Add a component (`components/mylib/CMakeLists.txt`): - -```cmake -cmake_minimum_required(VERSION 3.15) -project(mylib) -include($ENV{ABCMAKE_PATH}/ab.cmake) # or relative path if local copy -add_component(${PROJECT_NAME}) -``` - -## Concepts - -| Term | Meaning | -| -------------- | ------------------------------------------------------------------------------------------------ | -| Component | A folder with its own `CMakeLists.txt` that calls `add_component` or `add_main_component`. | -| Main component | The top-level executable (or library) defined with `add_main_component`. | -| Registry | A global list of discovered components (added via `register_components`). | -| Auto package | A directory under `components/` containing `*Config.cmake` -> treated as a CMake package. | - -## Public API - -### `add_main_component( [INCLUDE_DIR ...] [SOURCE_DIR ...])` - -Creates an executable (or top-level library) and automatically: - -- Adds sources from provided `SOURCE_DIR` list (default `src`). -- Adds include dirs (default `include` if exists). -- Discovers & links nested components in `components/`. - -### `add_component( [SHARED] [INCLUDE_DIR ...] [SOURCE_DIR ...])` - -Defines a static (default) or shared library component with the same discovery & inclusion mechanics. - -### `register_components( ...)` - -Registers components so you can later link by name instead of path. - -### `target_link_components( [PATH ...] [NAME ...])` - -Links components to a target via explicit paths and/or previously registered names. - -#### Auto Package Detection - -Any directory in `components/` containing a `*Config.cmake` is probed with `find_package( CONFIG PATHS NO_DEFAULT_PATH QUIET)`. Targets `` or `::` are auto-linked if present. - -## Advanced Usage - -Linking multiple sources & includes: - -```cmake -add_component(core \ - INCLUDE_DIR include public_api \ - SOURCE_DIR src generated) -``` - -Mix path + name linking: - -```cmake -register_components(${CMAKE_CURRENT_LIST_DIR}/libs/math) -target_link_components(app \ - PATH ${CMAKE_CURRENT_LIST_DIR}/libs/io \ - NAME math) -``` - -Custom project layout (no `src/`): - -```cmake -add_main_component(App SOURCE_DIR source INCLUDE_DIR include) -``` - -## Configuration - -Environment variables: - -| Variable | Effect | -| ------------------- | --------------------------- | -| `ABCMAKE_EMOJI=1` | Fancy emoji output in logs. | - -## Limitations - -- One logical component per `CMakeLists.txt` (keep them focused). -- Designed for small/medium modular trees; very large monorepos may prefer native CMake patterns. - -## Release & Single-File Build - -The single-file `ab.cmake` is generated automatically during tagged releases (`v*.*.*`). It is not stored in the repository. - -Generate locally: - -```bash -python scripts/build_single_file.py -``` - -Download instead: [GitHub Releases](https://github.com/an-dr/abcmake/releases) - -## Contributing - -1. Fork & branch. -2. Run the test suite: `python -m unittest discover -v` (from `tests/`). -3. Regenerate single file if you touch core logic: `python scripts/build_single_file.py` (optional for dev). -4. Keep PRs focused & update the **Unreleased** section in `CHANGELOG.md`. - -## Changelog - -See [CHANGELOG.md](CHANGELOG.md) for structured history. - -## License - -MIT License © Andrei Gramakov. - -See [LICENSE](LICENSE) for details. diff --git a/docs/README/header.drawio.svg b/docs/README/header.drawio.svg index 52bb734..28bb87c 100644 --- a/docs/README/header.drawio.svg +++ b/docs/README/header.drawio.svg @@ -1,41 +1,64 @@ - - - - - - + + - - - - + - - + + - +
-
-
+
+
ABCmake
- + ABCmake + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From e5309ef78c2d02f1926cab6cacc958cb64f56681 Mon Sep 17 00:00:00 2001 From: Andrei Gramakov Date: Mon, 17 Nov 2025 11:54:50 +0100 Subject: [PATCH 7/7] Fix CI --- CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cc4c2d4..72aa578 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,8 +62,6 @@ install(FILES # Copy installer and docs to package root (CMAKE_INSTALL_PREFIX) install(CODE " - file(COPY ${CMAKE_CURRENT_BINARY_DIR}/install.cmake - DESTINATION \"\${CMAKE_INSTALL_PREFIX}\") file(COPY ${CMAKE_CURRENT_LIST_DIR}/LICENSE DESTINATION \"\${CMAKE_INSTALL_PREFIX}\") file(COPY ${CMAKE_CURRENT_LIST_DIR}/README.md