diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7a3c9ac..5ffe4a2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,43 +47,30 @@ jobs: needs: [ lint ] runs-on: ubuntu-latest + strategy: + matrix: + example-folder: [ cmake-local, cmake-fetch-content ] + + defaults: + run: + working-directory: examples/${{ matrix.example-folder }} + steps: - uses: actions/checkout@v4 - name: Get latest CMake and ninja uses: lukka/get-cmake@latest - - name: Configure local example - working-directory: examples/cmake-local + - name: Configure example run: cmake -S . -B build - - name: Build local example - working-directory: examples/cmake-local + - name: Build example run: cmake --build build - - name: Run local example - working-directory: examples/cmake-local/build - run: ./VeryCoolProject - - - if: github.ref == 'refs/heads/master' - && github.event_name == 'push' - && github.repository_owner == 'gunvirranu' - run: echo "RUN_FETCH_EXAMPLE=true" >> $GITHUB_ENV - - - name: Configure fetch-content example - working-directory: examples/cmake-fetch-content - if: env.RUN_FETCH_EXAMPLE == 'true' - run: cmake -S . -B build - - - name: Build fetch-content example - working-directory: examples/cmake-fetch-content - if: env.RUN_FETCH_EXAMPLE == 'true' - run: cmake --build build - - - name: Run fetch-content example - working-directory: examples/cmake-fetch-content/build - if: env.RUN_FETCH_EXAMPLE == 'true' - run: ./VeryCoolProject + - name: Run example + run: | + cd build + ./VeryCoolExampleProject test: name: Test diff --git a/README.md b/README.md index 850d408..cc5c1b4 100644 --- a/README.md +++ b/README.md @@ -75,10 +75,12 @@ Point it at this Github repo with a tagged release version and you should be goo ```cmake include(FetchContent) + # Download and setup the perturb library FetchContent_Declare( perturb GIT_REPOSITORY "https://github.com/gunvirranu/perturb" + GIT_TAG 5723e50a54d438876b7a02e02a326e30b51ead4c # Release v1.0.0 ) FetchContent_MakeAvailable(perturb) @@ -86,7 +88,7 @@ FetchContent_MakeAvailable(perturb) target_link_libraries(YOUR_VERY_COOL_PROJECT_TARGET perturb) ``` -Also see the [`examples`](examples) directory for a full CMake example project using this. You can make more complicated adjustments as necessary, but this demonstrates the basics. +See the [`examples`](examples) directory for CMake example projects using this approach. You can make more complicated adjustments as necessary, but this demonstrates the basics. ### Git Submodules diff --git a/examples/cmake-fetch-content/CMakeLists.txt b/examples/cmake-fetch-content/CMakeLists.txt index 2ad9729..acaed2c 100644 --- a/examples/cmake-fetch-content/CMakeLists.txt +++ b/examples/cmake-fetch-content/CMakeLists.txt @@ -2,21 +2,22 @@ cmake_minimum_required(VERSION 3.14) # Create your own very cool project! project( - VeryCoolProject + VeryCoolExampleProject DESCRIPTION "Example of using perturb via CMake's FetchContent" LANGUAGES CXX ) # A very cool executable indeed -add_executable(VeryCoolProject main.cpp) +add_executable(VeryCoolExampleProject main.cpp) # CMake downloads and sets up perturb for you include(FetchContent) FetchContent_Declare( perturb GIT_REPOSITORY "https://github.com/gunvirranu/perturb" + GIT_TAG 5723e50a54d438876b7a02e02a326e30b51ead4c # Release v1.0.0 ) FetchContent_MakeAvailable(perturb) # Link together that bad boy as a dependency -target_link_libraries(VeryCoolProject perturb) +target_link_libraries(VeryCoolExampleProject perturb) diff --git a/examples/cmake-local/CMakeLists.txt b/examples/cmake-local/CMakeLists.txt index 324df65..7115ee7 100644 --- a/examples/cmake-local/CMakeLists.txt +++ b/examples/cmake-local/CMakeLists.txt @@ -2,17 +2,17 @@ cmake_minimum_required(VERSION 3.14) # Create your own very cool project! project( - VeryCoolProject + VeryCoolExampleProject DESCRIPTION "Example of using perturb from a local source clone" LANGUAGES CXX ) # A very cool executable indeed -add_executable(VeryCoolProject main.cpp) +add_executable(VeryCoolExampleProject main.cpp) # Add perturb library root directory # I have to use the local `build/` binary_dir cause my root one already being used add_subdirectory(../../ build) # Link together that bad boy as a dependency -target_link_libraries(VeryCoolProject perturb) +target_link_libraries(VeryCoolExampleProject perturb)