File: CMakeLists.txt

package info (click to toggle)
cmake 4.2.3-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 152,456 kB
  • sloc: ansic: 403,896; cpp: 303,920; sh: 4,105; python: 3,583; yacc: 3,106; lex: 1,279; f90: 538; asm: 471; lisp: 375; cs: 270; java: 266; fortran: 239; objc: 215; perl: 213; xml: 198; makefile: 111; javascript: 83; pascal: 63; tcl: 55; php: 25; ruby: 22
file content (87 lines) | stat: -rw-r--r-- 2,656 bytes parent folder | download | duplicates (3)
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
# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
# file LICENSE.rst or https://cmake.org/licensing for details.

cmake_minimum_required(VERSION 3.12 FATAL_ERROR)

project(test C)

message("Copy project")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt.in
  ${CMAKE_CURRENT_BINARY_DIR}/src/CMakeLists.txt COPYONLY)

file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/test.c
  DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/src
)

message("Building project")
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
try_compile(RESULT
  ${CMAKE_CURRENT_BINARY_DIR}/build
  ${CMAKE_CURRENT_BINARY_DIR}/src
  test
  CMAKE_FLAGS
    -DRUN_TEST=${RUN_TEST}
    -DCMAKE_BUILD_TYPE=${RUN_TEST_BUILD_TYPE}
  OUTPUT_VARIABLE OUTPUT)

message("Output from build:\n${OUTPUT}")
if (RUN_TEST STREQUAL "RELEASE_FLAGS")
  find_file (fileName test_none.gpj
    ${CMAKE_CURRENT_BINARY_DIR}/build/test_none.dir
    )
  message("Parsing project file: ${fileName}")
  file(STRINGS ${fileName} fileText)
  set(opt "-unexpected_release_option")
  string(FIND "${fileText}" "${opt}" opt_found)
  if ( NOT opt_found EQUAL -1 )
    message(SEND_ERROR "Release option found: ${opt}")
  endif()
else()
  unset(fileName CACHE)
  find_file (fileName K1.gpj
    ${CMAKE_CURRENT_BINARY_DIR}/build/K1.dir
    )
  message("Parsing project file: ${fileName}")
  file(STRINGS ${fileName} fileText)
  set(opt "-required-debug-option")
  string(FIND "${fileText}" "${opt}" opt_found)
  if ( opt_found EQUAL -1 )
    message(SEND_ERROR "Missing debug option: ${opt}")
  endif()

  unset(fileName CACHE)
  find_file (fileName K2.gpj
    ${CMAKE_CURRENT_BINARY_DIR}/build/K2.dir
    )
  message("Parsing project file: ${fileName}")
  file(STRINGS ${fileName} fileText)
  set(opt "-required-debug-option")
  string(FIND "${fileText}" "${opt}" opt_found)
  if ( opt_found EQUAL -1 )
    message(SEND_ERROR "Missing debug option: ${opt}")
  endif()

  unset(fileName CACHE)
  find_file (fileName K3.gpj
    ${CMAKE_CURRENT_BINARY_DIR}/build/K3.dir
    )
  message("Parsing project file: ${fileName}")
  file(STRINGS ${fileName} fileText)
  set(opt "-required-debug-option")
  string(FIND "${fileText}" "${opt}" opt_found)
  if ( opt_found EQUAL -1 )
    message(SEND_ERROR "Missing debug option: ${opt}")
  endif()

  unset(fileName CACHE)
  find_file (fileName K4.gpj
    ${CMAKE_CURRENT_BINARY_DIR}/build/K4.dir
    )
  message("Parsing project file: ${fileName}")
  file(STRINGS ${fileName} fileText)
  set(opt "-required-debug-option")
  string(FIND "${fileText}" "${opt}" opt_found)
  if ( opt_found EQUAL -1 )
    message(SEND_ERROR "Missing debug option: ${opt}")
  endif()
endif()