diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index aa9490d..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,33 +15,25 @@ 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: | 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: | - TAG="${{ steps.version.outputs.tag }}" - mkdir -p dist/release - zip -r "dist/release/abcmake-package-${TAG}.zip" dist/package + python scripts/build_single_file.py --check || python scripts/build_single_file.py + echo "Generated dist/single_file/ab.cmake" - name: Upload release artifact uses: actions/upload-artifact@v4 @@ -49,7 +41,6 @@ jobs: name: abcmake-${{ steps.version.outputs.tag }} path: | dist/single_file/ab.cmake - dist/release/abcmake-package-${{ steps.version.outputs.tag }}.zip - name: Create GitHub Release uses: softprops/action-gh-release@v2 @@ -60,6 +51,5 @@ 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 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + 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 e6ff035..72aa578 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 ) @@ -53,6 +54,22 @@ install(FILES DESTINATION ${ABCMAKE_INSTALL_CMAKEDIR} ) +# 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_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}\") +") + # 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..87add8c 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,41 +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. -## Installation +## 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) +- [Limitations](#limitations) +- [Contributing](#contributing) +- [Changelog](#changelog) +- [License](#license) -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`. +## Quick Start -Optional (submodules / vendored): you can also keep the whole repository and include via `set(ABCMAKE_PATH path/to/src)` & `include(${ABCMAKE_PATH}/ab.cmake)`. +### Install -## Quick Start +**Project Scope**. Download a single-file distribution and put near your CMakeLists.txt: + +- + +**User Scope**. Clone the repo and install it in your system: + +```bash +git clone https://github.com/you/abcmake.git +cd abcmake +cmake -B build +cmake --install build --prefix ~/.local +``` + +For Windows: + +- Use `$env:LOCALAPPDATA\CMake` instead of `~/.local` also append the path: + +```cmake +list(APPEND CMAKE_PREFIX_PATH "$ENV{LOCALAPPDATA}/CMake") +find_package(abcmake REQUIRED) +``` + +**System-wide Scope**. Change prefix to `/usr/local` (Linux) or `C:\Program Files\CMake` (Windows), run with elevated privileges + +```bash +git clone https://github.com/you/abcmake.git +cd abcmake +cmake -B build +sudo cmake --install build --prefix /usr/local +``` + +### Use 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 distribution + add_main_component(${PROJECT_NAME}) ``` @@ -72,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 | -|------|---------| -| 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 @@ -136,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 @@ -176,3 +208,4 @@ See [CHANGELOG.md](CHANGELOG.md) for structured history. MIT License © Andrei Gramakov. +See [LICENSE](LICENSE) for details. diff --git a/docs/README/header.drawio.svg b/docs/README/header.drawio.svg new file mode 100644 index 0000000..28bb87c --- /dev/null +++ b/docs/README/header.drawio.svg @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + +
+
+
+ ABCmake +
+
+
+
+ + ABCmake + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + Text is not SVG - cannot display + + + +
diff --git a/scripts/build_package.ps1 b/scripts/build_package.ps1 deleted file mode 100644 index bdca707..0000000 --- a/scripts/build_package.ps1 +++ /dev/null @@ -1,20 +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 -# -# ************************************************************************* - - -pushd $PSScriptRoot/.. - -mkdir -Force build -cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install -G "Ninja" -cmake --build build --config Release --target all -cmake --install build --config Release --prefix dist/package