Debian Codegraph @

Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt

raw
1 # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 # file LICENSE.rst or https://cmake.org/licensing for details.
3
4 cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
5
6 project(test C)
7
8 message("Copy project")
9 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt.in
10 ${CMAKE_CURRENT_BINARY_DIR}/src/CMakeLists.txt COPYONLY)
11
12 file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/test.c
13 DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/src
14 )
15
16 message("Building project")
17 set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
18 try_compile(RESULT
19 ${CMAKE_CURRENT_BINARY_DIR}/build
20 ${CMAKE_CURRENT_BINARY_DIR}/src
21 test
22 CMAKE_FLAGS
23 -DRUN_TEST=${RUN_TEST}
24 -DCMAKE_BUILD_TYPE=${RUN_TEST_BUILD_TYPE}
25 OUTPUT_VARIABLE OUTPUT)
26
27 message("Output from build:\n${OUTPUT}")
28 if (RUN_TEST STREQUAL "RELEASE_FLAGS")
29 find_file (fileName test_none.gpj
30 ${CMAKE_CURRENT_BINARY_DIR}/build/test_none.dir
31 )
32 message("Parsing project file: ${fileName}")
33 file(STRINGS ${fileName} fileText)
34 set(opt "-unexpected_release_option")
35 string(FIND "${fileText}" "${opt}" opt_found)
36 if ( NOT opt_found EQUAL -1 )
37 message(SEND_ERROR "Release option found: ${opt}")
38 endif()
39 else()
40 unset(fileName CACHE)
41 find_file (fileName K1.gpj
42 ${CMAKE_CURRENT_BINARY_DIR}/build/K1.dir
43 )
44 message("Parsing project file: ${fileName}")
45 file(STRINGS ${fileName} fileText)
46 set(opt "-required-debug-option")
47 string(FIND "${fileText}" "${opt}" opt_found)
48 if ( opt_found EQUAL -1 )
49 message(SEND_ERROR "Missing debug option: ${opt}")
50 endif()
51
52 unset(fileName CACHE)
53 find_file (fileName K2.gpj
54 ${CMAKE_CURRENT_BINARY_DIR}/build/K2.dir
55 )
56 message("Parsing project file: ${fileName}")
57 file(STRINGS ${fileName} fileText)
58 set(opt "-required-debug-option")
59 string(FIND "${fileText}" "${opt}" opt_found)
60 if ( opt_found EQUAL -1 )
61 message(SEND_ERROR "Missing debug option: ${opt}")
62 endif()
63
64 unset(fileName CACHE)
65 find_file (fileName K3.gpj
66 ${CMAKE_CURRENT_BINARY_DIR}/build/K3.dir
67 )
68 message("Parsing project file: ${fileName}")
69 file(STRINGS ${fileName} fileText)
70 set(opt "-required-debug-option")
71 string(FIND "${fileText}" "${opt}" opt_found)
72 if ( opt_found EQUAL -1 )
73 message(SEND_ERROR "Missing debug option: ${opt}")
74 endif()
75
76 unset(fileName CACHE)
77 find_file (fileName K4.gpj
78 ${CMAKE_CURRENT_BINARY_DIR}/build/K4.dir
79 )
80 message("Parsing project file: ${fileName}")
81 file(STRINGS ${fileName} fileText)
82 set(opt "-required-debug-option")
83 string(FIND "${fileText}" "${opt}" opt_found)
84 if ( opt_found EQUAL -1 )
85 message(SEND_ERROR "Missing debug option: ${opt}")
86 endif()
87 endif()