Skip to content

Commit

Permalink
[test] windows again
Browse files Browse the repository at this point in the history
  • Loading branch information
Quuxplusone committed Oct 19, 2023
1 parent 542f041 commit b27c6ec
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 34 deletions.
36 changes: 16 additions & 20 deletions .github/workflows/build-and-run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,20 @@ jobs:
os: [ubuntu-latest, windows-latest]
build_type: [Debug]
cpp_compiler: [g++, clang++, cl]
cpp_standard: [14]
cpp_standard: [14, 20, 23]
exclude:
- os: ubuntu-latest
cpp_compiler: cl
- os: ubuntu-latest
cpp_compiler: clang++
cpp_standard: 20
- os: ubuntu-latest
cpp_compiler: clang++
cpp_standard: 23
- os: windows-latest
cpp_compiler: clang++
- os: windows-latest
cpp_compiler: g++

runs-on: ${{ matrix.os }}

Expand All @@ -30,34 +40,20 @@ jobs:
run: >
sudo apt-get install libgtest-dev
- name: Install Google Test (Windows)
if: matrix.os == 'windows-latest'
run: >
git clone https://github.com/google/googletest.git &&
mkdir googletest/build &&
cd googletest/build &&
cmake .. -G 'Unix Makefiles' &&
make install
- name: Build (Linux)
if: matrix.os == 'ubuntu-latest'
working-directory: ${{ github.workspace }}
env:
CMAKE_CXX_COMPILER: ${{ matrix.cpp_compiler }}
CMAKE_BUILD_TYPE: ${{ matrix.build_type }}
run: |
cmake -S . -B ./build -DCMAKE_CXX_STANDARD=${{ matrix.cpp_standard }}
cmake . -B ./build -G 'Unix Makefiles' \
-DCMAKE_CXX_STANDARD=${{ matrix.cpp_standard }} \
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
- name: Build (Windows)
if: matrix.os == 'windows-latest'
working-directory: ${{ github.workspace }}
env:
CMAKE_CXX_COMPILER: ${{ matrix.cpp_compiler }}
CMAKE_BUILD_TYPE: ${{ matrix.build_type }}
run: |
cmake -S . -B ./build -DCMAKE_CXX_STANDARD=${{ matrix.cpp_standard }}
# -DGTEST_ROOT="C:/Program Files (x86)/googletest-distribution"
cmake . -B ./build -G 'Unix Makefiles' -DCMAKE_CXX_STANDARD=${{ matrix.cpp_standard }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_DOWNLOAD_GTEST=ON
- name: Test
working-directory: ${{ github.workspace }}/build
Expand Down
37 changes: 23 additions & 14 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@

find_package(gtest REQUIRED)
if ("${CMAKE_DOWNLOAD_GTEST}")
include(fetchcontent)
fetchcontent_declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG f8d7d77c06936315286eb55f8de22cd23c188571 # tagged v1.14.0
)
fetchcontent_makeavailable(googletest)
endif()
find_package(GTest REQUIRED)

set(TEST_SOURCE_FILES
flat_map_test.cpp
Expand All @@ -13,23 +22,23 @@ set(TEST_SOURCE_FILES
unstable_remove_test.cpp
)

set(TEST_NAME utest)
add_executable(${TEST_NAME} ${TEST_SOURCE_FILES})
add_executable(utest ${TEST_SOURCE_FILES})
include_directories(${GTEST_INCLUDE_DIRS} ${SG14_INCLUDE_DIRECTORY})
target_link_libraries(${TEST_NAME} ${CMAKE_THREAD_LIBS_INIT} ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES})
target_link_libraries(utest ${CMAKE_THREAD_LIBS_INIT} ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES})

# Compile options
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
target_compile_options(${TEST_NAME} PRIVATE -Wall -Wextra -Werror)
target_compile_options(utest PRIVATE -Wall -Wextra -Werror)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
target_compile_options(${TEST_NAME} PRIVATE -Wall -Wextra -Werror)
if (CMAKE_CXX_COMPILER_VERSION MATCHES "^7.*")
set_source_files_properties(${SG14_TEST_SOURCE_DIRECTORY}/slot_map_test.cpp PROPERTIES
COMPILE_FLAGS "-Wno-error=unused-variable -Wno-error=unused-but-set-variable") # Fix gcc7 issues with structured bindings
message("Disabled -Wunused-variable and -Wunused-but-set-variable for gcc ${CMAKE_CXX_COMPILER_VERSION}.")
endif()
target_compile_options(utest PRIVATE -Wall -Wextra -Werror)
if (CMAKE_CXX_COMPILER_VERSION MATCHES "^7.*")
set_source_files_properties(${SG14_TEST_SOURCE_DIRECTORY}/slot_map_test.cpp PROPERTIES
COMPILE_FLAGS "-Wno-error=unused-variable -Wno-error=unused-but-set-variable" # Fix gcc7 issues with structured bindings
)
message("Disabled -Wunused-variable and -Wunused-but-set-variable for gcc ${CMAKE_CXX_COMPILER_VERSION}.")
endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${TEST_NAME})
target_compile_options(${TEST_NAME} PRIVATE /Zc:__cplusplus /permissive- /W4 /WX)
add_definitions(-DNOMINMAX -D_SCL_SECURE_NO_WARNINGS)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT utest)
target_compile_options(utest PRIVATE /Zc:__cplusplus /permissive- /W4 /WX)
add_definitions(-DNOMINMAX -D_SCL_SECURE_NO_WARNINGS)
endif()

0 comments on commit b27c6ec

Please sign in to comment.