File: ErrorsCommon.cmake

package info (click to toggle)
cmake 3.25.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 121,376 kB
  • sloc: ansic: 361,053; cpp: 250,806; sh: 3,828; yacc: 3,243; python: 2,707; lex: 1,328; lisp: 382; asm: 371; f90: 314; java: 266; perl: 217; objc: 212; xml: 202; cs: 200; fortran: 131; makefile: 99; javascript: 83; pascal: 63; tcl: 55; php: 25; ruby: 22
file content (55 lines) | stat: -rw-r--r-- 1,519 bytes parent folder | download | duplicates (11)
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
# This CMakeLists file is *sometimes expected* to result in a configure error.
#
# expect this to succeed:
# ../bin/Release/cmake -G Xcode
#   ../../CMake/Tests/CMakeCommands/build_command
#
# expect this to fail:
# ../bin/Release/cmake -DTEST_ERROR_CONDITIONS:BOOL=ON -G Xcode
#   ../../CMake/Tests/CMakeCommands/build_command
#
# This project exists merely to test the CMake command 'build_command'...
# ...even purposefully calling it with known-bad argument lists to cover
# error handling code.
#

set(cmd "initial")

message("0. begin")

if(TEST_ERROR_CONDITIONS)
  # Test with no arguments (an error):
  build_command()
  message("1. cmd='${cmd}'")

  # Test with unknown arguments (also an error):
  build_command(cmd BOGUS STUFF)
  message("2. cmd='${cmd}'")

  build_command(cmd STUFF BOGUS)
  message("3. cmd='${cmd}'")
else()
  message("(skipping cases 1, 2 and 3 because TEST_ERROR_CONDITIONS is OFF)")
endif()

# Test the one arg signature with none of the optional KEYWORD arguments:
build_command(cmd)
message("4. cmd='${cmd}'")

# Test the two-arg legacy signature:
build_command(legacy_cmd ${CMAKE_MAKE_PROGRAM})
message("5. legacy_cmd='${legacy_cmd}'")
message("   CMAKE_MAKE_PROGRAM='${CMAKE_MAKE_PROGRAM}'")

# Test the optional KEYWORDs:
build_command(cmd CONFIGURATION hoohaaConfig)
message("6. cmd='${cmd}'")

build_command(cmd PROJECT_NAME hoohaaProject)
message("7. cmd='${cmd}'")

build_command(cmd TARGET hoohaaTarget)
message("8. cmd='${cmd}'")

set(cmd "final")
message("9. cmd='${cmd}'")