1project (mipi_syst_printer) 2cmake_minimum_required (VERSION 2.8) 3enable_testing() 4 5# External third party build dependencies: 6# * PugiXML https://github.com/zeux/pugixml 7# 8if (NOT DEFINED PUGIXML_SRC_DIR) 9 get_filename_component(PUGIXML "${CMAKE_CURRENT_LIST_DIR}/../external/pugixml/src" ABSOLUTE) 10 set(PUGIXML_SRC_DIR "${PUGIXML}" CACHE PATH "Location of pugixml XML parser code") 11endif() 12if (NOT EXISTS "${PUGIXML_SRC_DIR}/pugixml.cpp") 13 message(FATAL_ERROR 14 "PUGIXML_SRC_DIR=${PUGIXML_SRC_DIR} does not point to pugixml sources. Try running\n" 15 "git submodule update --init --recursive\n" 16 "to populate the external folder git submodules or change PUGIXML_SRC_DIR to point to pugixml sources." 17 ) 18endif() 19 20if (WIN32) 21 add_definitions(-D_CRT_SECURE_NO_WARNINGS) 22endif() 23 24set (printer_Includes 25 include/mipi_syst_collateral.h 26 include/mipi_syst_printer.h 27 include/mipi_syst_decode.h 28 include/mipi_syst_message.h 29 include/mipi_syst_guid.h 30 include/mipi_syst_printf.h 31 32 ${PUGIXML_SRC_DIR}/pugixml.hpp 33) 34 35set (printer_Sources 36 src/mipi_syst_main.cpp 37 src/mipi_syst_collateral.cpp 38 src/mipi_syst_printf.cpp 39 src/mipi_syst_decode.cpp 40 src/mipi_syst_message.cpp 41 ${PUGIXML_SRC_DIR}/pugixml.cpp 42) 43 44include_directories( 45 include 46 ${PUGIXML_SRC_DIR} 47) 48 49add_executable(systprint 50 ${printer_Includes} 51 ${printer_Sources} 52) 53 54# Request C++11 support 55# 56if (CMAKE_VERSION VERSION_LESS "3.1") 57 if (CMAKE_CXX_COMPILER_ID STREQUAL "CLANG") 58 set (CMAKE_CXX_FLAGS "-std=c++11" ${CMAKE_CXX_FLAGS}) 59 elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") 60 message( STATUS ${CMAKE_CXX_COMPILER_ID}) 61 set (CMAKE_CXX_FLAGS "-std=gnu++11" ${CMAKE_CXX_FLAGS}) 62 endif() 63else() 64 set_property(TARGET systprint PROPERTY CXX_STANDARD 11) 65endif() 66 67install(TARGETS systprint 68 RUNTIME DESTINATION bin 69 LIBRARY DESTINATION lib 70 ARCHIVE DESTINATION lib 71) 72 73# Simple test that print an input file 74add_test( 75 NAME print_client_example 76 COMMAND systprint --short_guid {494E5443-8A9C-4014-A65A-2F36A36D96E4} --collateral collateral.xml input_client64.txt 77 WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/test 78) 79 80# pass option as single "^" separated option to test script to avoid CMAKE string list modifications on blanks 81# 82set(TEST_OPTIONS --short_guid {494E5443-8A9C-4014-A65A-2F36A36D96E4} --collateral collateral.xml) 83string(REPLACE ";" "^" TEST_OPTIONS "${TEST_OPTIONS}") 84 85# Compare output from 32bit client 86# 87add_test( 88 NAME diff_output_with_32bit_reference 89 COMMAND ${CMAKE_COMMAND} 90 -DEXECUTABLE=$<TARGET_FILE:systprint> 91 -DOPTIONS=${TEST_OPTIONS}^input_client32.txt 92 -DTEST_REFERENCE=output_client32.txt 93 -DTEST_OUTPUT=${CMAKE_CURRENT_BINARY_DIR}/output32.txt 94 -P ${CMAKE_CURRENT_SOURCE_DIR}/test/diff.cmake 95 WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/test 96) 97 98# Compare output from 64bit client 99# 100add_test( 101 NAME diff_output_with_64bit_reference 102 COMMAND ${CMAKE_COMMAND} 103 -DEXECUTABLE=$<TARGET_FILE:systprint> 104 -DOPTIONS=${TEST_OPTIONS}^input_client64.txt 105 -DTEST_REFERENCE=output_client64.txt 106 -DTEST_OUTPUT=${CMAKE_CURRENT_BINARY_DIR}/output64.txt 107 -P ${CMAKE_CURRENT_SOURCE_DIR}/test/diff.cmake 108 WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/test 109) 110# Add verbose test target to show the output of the tools run by tests 111# 112if (CMAKE_CONFIGURATION_TYPES) 113 add_custom_target(RUN_TEST_VERBOSE COMMAND ${CMAKE_CTEST_COMMAND} 114 --force-new-ctest-process --verbose 115 --build-config "$<CONFIGURATION>") 116else() 117 add_custom_target(RUN_TEST_VERBOSE COMMAND ${CMAKE_CTEST_COMMAND} 118 --force-new-ctest-process --verbose) 119endif() 120 121