Debian Codegraph @

debian/core-test/meta/sample.cmake

raw
1 # sample.cmake: Tests run_and_sort to make sure it's working.
2
3 cmake_minimum_required(VERSION 3.5)
4
5 # See documentation links at https://stackoverflow.com/q/12802377/2877364
6 set( tests_meta_sample_dir "${CMAKE_CURRENT_LIST_DIR}" )
7 list( APPEND CMAKE_MODULE_PATH "${tests_meta_sample_dir}/../cmake" )
8 include( runandsort )
9
10 run_and_sort( RETVAL lines RETVAL_FAILURE did_fail
11 CAPTURE_STDERR TRIM_INITIAL_LEADING_SPACE # since we're using almostcat
12 CMDLINE "cmake" "-DWHICH:STRING=${tests_meta_sample_dir}/sample.txt"
13 "-P" "${tests_meta_sample_dir}/../cmake/almostcat.cmake"
14 ) # Don't use cat(1) since we might be running on Windows
15
16 if( ${did_fail} )
17 message( FATAL_ERROR "Program returned a nonzero exit code" )
18 return()
19 endif()
20
21 # message() will give us an extra \n, so trim one if we can.
22 string( REGEX REPLACE "(\r\n|\r|\n)$" "" lines "${lines}" )
23
24 message( "${lines}" )
25 # This outputs to stderr, and prints nothing extra except for a \n at the end
26
27 # Note that message( STATUS "${lines}" ) doesn't work because it outputs a "--"
28 # before the actual content.
29
30 # You could also use execute_process( COMMAND "echo" "${lines}" )
31 # or cmake -E echo, but I think the message() call is good enough.