@@ -32,22 +32,20 @@ jobs:
3232 output_folder : ${{github.workspace}}/build/
3333
3434 steps :
35- - uses : actions/checkout@v4
35+ - uses : actions/checkout@v5
3636
3737 - name : Configure CMake & Build
3838 env :
39- # Map from C++ compiler to equivalent C compiler
40- g++ : gcc
41- clang++ : clang
42- uses : threeal/cmake-action@v2.0.0
43- with :
44- build-dir : ${{ env.output_folder }}
45- c-compiler : ${{ env[matrix.cpp_compiler] }}
46- cxx-compiler : ${{ matrix.cpp_compiler }}
47- options : |
48- LIBDIVIDE_BUILD_TESTS=ON
49- CMAKE_BUILD_TYPE=${{ matrix.build_type }}
50- build-args : --config ${{ matrix.build_type }}
39+ C_COMPILER : ${{ matrix.cpp_compiler == 'g++' && 'gcc' || 'clang' }}
40+ CXX_COMPILER : ${{ matrix.cpp_compiler }}
41+ BUILD_TYPE : ${{ matrix.build_type }}
42+ run : |
43+ cmake -B "$output_folder" \
44+ "-DCMAKE_C_COMPILER=$C_COMPILER" \
45+ "-DCMAKE_CXX_COMPILER=$CXX_COMPILER" \
46+ -DLIBDIVIDE_BUILD_TESTS=ON \
47+ "-DCMAKE_BUILD_TYPE=$BUILD_TYPE"
48+ cmake --build "$output_folder" --config "$BUILD_TYPE"
5149
5250 - name : Test
5351 working-directory : ${{ env.output_folder }}
@@ -93,30 +91,27 @@ jobs:
9391 output_folder : ${{github.workspace}}/build/
9492
9593 steps :
96- - uses : actions/checkout@v4
97- - uses : ilammy/msvc-dev-cmd@v1
94+ - uses : actions/checkout@v5
9895
99- - name : Configure CMake & Build
96+ - name : Configure CMake, Build & Test
10097 env :
101- # Map from C++ compiler to equivalent C compiler
102- cl.exe : cl.exe
103- clang-cl.exe : clang-cl.exe
104- toolset : ${{ matrix.toolset && format('-T {0}', matrix.toolset) || ''}}
105- uses : threeal/cmake-action@v2.0.0
106- with :
107- build-dir : ${{ env.output_folder }}
108- c-compiler : ${{ env[matrix.cpp_compiler] }}
109- cxx-compiler : ${{ matrix.cpp_compiler }}
110- generator : ${{ matrix.generator }}
111- args : ${{ env.toolset }}
112- options : |
113- LIBDIVIDE_BUILD_TESTS=ON
114- CMAKE_BUILD_TYPE=${{ matrix.build_type }}
115- ${{ matrix.build_type == 'Sanitize' && 'LIBDIVIDE_ENABLE_SANITIZERS=ON' || '' }}
116- build-args : --config ${{ matrix.build_type }}
117-
118- - name : Test
119- working-directory : ${{ env.output_folder }}
120- # Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
121- # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
122- run : ctest --build-config ${{ matrix.build_type }} --verbose
98+ SANITIZER_OPTION : ${{ matrix.build_type == 'Sanitize' && '-DLIBDIVIDE_ENABLE_SANITIZERS=ON' || '' }}
99+ TOOLSET_ARGS : ${{ matrix.toolset && format('-T {0}', matrix.toolset) || '' }}
100+ shell : cmd
101+ run : |
102+ for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -products * -latest -prerelease -property installationPath`) do set "VS_INSTALL_PATH=%%i"
103+ if not defined VS_INSTALL_PATH exit /b 1
104+ call "%VS_INSTALL_PATH%\VC\Auxiliary\Build\vcvarsall.bat" x64
105+ if errorlevel 1 exit /b 1
106+ cmake -B "%output_folder%" ^
107+ -G "${{ matrix.generator }}" ^
108+ -DCMAKE_C_COMPILER=${{ matrix.cpp_compiler }} ^
109+ -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} ^
110+ -DLIBDIVIDE_BUILD_TESTS=ON ^
111+ -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} ^
112+ %SANITIZER_OPTION% %TOOLSET_ARGS%
113+ if errorlevel 1 exit /b 1
114+ cmake --build "%output_folder%" --config ${{ matrix.build_type }}
115+ if errorlevel 1 exit /b 1
116+ cd /d "%output_folder%"
117+ ctest --build-config ${{ matrix.build_type }} --verbose
0 commit comments