From d4e12344d6bc443b44ec32fdaf175bcc7a5d1486 Mon Sep 17 00:00:00 2001 From: Vladislav Shchapov Date: Mon, 7 Feb 2022 18:34:55 +0500 Subject: [PATCH] Fix C++20 test errors --- test/CMakeLists.txt | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f9fdd18..caecea4 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -3,6 +3,15 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/") set(PARSE_CATCH_TESTS_ADD_TO_CONFIGURE_DEPENDS ON) include(ParseAndAddCatchTests) +function(SetTestCompileOptions target_name) + target_compile_options(${target_name} PRIVATE + $<$:-s DISABLE_EXCEPTION_CATCHING=0> + $<$,$>:-Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wpedantic -Werror -Wno-deprecated-declarations> + $<$:-Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wpedantic -Wno-psabi -Werror -Wno-deprecated-declarations> + $<$:/WX /wd4996> + $<$:-Wa,-mbig-obj>) +endfunction() + if(GHC_COVERAGE) message("Generating test runner for coverage run...") set(CMAKE_EXE_LINKER_FLAGS "${CMCMAKE_EXE_LINKER_FLAGS} --coverage") @@ -23,12 +32,7 @@ else() message("Generating test runner for normal test...") add_executable(filesystem_test filesystem_test.cpp catch.hpp) target_link_libraries(filesystem_test ghc_filesystem) - target_compile_options(filesystem_test PRIVATE - $<$:-s DISABLE_EXCEPTION_CATCHING=0> - $<$,$>:-Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wpedantic -Werror> - $<$:-Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wpedantic -Wno-psabi -Werror> - $<$:/WX> - $<$:-Wa,-mbig-obj>) + SetTestCompileOptions(filesystem_test) if(CMAKE_CXX_COMPILER_ID MATCHES MSVC) target_compile_definitions(filesystem_test PRIVATE _CRT_SECURE_NO_WARNINGS WIN32_LEAN_AND_MEAN NOMINMAX) endif() @@ -42,10 +46,7 @@ else() if(WIN32) add_executable(filesystem_test_char filesystem_test.cpp catch.hpp) target_link_libraries(filesystem_test_char ghc_filesystem) - target_compile_options(filesystem_test_char PRIVATE - $<$:-Wall -Wextra -Werror> - $<$:-Wall -Werror> - $<$:/WX>) + SetTestCompileOptions(filesystem_test_char) if(CMAKE_CXX_COMPILER_ID MATCHES MSVC) target_compile_definitions(filesystem_test_char PRIVATE _CRT_SECURE_NO_WARNINGS GHC_WIN_DISABLE_WSTRING_STORAGE_TYPE) else() @@ -67,12 +68,7 @@ add_test(multifile_test multifile_test) add_executable(fwd_impl_test fwd_test.cpp impl_test.cpp) target_link_libraries(fwd_impl_test ghc_filesystem) -target_compile_options(fwd_impl_test PRIVATE - $<$:-s DISABLE_EXCEPTION_CATCHING=0> - $<$,$>:-Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wpedantic -Werror> - $<$:-Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wpedantic -Wno-psabi -Werror> - $<$:/WX> - $<$:-Wa,-mbig-obj>) +SetTestCompileOptions(fwd_impl_test) if(CMAKE_CXX_COMPILER_ID MATCHES MSVC) target_compile_definitions(fwd_impl_test PRIVATE _CRT_SECURE_NO_WARNINGS WIN32_LEAN_AND_MEAN NOMINMAX) endif() @@ -83,9 +79,4 @@ if(NOT MSVC) target_compile_options(exception PRIVATE -fno-exceptions) endif() target_include_directories(exception PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../include) -target_compile_options(exception PRIVATE - $<$:-s DISABLE_EXCEPTION_CATCHING=0> - $<$,$>:-Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wpedantic -Werror> - $<$:-Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wpedantic -Wno-psabi -Werror> - $<$:/WX> - $<$:-Wa,-mbig-obj>) +SetTestCompileOptions(exception)