Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,32 @@ jobs:
cd docs
npm install
npm run build

verify_fetchcontent:
# Graaf is commonly consumed via FetchContent. This builds a minimal
# standalone project that does exactly that, to catch regressions in our
# own CMakeLists.txt that only surface when Graaf is a subproject rather
# than top-level (see #310/#312).
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v7

- name: Configure consumer project
run: cmake -B ${{github.workspace}}/consumer-build -S ${{github.workspace}}/cmake_integration/consumer -DGRAAF_SOURCE_DIR=${{github.workspace}}

- name: Build consumer project
run: cmake --build ${{github.workspace}}/consumer-build

- name: Run consumer executable
run: ${{github.workspace}}/consumer-build/consumer

- name: Install consumer project
run: cmake --install ${{github.workspace}}/consumer-build --prefix ${{github.workspace}}/consumer-install

- name: Verify no pkgconfig file leaked from the FetchContent dependency
run: |
if [ -f "${{github.workspace}}/consumer-install/lib/pkgconfig/graaf.pc" ]; then
echo "::error::graaf.pc should not be installed when Graaf is consumed via FetchContent"
exit 1
fi
18 changes: 18 additions & 0 deletions cmake_integration/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# CMake integration check

`consumer/` is a minimal standalone CMake project that consumes Graaf via
`FetchContent`, the same way a real downstream project would. It exists to
catch regressions in Graaf's own `CMakeLists.txt` that only surface when
Graaf is built as a subproject rather than top-level (see #310/#312).

Run it locally from the repo root:

```bash
cmake -B /tmp/graaf-consumer-build -S cmake_integration/consumer -DGRAAF_SOURCE_DIR="$(pwd)"
cmake --build /tmp/graaf-consumer-build
cmake --install /tmp/graaf-consumer-build --prefix /tmp/graaf-consumer-install
```

This should succeed, and `/tmp/graaf-consumer-install/lib/pkgconfig/graaf.pc`
should **not** exist (pkgconfig generation is only meant for a top-level
Graaf build).
21 changes: 21 additions & 0 deletions cmake_integration/consumer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
cmake_minimum_required(VERSION 3.11...3.25)

project(GraafFetchContentConsumer LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include(FetchContent)
FetchContent_Declare(
graaf
SOURCE_DIR ${GRAAF_SOURCE_DIR}
)
set(SKIP_EXAMPLES ON CACHE BOOL "" FORCE)
set(SKIP_TESTS ON CACHE BOOL "" FORCE)
set(SKIP_BENCHMARKS ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(graaf)

add_executable(consumer main.cpp)
target_link_libraries(consumer PRIVATE Graaf::Graaf)

install(TARGETS consumer RUNTIME DESTINATION bin)
10 changes: 10 additions & 0 deletions cmake_integration/consumer/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <graaflib/graph.h>

int main() {
graaf::undirected_graph<int, float> graph{};
const auto vertex_1{graph.add_vertex(1)};
const auto vertex_2{graph.add_vertex(2)};
graph.add_edge(vertex_1, vertex_2, 1.0F);

return graph.edge_count() == 1 ? 0 : 1;
}