json/test/CMakeLists.txt
Robert Marki 639d63217e Define CMake/CTest tests
Instead of copying the test executable and the JSON files used by
the tests at install time, define CMake/CTest tests for running
the json_unit executable from any build directory with the project's
source directory as its working directory.

- call enable_testing in the main lists file to allow the definition
of tests
- remove install commands from the test directory's lists file
- define two tests
  - json_unit_default for running the default tests by executing
json_unit without any arguments
  - json_unit_all for running all the tests by executing json_unit
with the "*" argument
- update the AppVeyor configuration file to use the new testing method
2016-05-18 11:53:49 +02:00

25 lines
836 B
CMake

# The unit test executable.
set(JSON_UNITTEST_TARGET_NAME "json_unit")
add_executable(${JSON_UNITTEST_TARGET_NAME}
"src/catch.hpp"
"src/unit.cpp"
)
set_target_properties(${JSON_UNITTEST_TARGET_NAME} PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON
COMPILE_DEFINITIONS "$<$<CXX_COMPILER_ID:MSVC>:_SCL_SECURE_NO_WARNINGS>"
COMPILE_OPTIONS "$<$<CXX_COMPILER_ID:MSVC>:/EHsc;$<$<CONFIG:Release>:/Od>>"
)
target_include_directories(${JSON_UNITTEST_TARGET_NAME} PRIVATE "src")
target_link_libraries(${JSON_UNITTEST_TARGET_NAME} ${JSON_TARGET_NAME})
add_test(NAME "${JSON_UNITTEST_TARGET_NAME}_default"
COMMAND ${JSON_UNITTEST_TARGET_NAME}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
add_test(NAME "${JSON_UNITTEST_TARGET_NAME}_all"
COMMAND ${JSON_UNITTEST_TARGET_NAME} "*"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)