⚗️ add C++17 copies of the test binaries
This commit is contained in:
parent
879217d008
commit
cf2a896bcd
@ -52,6 +52,13 @@ endif()
|
|||||||
# one executable for each unit test file
|
# one executable for each unit test file
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
|
# check if compiler supports C++17
|
||||||
|
foreach(feature ${CMAKE_CXX_COMPILE_FEATURES})
|
||||||
|
if (${feature} STREQUAL cxx_std_17)
|
||||||
|
set(compiler_supports_cpp_17 TRUE)
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
file(GLOB files src/unit-*.cpp)
|
file(GLOB files src/unit-*.cpp)
|
||||||
|
|
||||||
foreach(file ${files})
|
foreach(file ${files})
|
||||||
@ -69,30 +76,32 @@ foreach(file ${files})
|
|||||||
target_link_libraries(${testcase} PRIVATE ${NLOHMANN_JSON_TARGET_NAME})
|
target_link_libraries(${testcase} PRIVATE ${NLOHMANN_JSON_TARGET_NAME})
|
||||||
|
|
||||||
# add a copy with C++17 compilation
|
# add a copy with C++17 compilation
|
||||||
file(READ ${file} FILE_CONTENT)
|
if (compiler_supports_cpp_17)
|
||||||
string(FIND "${FILE_CONTENT}" "JSON_HAS_CPP_17" CPP_17_FOUND)
|
file(READ ${file} FILE_CONTENT)
|
||||||
if(NOT ${CPP_17_FOUND} EQUAL -1)
|
string(FIND "${FILE_CONTENT}" "JSON_HAS_CPP_17" CPP_17_FOUND)
|
||||||
add_executable(${testcase}_cpp17 $<TARGET_OBJECTS:doctest_main> ${file})
|
if(NOT ${CPP_17_FOUND} EQUAL -1)
|
||||||
target_compile_definitions(${testcase}_cpp17 PRIVATE DOCTEST_CONFIG_SUPER_FAST_ASSERTS)
|
add_executable(${testcase}_cpp17 $<TARGET_OBJECTS:doctest_main> ${file})
|
||||||
target_compile_options(${testcase}_cpp17 PRIVATE
|
target_compile_definitions(${testcase}_cpp17 PRIVATE DOCTEST_CONFIG_SUPER_FAST_ASSERTS)
|
||||||
$<$<CXX_COMPILER_ID:MSVC>:/EHsc;$<$<CONFIG:Release>:/Od>>
|
target_compile_options(${testcase}_cpp17 PRIVATE
|
||||||
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-deprecated;-Wno-float-equal>
|
$<$<CXX_COMPILER_ID:MSVC>:/EHsc;$<$<CONFIG:Release>:/Od>>
|
||||||
$<$<CXX_COMPILER_ID:GNU>:-Wno-deprecated-declarations>
|
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-deprecated;-Wno-float-equal>
|
||||||
)
|
$<$<CXX_COMPILER_ID:GNU>:-Wno-deprecated-declarations>
|
||||||
target_include_directories(${testcase}_cpp17 PRIVATE ${CMAKE_BINARY_DIR}/include thirdparty/doctest thirdparty/fifo_map)
|
)
|
||||||
target_link_libraries(${testcase}_cpp17 PRIVATE ${NLOHMANN_JSON_TARGET_NAME})
|
target_include_directories(${testcase}_cpp17 PRIVATE ${CMAKE_BINARY_DIR}/include thirdparty/doctest thirdparty/fifo_map)
|
||||||
set_target_properties(${testcase}_cpp17 PROPERTIES CXX_STANDARD 17)
|
target_link_libraries(${testcase}_cpp17 PRIVATE ${NLOHMANN_JSON_TARGET_NAME})
|
||||||
|
target_compile_features(${testcase}_cpp17 PRIVATE cxx_std_17)
|
||||||
|
|
||||||
if (JSON_FastTests)
|
if (JSON_FastTests)
|
||||||
add_test(NAME "${testcase}_cpp17"
|
add_test(NAME "${testcase}_cpp17"
|
||||||
COMMAND ${testcase}_cpp17 ${DOCTEST_TEST_FILTER}
|
COMMAND ${testcase}_cpp17 ${DOCTEST_TEST_FILTER}
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
add_test(NAME "${testcase}_cpp17"
|
add_test(NAME "${testcase}_cpp17"
|
||||||
COMMAND ${testcase}_cpp17 ${DOCTEST_TEST_FILTER} --no-skip
|
COMMAND ${testcase}_cpp17 ${DOCTEST_TEST_FILTER} --no-skip
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
)
|
)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user