blob: 5060ae7eea4e676e384183a2268779e1d1582386 (
plain)
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
|
PROJECT(MakeClean)
# Build the to-clean project.
TRY_COMPILE(TOCLEAN_BUILT
${MakeClean_BINARY_DIR}/ToClean
${MakeClean_SOURCE_DIR}/ToClean
ToClean
OUTPUT_VARIABLE OUTPUT
)
IF(TOCLEAN_BUILT)
MESSAGE(
"Building ToClean succeeded with the following output:\n"
"[${OUTPUT}]"
)
ELSE(TOCLEAN_BUILT)
MESSAGE(FATAL_ERROR
"Building ToClean failed with the following output:\n"
"[${OUTPUT}]"
)
ENDIF(TOCLEAN_BUILT)
# Get the set of files to check from the ToClean project.
INCLUDE(${MakeClean_BINARY_DIR}/ToClean/ToCleanFiles.cmake)
# Check for the existence of the files.
FOREACH(f ${TOCLEAN_FILES})
IF(EXISTS "${f}")
ELSE(EXISTS "${f}")
MESSAGE(FATAL_ERROR "File \"${f}\" does not exist!")
ENDIF(EXISTS "${f}")
ENDFOREACH(f)
# Enable ANSI flags for the C executable.
IF(CMAKE_ANSI_CFLAGS)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_ANSI_CFLAGS}")
ENDIF(CMAKE_ANSI_CFLAGS)
# Configure an executable to check that all the files are missing.
SET(CHECK_FILES)
FOREACH(f ${TOCLEAN_FILES})
SET(CHECK_FILES "${CHECK_FILES} \"${f}\",\n")
ENDFOREACH(f)
CONFIGURE_FILE(${MakeClean_SOURCE_DIR}/check_clean.c.in
${MakeClean_BINARY_DIR}/check_clean.c @ONLY IMMEDIATE)
ADD_EXECUTABLE(check_clean ${MakeClean_BINARY_DIR}/check_clean.c)
# After the executable builds, clean the files.
ADD_CUSTOM_COMMAND(
TARGET check_clean
POST_BUILD
COMMAND ${CMAKE_CTEST_COMMAND}
ARGS --build-and-test
${MakeClean_SOURCE_DIR}/ToClean
${MakeClean_BINARY_DIR}/ToClean
--build-generator ${CMAKE_GENERATOR}
--build-project ToClean
--build-makeprogram ${CMAKE_MAKE_PROGRAM}
--build-noclean
--build-target clean
COMMENT "Clean the ToClean Project"
)
|