File: test.cmake.in

package info (click to toggle)
cmake 4.2.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, 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 (64 lines) | stat: -rw-r--r-- 2,173 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
cmake_minimum_required(VERSION 3.10)

set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestEmptyBinaryDirectory")
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestEmptyBinaryDirectory")

# make sure ctest does not remove directories without a CMakeCache.txt in it
set(EMPTY_BINARY_DIR "${CTEST_BINARY_DIRECTORY}/empty_binary_dir")
file(MAKE_DIRECTORY "${EMPTY_BINARY_DIR}")

if(NOT EXISTS "${EMPTY_BINARY_DIR}"
  OR EXISTS "${EMPTY_BINARY_DIR}/CMakeCache.txt")
    message(FATAL_ERROR "empty_binary_dir precondition failed")
endif()

ctest_empty_binary_directory("${EMPTY_BINARY_DIR}")

if(NOT EXISTS "${EMPTY_BINARY_DIR}")
  message(FATAL_ERROR "empty_binary_dir should not have been removed")
endif()

# make sure ctest does remove directories with a CMakeCache.txt
set(VALID_BINARY_DIR "${CTEST_BINARY_DIRECTORY}/valid_binary_dir")
file(MAKE_DIRECTORY "${VALID_BINARY_DIR}")
file(WRITE "${VALID_BINARY_DIR}/CMakeCache.txt")

if(NOT EXISTS "${VALID_BINARY_DIR}"
  OR NOT EXISTS "${VALID_BINARY_DIR}/CMakeCache.txt")
    message(FATAL_ERROR "valid_binary_dir precondition failed")
endif()

ctest_empty_binary_directory("${VALID_BINARY_DIR}")

if(EXISTS "${VALID_BINARY_DIR}")
  message(FATAL_ERROR "valid_binary_dir should have been removed")
endif()

# make sure ctest removes build directories recursively
set(DEEP_BINARY_DIR "${CTEST_BINARY_DIRECTORY}/deep_binary_dir")
file(MAKE_DIRECTORY "${DEEP_BINARY_DIR}")
file(WRITE "${DEEP_BINARY_DIR}/CMakeCache.txt")

foreach(SUBDIR A Z A/A A/Z Z/A Z/Z)
  set(FULL_SUBDIR "${DEEP_BINARY_DIR}/${SUBDIR}")
  file(MAKE_DIRECTORY "${FULL_SUBDIR}")

  foreach(SUBFILE A.cpp Z.bat)
    set(FULL_SUBFILE "${FULL_SUBDIR}/${SUBFILE}")
    file(WRITE "${FULL_SUBFILE}" "I am '${FULL_SUBFILE}'")
  endforeach()
endforeach()

if(NOT EXISTS "${DEEP_BINARY_DIR}"
  OR NOT EXISTS "${DEEP_BINARY_DIR}/CMakeCache.txt"
  OR NOT EXISTS "${DEEP_BINARY_DIR}/Z/A/Z.bat")
    message(FATAL_ERROR "deep_binary_dir precondition failed")
endif()

ctest_empty_binary_directory("${DEEP_BINARY_DIR}")

if(EXISTS "${DEEP_BINARY_DIR}")
  message(FATAL_ERROR "deep_binary_dir should have been removed")
endif()

message("TEST_SUCCESS")