1find_package(PythonInterp 2.6) 2 3add_executable(jsontestrunner_exe 4 main.cpp 5 ) 6 7if(BUILD_SHARED_LIBS) 8 add_compile_definitions( JSON_DLL ) 9endif() 10target_link_libraries(jsontestrunner_exe jsoncpp_lib) 11 12set_target_properties(jsontestrunner_exe PROPERTIES OUTPUT_NAME jsontestrunner_exe) 13 14if(PYTHONINTERP_FOUND) 15 # Run end to end parser/writer tests 16 set(TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../test) 17 set(RUNJSONTESTS_PATH ${TEST_DIR}/runjsontests.py) 18 19 # Run unit tests in post-build 20 # (default cmake workflow hides away the test result into a file, resulting in poor dev workflow?!?) 21 add_custom_target(jsoncpp_readerwriter_tests 22 "${PYTHON_EXECUTABLE}" -B "${RUNJSONTESTS_PATH}" $<TARGET_FILE:jsontestrunner_exe> "${TEST_DIR}/data" 23 DEPENDS jsontestrunner_exe jsoncpp_test 24 ) 25 add_custom_target(jsoncpp_check DEPENDS jsoncpp_readerwriter_tests) 26 27 ## Create tests for dashboard submission, allows easy review of CI results https://my.cdash.org/index.php?project=jsoncpp 28 add_test(NAME jsoncpp_readerwriter 29 COMMAND "${PYTHON_EXECUTABLE}" -B "${RUNJSONTESTS_PATH}" $<TARGET_FILE:jsontestrunner_exe> "${TEST_DIR}/data" 30 WORKING_DIRECTORY "${TEST_DIR}/data" 31 ) 32 add_test(NAME jsoncpp_readerwriter_json_checker 33 COMMAND "${PYTHON_EXECUTABLE}" -B "${RUNJSONTESTS_PATH}" --with-json-checker $<TARGET_FILE:jsontestrunner_exe> "${TEST_DIR}/data" 34 WORKING_DIRECTORY "${TEST_DIR}/data" 35 ) 36endif() 37