Skip to content

Revise README and improve untracked dependency handling #41

Revise README and improve untracked dependency handling

Revise README and improve untracked dependency handling #41

Workflow file for this run

# CI workflow for cpp-library project itself
name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
jobs:
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Run dependency mapping tests
run: cmake -P tests/install/CMakeLists.txt
- name: Run provider merging tests
run: cmake -P tests/install/test_provider_merge.cmake
integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Download CPM.cmake
run: |
mkdir -p cmake
wget -q -O cmake/CPM.cmake https://github.com/cpm-cmake/CPM.cmake/releases/latest/download/get_cpm.cmake
- name: Create test project
run: |
mkdir -p test-project/include/testlib
cd test-project
# Create CMakeLists.txt that uses cpp-library
cat > CMakeLists.txt << 'EOF'
cmake_minimum_required(VERSION 3.24)
# Setup CPM before project()
include(../cmake/CPM.cmake)
# Fetch cpp-library before project()
# Check https://github.com/stlab/cpp-library/releases for the latest version
CPMAddPackage(NAME cpp-library SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)
include(${cpp-library_SOURCE_DIR}/cpp-library.cmake)
# Enable dependency tracking before project()
cpp_library_enable_dependency_tracking()
# Now call project()
project(mylib VERSION 1.0.0)
# Create a simple test library
cpp_library_setup(
DESCRIPTION "Test library for cpp-library"
NAMESPACE testlib
HEADERS mylib.hpp
)
EOF
# Create a simple header
cat > include/testlib/mylib.hpp << 'EOF'
#pragma once
namespace testlib {
inline int get_value() { return 42; }
}
EOF
- name: Configure test project
run: |
cd test-project
cmake -B build -DCMAKE_BUILD_TYPE=Release
- name: Build test project
run: |
cd test-project
cmake --build build
- name: Install test project
run: |
cd test-project
cmake --install build --prefix ${{ runner.temp }}/install
- name: Verify installation
run: |
# Check that package config was installed
if [ ! -f "${{ runner.temp }}/install/lib/cmake/testlib-mylib/testlib-mylibConfig.cmake" ]; then
echo "Error: Package config not found"
exit 1
fi
echo "✓ Installation successful"
- name: Test find_package
run: |
mkdir -p test-consumer
cd test-consumer
# Create a consumer project
cat > CMakeLists.txt << 'EOF'
cmake_minimum_required(VERSION 3.20)
project(test-consumer)
find_package(testlib-mylib REQUIRED)
add_executable(consumer main.cpp)
target_link_libraries(consumer PRIVATE testlib::mylib)
EOF
# Create main.cpp
cat > main.cpp << 'EOF'
#include <testlib/mylib.hpp>
#include <iostream>
int main() {
std::cout << "Value: " << testlib::get_value() << std::endl;
return 0;
}
EOF
# Configure with installed package
cmake -B build -DCMAKE_PREFIX_PATH=${{ runner.temp }}/install
# Build
cmake --build build
echo "✓ Consumer project built successfully"
documentation:
name: Documentation Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Check README examples
run: |
# Extract and validate code blocks from README
grep -A 20 '```cmake' README.md | head -50
echo "✓ README documentation looks valid"
- name: Validate template files
run: |
# Check that all template files exist
test -f templates/CMakePresets.json
test -f templates/Config.cmake.in
test -f templates/Doxyfile.in
test -f templates/custom.css
echo "✓ All template files present"