mirror of
https://github.com/nlohmann/json.git
synced 2026-09-17 21:57:57 +00:00
Merge branch 'develop' of https://github.com/nlohmann/json into develop
This commit is contained in:
+14
-15
@@ -22,7 +22,7 @@ if(JSON_NoExceptions)
|
||||
if(NOT MSVC)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DJSON_NOEXCEPTION")
|
||||
endif()
|
||||
set(CATCH_TEST_FILTER -e)
|
||||
set(DOCTEST_TEST_FILTER --no-throw)
|
||||
endif()
|
||||
|
||||
if(JSON_Coverage)
|
||||
@@ -54,22 +54,22 @@ if(JSON_Coverage)
|
||||
endif()
|
||||
|
||||
#############################################################################
|
||||
# Catch library with the main function to speed up build
|
||||
# doctest library with the main function to speed up build
|
||||
#############################################################################
|
||||
|
||||
add_library(catch_main OBJECT
|
||||
add_library(doctest_main OBJECT
|
||||
"src/unit.cpp"
|
||||
)
|
||||
set_target_properties(catch_main PROPERTIES
|
||||
set_target_properties(doctest_main PROPERTIES
|
||||
COMPILE_DEFINITIONS "$<$<CXX_COMPILER_ID:MSVC>:_SCL_SECURE_NO_WARNINGS>"
|
||||
COMPILE_OPTIONS "$<$<CXX_COMPILER_ID:MSVC>:/EHsc;$<$<CONFIG:Release>:/Od>>"
|
||||
)
|
||||
if (${CMAKE_VERSION} VERSION_LESS "3.8.0")
|
||||
target_compile_features(catch_main PUBLIC cxx_range_for)
|
||||
if (${CMAKE_VERSION} VERSION_LESS "3.8.0")
|
||||
target_compile_features(doctest_main PUBLIC cxx_range_for)
|
||||
else()
|
||||
target_compile_features(catch_main PUBLIC cxx_std_11)
|
||||
target_compile_features(doctest_main PUBLIC cxx_std_11)
|
||||
endif()
|
||||
target_include_directories(catch_main PRIVATE "thirdparty/catch")
|
||||
target_include_directories(doctest_main PRIVATE "thirdparty/doctest")
|
||||
|
||||
# https://stackoverflow.com/questions/2368811/how-to-set-warning-level-in-cmake
|
||||
if(MSVC)
|
||||
@@ -99,10 +99,9 @@ foreach(file ${files})
|
||||
get_filename_component(file_basename ${file} NAME_WE)
|
||||
string(REGEX REPLACE "unit-([^$]+)" "test-\\1" testcase ${file_basename})
|
||||
|
||||
add_executable(${testcase} $<TARGET_OBJECTS:catch_main> ${file})
|
||||
add_executable(${testcase} $<TARGET_OBJECTS:doctest_main> ${file})
|
||||
target_compile_definitions(${testcase} PRIVATE
|
||||
CATCH_CONFIG_FAST_COMPILE
|
||||
$<$<CXX_COMPILER_ID:MSVC>:_SCL_SECURE_NO_WARNINGS>
|
||||
DOCTEST_CONFIG_SUPER_FAST_ASSERTS
|
||||
)
|
||||
target_compile_options(${testcase} PRIVATE
|
||||
$<$<CXX_COMPILER_ID:MSVC>:/EHsc;$<$<CONFIG:Release>:/Od>>
|
||||
@@ -110,26 +109,26 @@ foreach(file ${files})
|
||||
$<$<CXX_COMPILER_ID:GNU>:-Wno-deprecated-declarations>
|
||||
)
|
||||
target_include_directories(${testcase} PRIVATE
|
||||
thirdparty/catch
|
||||
thirdparty/doctest
|
||||
thirdparty/fifo_map
|
||||
)
|
||||
target_link_libraries(${testcase} ${NLOHMANN_JSON_TARGET_NAME})
|
||||
|
||||
add_test(NAME "${testcase}_default"
|
||||
COMMAND ${testcase} ${CATCH_TEST_FILTER}
|
||||
COMMAND ${testcase} ${DOCTEST_TEST_FILTER}
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
)
|
||||
set_tests_properties("${testcase}_default" PROPERTIES LABELS "default")
|
||||
|
||||
add_test(NAME "${testcase}_all"
|
||||
COMMAND ${testcase} ${CATCH_TEST_FILTER} "*"
|
||||
COMMAND ${testcase} ${DOCTEST_TEST_FILTER} --no-skip
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
)
|
||||
set_tests_properties("${testcase}_all" PROPERTIES LABELS "all")
|
||||
|
||||
if(JSON_Valgrind)
|
||||
add_test(NAME "${testcase}_valgrind"
|
||||
COMMAND ${memcheck_command} ${CMAKE_CURRENT_BINARY_DIR}/${testcase} ${CATCH_TEST_FILTER}
|
||||
COMMAND ${memcheck_command} ${CMAKE_CURRENT_BINARY_DIR}/${testcase} ${DOCTEST_TEST_FILTER}
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
)
|
||||
set_tests_properties("${testcase}_valgrind" PROPERTIES LABELS "valgrind")
|
||||
|
||||
Reference in New Issue
Block a user