Skip to content

Commit 80c9857

Browse files
committed
Added msvc build test.
1 parent 24e27f9 commit 80c9857

File tree

2 files changed

+44
-5
lines changed

2 files changed

+44
-5
lines changed

.github/workflows/build_and_test.yml

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ env:
1313

1414
jobs:
1515
compiler_matrix:
16+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
1617
runs-on: ubuntu-24.04
1718
strategy:
1819
fail-fast: false
@@ -48,11 +49,41 @@ jobs:
4849
uses: actions/checkout@v2
4950

5051
- name: CMake Configure
51-
run: cmake -B ${{github.workspace}}/build -G"Ninja" -DINT_TREE_BUILD_EXAMPLES=on -DINT_TREE_ENABLE_TESTS=on -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_CXX_COMPILER=${{ matrix.compiler.cxx }} -DCMAKE_CXX_STANDARD=${{ matrix.cxx_standard }}
52+
run: cmake -B ${{github.workspace}}/build -G"Ninja" -DINT_TREE_USE_OPTIONAL_POLYFILL=on -DINT_TREE_BUILD_EXAMPLES=on -DINT_TREE_ENABLE_TESTS=on -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_CXX_COMPILER=${{ matrix.compiler.cxx }} -DCMAKE_CXX_STANDARD=${{ matrix.cxx_standard }}
5253

5354
- name: Build
5455
run: cmake --build ${{github.workspace}}/build
5556

5657
- name: Test
5758
working-directory: ${{github.workspace}}/build
58-
run: ./tests/tree-tests
59+
run: ./tests/tree-tests
60+
61+
msvc:
62+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
63+
runs-on: windows-latest
64+
steps:
65+
- name: Checkout
66+
uses: actions/checkout@v2
67+
68+
- name: Setup MSVC
69+
uses: microsoft/[email protected]
70+
71+
- name: Install vcpkg and gtest
72+
run: |
73+
git clone https://github.com/microsoft/vcpkg.git
74+
.\vcpkg\bootstrap-vcpkg.bat
75+
.\vcpkg\vcpkg.exe install gtest
76+
shell: pwsh
77+
env:
78+
VCPKG_DEFAULT_TRIPLET: x64-windows
79+
80+
- name: CMake Configure
81+
run: cmake -B ${{github.workspace}}/build -G"Visual Studio 17 2022" -A x64 -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_CXX_STANDARD=20 -DINT_TREE_USE_OPTIONAL_POLYFILL=on -DINT_TREE_BUILD_EXAMPLES=on -DINT_TREE_ENABLE_TESTS=on -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
82+
83+
- name: Build
84+
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
85+
86+
- name: Test
87+
working-directory: ${{github.workspace}}/build
88+
run: .\tests\Release\tree-tests.exe
89+
shell: cmd

tests/CMakeLists.txt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,25 @@ file(GLOB sources "*.cpp")
1919
# Add Executable
2020
add_executable(tree-tests ${sources})
2121

22-
target_link_libraries(tree-tests PRIVATE gtest gmock interval-tree)
22+
find_package(GTest REQUIRED)
23+
24+
target_link_libraries(tree-tests PRIVATE interval-tree GTest::gtest GTest::gmock GTest::gmock_main)
2325

2426
# Compiler Options
2527
set(DEBUG_OPTIONS -fexceptions -g -Wall -pedantic-errors -pedantic)
2628
target_compile_options(tree-tests PUBLIC "$<$<CONFIG:DEBUG>:${DEBUG_OPTIONS}>")
2729

28-
set(RELEASE_OPTIONS -fexceptions -O3 -Wall -pedantic)
30+
if (${MSVC})
31+
set(WARNING_FLAGS -W4)
32+
else()
33+
set(WARNING_FLAGS -Wall)
34+
list(APPEND WARNING_FLAGS -Wextra)
35+
endif()
36+
set(RELEASE_OPTIONS -fexceptions -O3 ${WARNING_FLAGS} -pedantic)
2937
target_compile_options(tree-tests PUBLIC "$<$<CONFIG:RELEASE>:${RELEASE_OPTIONS}>")
3038

3139
if (INT_TREE_DRAW_EXAMPLES)
32-
target_link_libraries(tree-tests PRIVATE cairo cairo-wrap)
40+
target_link_libraries(tree-tests PRIVATE cairo-wrap cairo)
3341
endif()
3442

3543
# If msys2, copy dynamic libraries to executable directory, visual studio does this automatically.

0 commit comments

Comments
 (0)