Skip to content

Commit

Permalink
Add cmake integration workflows (jeremy-rifkin#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-rifkin authored Jul 29, 2023
1 parent c5168d5 commit 5a6a1e8
Show file tree
Hide file tree
Showing 10 changed files with 225 additions and 48 deletions.
162 changes: 162 additions & 0 deletions .github/workflows/cmake-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
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/tests/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
sudo /sbin/ldconfig
cd ../..
cp -rv libassert/tests/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/tests/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/tests/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/tests/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/tests/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/tests/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/tests/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/[email protected]
- name: test
run: |
$tag=$(git rev-parse --abbrev-ref HEAD)
cd ..
cp -Recurse libassert/tests/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/[email protected]
- name: test
run: |
cd ..
cp -Recurse libassert/tests/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
13 changes: 13 additions & 0 deletions tests/add_subdirectory-integration/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
cmake_minimum_required(VERSION 3.8)

project(demo_project VERSION 0.0.1 LANGUAGES CXX)

add_executable(main main.cpp)

if(WIN32)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
endif()

add_subdirectory(libassert)
target_link_libraries(main assert)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <assert/assert.hpp>
#include <assert.hpp>

int main() {
VERIFY(true);
Expand Down
21 changes: 21 additions & 0 deletions tests/fetchcontent-integration/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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")

if(WIN32)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
endif()

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)
10 changes: 10 additions & 0 deletions tests/fetchcontent-integration/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <assert.hpp>

#include <iostream>

int main() {
VERIFY(true);
ASSUME(true);
ASSERT(true);
std::cout<<"Good to go"<<std::endl;
}
8 changes: 8 additions & 0 deletions tests/findpackage-integration/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
10 changes: 10 additions & 0 deletions tests/findpackage-integration/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <assert.hpp>

#include <iostream>

int main() {
VERIFY(true);
ASSUME(true);
ASSERT(true);
std::cout<<"Good to go"<<std::endl;
}
16 changes: 0 additions & 16 deletions tests/library-usage/cmake-fetch-content/CMakeLists.txt

This file was deleted.

24 changes: 0 additions & 24 deletions tests/library-usage/cmake-find-package/CMakeLists.txt

This file was deleted.

7 changes: 0 additions & 7 deletions tests/library-usage/cmake-find-package/main.cpp

This file was deleted.

0 comments on commit 5a6a1e8

Please sign in to comment.