Skip to content

Commit 45780e5

Browse files
committed
Add cross-platform CI
1 parent a182177 commit 45780e5

2 files changed

Lines changed: 29 additions & 21 deletions

File tree

.github/workflows/ci.yml

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,22 @@ on:
77
branches: [master]
88

99
jobs:
10-
gtest:
11-
runs-on: ubuntu-latest
12-
steps:
13-
- uses: actions/checkout@v4
14-
15-
- name: Install dependencies
16-
run: |
17-
sudo apt-get update
18-
sudo apt-get install -y libgtest-dev pkg-config
10+
test:
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
os: [ubuntu-latest, macos-latest, windows-latest]
1915

20-
- name: Build tests
21-
run: make gtests
16+
runs-on: ${{ matrix.os }}
2217

23-
- name: Run tests
24-
run: ./gtests --gtest_filter=*
25-
26-
samples:
27-
runs-on: ubuntu-latest
2818
steps:
2919
- uses: actions/checkout@v4
3020

31-
- name: Build sample
32-
run: make sample
21+
- name: Configure
22+
run: cmake -S . -B build -DBUILD_TESTING=ON
23+
24+
- name: Build
25+
run: cmake --build build --config Release
3326

34-
- name: Run sample
35-
run: ./sample
27+
- name: Test
28+
run: ctest --test-dir build --config Release --output-on-failure

CMakeLists.txt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,28 @@ target_compile_features(CppGeometryLibrary INTERFACE cxx_std_17)
1515
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
1616
include(CTest)
1717
if(BUILD_TESTING)
18-
find_package(GTest REQUIRED)
18+
find_package(GTest QUIET)
19+
if(NOT GTest_FOUND)
20+
include(FetchContent)
21+
FetchContent_Declare(
22+
googletest
23+
URL https://github.com/google/googletest/archive/v1.14.0.tar.gz
24+
DOWNLOAD_EXTRACT_TIMESTAMP ON
25+
)
26+
# Prevent overriding the parent project's compiler/linker settings on Windows
27+
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
28+
FetchContent_MakeAvailable(googletest)
29+
endif()
30+
1931
add_executable(cpp_geometry_tests tests/Tests.cpp)
2032
target_link_libraries(cpp_geometry_tests
2133
PRIVATE CppGeometryLibrary GTest::GTest GTest::Main
2234
)
2335
add_test(NAME cpp_geometry_tests COMMAND cpp_geometry_tests)
2436
endif()
37+
38+
add_executable(cpp_geometry_sample samples/samples.cpp)
39+
target_link_libraries(cpp_geometry_sample PRIVATE CppGeometryLibrary)
2540
endif()
2641

2742
# Installation

0 commit comments

Comments
 (0)