aboutsummaryrefslogtreecommitdiff
path: root/printer/CMakeLists.txt
blob: 4b7aac5e0fb68b266c6f3cc286d3a1a17cfb1772 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
project (mipi_syst_printer)
cmake_minimum_required (VERSION 2.8)
enable_testing()

# External third party build dependencies:
# * PugiXML https://github.com/zeux/pugixml
#
if (NOT DEFINED PUGIXML_SRC_DIR)
    get_filename_component(PUGIXML "${CMAKE_CURRENT_LIST_DIR}/../external/pugixml/src" ABSOLUTE)
    set(PUGIXML_SRC_DIR "${PUGIXML}" CACHE PATH "Location of pugixml XML parser code")
endif()
if (NOT EXISTS "${PUGIXML_SRC_DIR}/pugixml.cpp")
    message(FATAL_ERROR
        "PUGIXML_SRC_DIR=${PUGIXML_SRC_DIR} does not point to pugixml sources. Try running\n"
        "git submodule update --init --recursive\n"
        "to populate the external folder git submodules or change PUGIXML_SRC_DIR to point to pugixml sources."
    )
endif()

if (WIN32)
    add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()

set (printer_Includes
    include/mipi_syst_collateral.h
    include/mipi_syst_printer.h
    include/mipi_syst_decode.h
    include/mipi_syst_message.h
    include/mipi_syst_guid.h
    include/mipi_syst_printf.h

    ${PUGIXML_SRC_DIR}/pugixml.hpp
)

set (printer_Sources
    src/mipi_syst_main.cpp
    src/mipi_syst_collateral.cpp
    src/mipi_syst_printf.cpp
    src/mipi_syst_decode.cpp
    src/mipi_syst_message.cpp
    ${PUGIXML_SRC_DIR}/pugixml.cpp
)

include_directories(
    include
    ${PUGIXML_SRC_DIR}
)

add_executable(systprint
    ${printer_Includes}
    ${printer_Sources}
)

# Request C++11 support
#
if (CMAKE_VERSION VERSION_LESS "3.1")
    if (CMAKE_CXX_COMPILER_ID STREQUAL "CLANG")
        set (CMAKE_CXX_FLAGS "-std=c++11" ${CMAKE_CXX_FLAGS})
    elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
        message( STATUS ${CMAKE_CXX_COMPILER_ID})
        set (CMAKE_CXX_FLAGS "-std=gnu++11" ${CMAKE_CXX_FLAGS})
    endif()
else()
    set_property(TARGET systprint PROPERTY CXX_STANDARD 11)
endif()

install(TARGETS systprint
    RUNTIME DESTINATION bin
    LIBRARY DESTINATION lib
    ARCHIVE DESTINATION lib
)

# Simple test that print an input file
add_test(
    NAME print_client_example
    COMMAND systprint --short_guid {494E5443-8A9C-4014-A65A-2F36A36D96E4} --collateral collateral.xml input_client64.txt
    WORKING_DIRECTORY  ${CMAKE_CURRENT_LIST_DIR}/test
)

# pass option as single "^" separated option to test script to avoid CMAKE  string list modifications on blanks
#
set(TEST_OPTIONS --short_guid {494E5443-8A9C-4014-A65A-2F36A36D96E4} --collateral collateral.xml)
string(REPLACE ";" "^" TEST_OPTIONS "${TEST_OPTIONS}")

# Compare output from 32bit client
#
add_test(
    NAME diff_output_with_32bit_reference
    COMMAND ${CMAKE_COMMAND}
        -DEXECUTABLE=$<TARGET_FILE:systprint>
        -DOPTIONS=${TEST_OPTIONS}^input_client32.txt
        -DTEST_REFERENCE=output_client32.txt
        -DTEST_OUTPUT=${CMAKE_CURRENT_BINARY_DIR}/output32.txt
        -P ${CMAKE_CURRENT_SOURCE_DIR}/test/diff.cmake
    WORKING_DIRECTORY  ${CMAKE_CURRENT_LIST_DIR}/test
)

# Compare output from 64bit client
#
add_test(
    NAME diff_output_with_64bit_reference
    COMMAND ${CMAKE_COMMAND}
        -DEXECUTABLE=$<TARGET_FILE:systprint>
        -DOPTIONS=${TEST_OPTIONS}^input_client64.txt
        -DTEST_REFERENCE=output_client64.txt
        -DTEST_OUTPUT=${CMAKE_CURRENT_BINARY_DIR}/output64.txt
        -P ${CMAKE_CURRENT_SOURCE_DIR}/test/diff.cmake
    WORKING_DIRECTORY  ${CMAKE_CURRENT_LIST_DIR}/test
)
# Add verbose test target to show the output of the tools run by tests
#
if (CMAKE_CONFIGURATION_TYPES)
    add_custom_target(RUN_TEST_VERBOSE COMMAND ${CMAKE_CTEST_COMMAND}
        --force-new-ctest-process --verbose
        --build-config "$<CONFIGURATION>")
else()
    add_custom_target(RUN_TEST_VERBOSE COMMAND ${CMAKE_CTEST_COMMAND}
        --force-new-ctest-process --verbose)
endif()