From 0ad42037adf152b0563d800e96a8d22aed95812f Mon Sep 17 00:00:00 2001 From: Jeremy <51220084+jeremy-rifkin@users.noreply.github.com> Date: Sat, 29 Jul 2023 00:14:36 -0400 Subject: [PATCH] Add cmake integration workflows --- .github/workflows/cmake-integration.yml | 161 ++++++++++++++++++ .../CMakeLists.txt | 8 + .../main.cpp | 0 tests/fetchcontent-integration/CMakeLists.txt | 16 ++ .../main.cpp | 0 tests/findpackage-integration/CMakeLists.txt | 8 + tests/findpackage-integration/main.cpp | 7 + .../cmake-fetch-content/CMakeLists.txt | 16 -- .../cmake-find-package/CMakeLists.txt | 24 --- 9 files changed, 200 insertions(+), 40 deletions(-) create mode 100644 .github/workflows/cmake-integration.yml create mode 100644 tests/add_subdirectory-integration/CMakeLists.txt rename tests/{library-usage/cmake-fetch-content => add_subdirectory-integration}/main.cpp (100%) create mode 100644 tests/fetchcontent-integration/CMakeLists.txt rename tests/{library-usage/cmake-find-package => fetchcontent-integration}/main.cpp (100%) create mode 100644 tests/findpackage-integration/CMakeLists.txt create mode 100644 tests/findpackage-integration/main.cpp delete mode 100644 tests/library-usage/cmake-fetch-content/CMakeLists.txt delete mode 100644 tests/library-usage/cmake-find-package/CMakeLists.txt diff --git a/.github/workflows/cmake-integration.yml b/.github/workflows/cmake-integration.yml new file mode 100644 index 00000000..010c82e6 --- /dev/null +++ b/.github/workflows/cmake-integration.yml @@ -0,0 +1,161 @@ +name: cmake-integration + +on: + push: + pull_request: + +jobs: + test-linux-fetchcontent: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v2 + - name: test + run: | + tag=$(git rev-parse --abbrev-ref HEAD) + cd .. + cp -rv libassert/test/fetchcontent-integration . + mkdir fetchcontent-integration/build + cd fetchcontent-integration/build + cmake .. -DCMAKE_BUILD_TYPE=Debug -DLIBASSERT_TAG=$tag + make + ./main + test-linux-findpackage: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v2 + - name: build + run: | + tag=$(git rev-parse --abbrev-ref HEAD) + mkdir build + cd build + cmake .. -DCMAKE_BUILD_TYPE=Debug + sudo make -j install + cd ../.. + cp -rv libassert/test/findpackage-integration . + mkdir findpackage-integration/build + cd findpackage-integration/build + cmake .. -DCMAKE_BUILD_TYPE=Debug + make + ./main + test-linux-add_subdirectory: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v2 + - name: build + run: | + cd .. + cp -rv libassert/test/add_subdirectory-integration . + cp -rv libassert add_subdirectory-integration + mkdir add_subdirectory-integration/build + cd add_subdirectory-integration/build + cmake .. -DCMAKE_BUILD_TYPE=Debug + make + ./main + + test-macos-fetchcontent: + runs-on: macos-13 + steps: + - uses: actions/checkout@v2 + - name: test + run: | + tag=$(git rev-parse --abbrev-ref HEAD) + cd .. + cp -rv libassert/test/fetchcontent-integration . + mkdir fetchcontent-integration/build + cd fetchcontent-integration/build + cmake .. -DCMAKE_BUILD_TYPE=Debug -DLIBASSERT_TAG=$tag + make + ./main + test-macos-findpackage: + runs-on: macos-13 + steps: + - uses: actions/checkout@v2 + - name: build + run: | + tag=$(git rev-parse --abbrev-ref HEAD) + mkdir build + cd build + cmake .. -DCMAKE_BUILD_TYPE=Debug + sudo make -j install + cd ../.. + cp -rv libassert/test/findpackage-integration . + mkdir findpackage-integration/build + cd findpackage-integration/build + cmake .. -DCMAKE_BUILD_TYPE=Debug + make + ./main + test-macos-add_subdirectory: + runs-on: macos-13 + steps: + - uses: actions/checkout@v2 + - name: test + run: | + cd .. + cp -rv libassert/test/add_subdirectory-integration . + cp -rv libassert add_subdirectory-integration + mkdir add_subdirectory-integration/build + cd add_subdirectory-integration/build + cmake .. -DCMAKE_BUILD_TYPE=Debug + make + ./main + + test-mingw-fetchcontent: + runs-on: windows-2019 + steps: + - uses: actions/checkout@v2 + - name: test + run: | + $tag=$(git rev-parse --abbrev-ref HEAD) + cd .. + cp -Recurse libassert/test/fetchcontent-integration . + mkdir fetchcontent-integration/build + cd fetchcontent-integration/build + cmake .. -DCMAKE_BUILD_TYPE=Debug -DLIBASSERT_TAG="$tag" -DCMAKE_BUILD_TYPE=g++ "-GUnix Makefiles" + make + .\main.exe + test-mingw-add_subdirectory: + runs-on: windows-2019 + steps: + - uses: actions/checkout@v2 + - name: test + run: | + cd .. + cp -Recurse libassert/test/add_subdirectory-integration . + cp -Recurse libassert add_subdirectory-integration + mkdir add_subdirectory-integration/build + cd add_subdirectory-integration/build + cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_BUILD_TYPE=g++ "-GUnix Makefiles" + make + .\main.exe + test-windows-fetchcontent: + runs-on: windows-2019 + steps: + - uses: actions/checkout@v2 + - name: Enable Developer Command Prompt + uses: ilammy/msvc-dev-cmd@v1.10.0 + - name: test + run: | + $tag=$(git rev-parse --abbrev-ref HEAD) + cd .. + cp -Recurse libassert/test/fetchcontent-integration . + mkdir fetchcontent-integration/build + cd fetchcontent-integration/build + cmake .. -DCMAKE_BUILD_TYPE=Debug -DLIBASSERT_TAG="$tag" + msbuild demo_project.sln + .\Debug\main.exe + test-windows-add_subdirectory: + runs-on: windows-2019 + steps: + - uses: actions/checkout@v2 + - name: Enable Developer Command Prompt + uses: ilammy/msvc-dev-cmd@v1.10.0 + - name: test + run: | + cd .. + cp -Recurse libassert/test/add_subdirectory-integration . + cp -Recurse libassert add_subdirectory-integration + mkdir add_subdirectory-integration/build + cd add_subdirectory-integration/build + cmake .. -DCMAKE_BUILD_TYPE=Debug + msbuild demo_project.sln + .\Debug\main.exe diff --git a/tests/add_subdirectory-integration/CMakeLists.txt b/tests/add_subdirectory-integration/CMakeLists.txt new file mode 100644 index 00000000..60417637 --- /dev/null +++ b/tests/add_subdirectory-integration/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) + +project(demo_project VERSION 0.0.1 LANGUAGES CXX) + +add_executable(main main.cpp) + +add_subdirectory(assert) +target_link_libraries(main assert) diff --git a/tests/library-usage/cmake-fetch-content/main.cpp b/tests/add_subdirectory-integration/main.cpp similarity index 100% rename from tests/library-usage/cmake-fetch-content/main.cpp rename to tests/add_subdirectory-integration/main.cpp diff --git a/tests/fetchcontent-integration/CMakeLists.txt b/tests/fetchcontent-integration/CMakeLists.txt new file mode 100644 index 00000000..fe235bcf --- /dev/null +++ b/tests/fetchcontent-integration/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.8) + +project(demo_project VERSION 0.0.1 LANGUAGES CXX) + +add_executable(main main.cpp) + +set(LIBASSERT_TAG "" CACHE STRING "libassert git tag") + +include(FetchContent) +FetchContent_Declare( + assert + GIT_REPOSITORY https://github.com/jeremy-rifkin/libassert.git + GIT_TAG ${LIBASSERT_TAG} +) +FetchContent_MakeAvailable(assert) +target_link_libraries(main assert) diff --git a/tests/library-usage/cmake-find-package/main.cpp b/tests/fetchcontent-integration/main.cpp similarity index 100% rename from tests/library-usage/cmake-find-package/main.cpp rename to tests/fetchcontent-integration/main.cpp diff --git a/tests/findpackage-integration/CMakeLists.txt b/tests/findpackage-integration/CMakeLists.txt new file mode 100644 index 00000000..aa5febbf --- /dev/null +++ b/tests/findpackage-integration/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.8) + +project(demo_project VERSION 0.0.1 LANGUAGES CXX) + +add_executable(main main.cpp) + +find_package(assert REQUIRED) +target_link_libraries(main assert::assert) diff --git a/tests/findpackage-integration/main.cpp b/tests/findpackage-integration/main.cpp new file mode 100644 index 00000000..24ea7474 --- /dev/null +++ b/tests/findpackage-integration/main.cpp @@ -0,0 +1,7 @@ +#include + +int main() { + VERIFY(true); + ASSUME(true); + ASSERT(true); +} diff --git a/tests/library-usage/cmake-fetch-content/CMakeLists.txt b/tests/library-usage/cmake-fetch-content/CMakeLists.txt deleted file mode 100644 index 90a13995..00000000 --- a/tests/library-usage/cmake-fetch-content/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -cmake_minimum_required(VERSION 3.8...3.23) - -project(cmake_find_package_test) - -set(TEST_TAG "null" CACHE STRING "TEST_TAG") - -include(FetchContent) -FetchContent_Declare( - assert - GIT_REPOSITORY "https://github.com/jeremy-rifkin/libassert" - GIT_TAG ${} -) -FetchContent_MakeAvailable(assert) - -add_executable(my_executable main.cpp) -target_link_libraries(my_executable PRIVATE assert) diff --git a/tests/library-usage/cmake-find-package/CMakeLists.txt b/tests/library-usage/cmake-find-package/CMakeLists.txt deleted file mode 100644 index 93e7929f..00000000 --- a/tests/library-usage/cmake-find-package/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -cmake_minimum_required(VERSION 3.8...3.23) - -project(cmake_find_package_test) - -find_package( - assert - REQUIRED - NO_PACKAGE_ROOT_PATH - NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_PACKAGE_REGISTRY - NO_CMAKE_SYSTEM_PATH - NO_CMAKE_SYSTEM_PACKAGE_REGISTRY -) - -add_executable( - main - main.cpp -) - -target_link_libraries( - main - PUBLIC - assert::assert -)