Skip to content

Commit d4e1234

Browse files
committed
Fix C++20 test errors
1 parent f437344 commit d4e1234

File tree

1 file changed

+13
-22
lines changed

1 file changed

+13
-22
lines changed

test/CMakeLists.txt

+13-22
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
33
set(PARSE_CATCH_TESTS_ADD_TO_CONFIGURE_DEPENDS ON)
44
include(ParseAndAddCatchTests)
55

6+
function(SetTestCompileOptions target_name)
7+
target_compile_options(${target_name} PRIVATE
8+
$<$<BOOL:${EMSCRIPTEN}>:-s DISABLE_EXCEPTION_CATCHING=0>
9+
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:-Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wpedantic -Werror -Wno-deprecated-declarations>
10+
$<$<CXX_COMPILER_ID:GNU>:-Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wpedantic -Wno-psabi -Werror -Wno-deprecated-declarations>
11+
$<$<CXX_COMPILER_ID:MSVC>:/WX /wd4996>
12+
$<$<BOOL:${CYGWIN}>:-Wa,-mbig-obj>)
13+
endfunction()
14+
615
if(GHC_COVERAGE)
716
message("Generating test runner for coverage run...")
817
set(CMAKE_EXE_LINKER_FLAGS "${CMCMAKE_EXE_LINKER_FLAGS} --coverage")
@@ -23,12 +32,7 @@ else()
2332
message("Generating test runner for normal test...")
2433
add_executable(filesystem_test filesystem_test.cpp catch.hpp)
2534
target_link_libraries(filesystem_test ghc_filesystem)
26-
target_compile_options(filesystem_test PRIVATE
27-
$<$<BOOL:${EMSCRIPTEN}>:-s DISABLE_EXCEPTION_CATCHING=0>
28-
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:-Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wpedantic -Werror>
29-
$<$<CXX_COMPILER_ID:GNU>:-Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wpedantic -Wno-psabi -Werror>
30-
$<$<CXX_COMPILER_ID:MSVC>:/WX>
31-
$<$<BOOL:${CYGWIN}>:-Wa,-mbig-obj>)
35+
SetTestCompileOptions(filesystem_test)
3236
if(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
3337
target_compile_definitions(filesystem_test PRIVATE _CRT_SECURE_NO_WARNINGS WIN32_LEAN_AND_MEAN NOMINMAX)
3438
endif()
@@ -42,10 +46,7 @@ else()
4246
if(WIN32)
4347
add_executable(filesystem_test_char filesystem_test.cpp catch.hpp)
4448
target_link_libraries(filesystem_test_char ghc_filesystem)
45-
target_compile_options(filesystem_test_char PRIVATE
46-
$<$<CXX_COMPILER_ID:Clang>:-Wall -Wextra -Werror>
47-
$<$<CXX_COMPILER_ID:GNU>:-Wall -Werror>
48-
$<$<CXX_COMPILER_ID:MSVC>:/WX>)
49+
SetTestCompileOptions(filesystem_test_char)
4950
if(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
5051
target_compile_definitions(filesystem_test_char PRIVATE _CRT_SECURE_NO_WARNINGS GHC_WIN_DISABLE_WSTRING_STORAGE_TYPE)
5152
else()
@@ -67,12 +68,7 @@ add_test(multifile_test multifile_test)
6768

6869
add_executable(fwd_impl_test fwd_test.cpp impl_test.cpp)
6970
target_link_libraries(fwd_impl_test ghc_filesystem)
70-
target_compile_options(fwd_impl_test PRIVATE
71-
$<$<BOOL:${EMSCRIPTEN}>:-s DISABLE_EXCEPTION_CATCHING=0>
72-
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:-Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wpedantic -Werror>
73-
$<$<CXX_COMPILER_ID:GNU>:-Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wpedantic -Wno-psabi -Werror>
74-
$<$<CXX_COMPILER_ID:MSVC>:/WX>
75-
$<$<BOOL:${CYGWIN}>:-Wa,-mbig-obj>)
71+
SetTestCompileOptions(fwd_impl_test)
7672
if(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
7773
target_compile_definitions(fwd_impl_test PRIVATE _CRT_SECURE_NO_WARNINGS WIN32_LEAN_AND_MEAN NOMINMAX)
7874
endif()
@@ -83,9 +79,4 @@ if(NOT MSVC)
8379
target_compile_options(exception PRIVATE -fno-exceptions)
8480
endif()
8581
target_include_directories(exception PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../include)
86-
target_compile_options(exception PRIVATE
87-
$<$<BOOL:${EMSCRIPTEN}>:-s DISABLE_EXCEPTION_CATCHING=0>
88-
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:-Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wpedantic -Werror>
89-
$<$<CXX_COMPILER_ID:GNU>:-Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wpedantic -Wno-psabi -Werror>
90-
$<$<CXX_COMPILER_ID:MSVC>:/WX>
91-
$<$<BOOL:${CYGWIN}>:-Wa,-mbig-obj>)
82+
SetTestCompileOptions(exception)

0 commit comments

Comments
 (0)