1 cmake_minimum_required (VERSION 2.6)
4 SET(CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS}")
6 # Build the to-clean project.
7 TRY_COMPILE(TOCLEAN_BUILT
8 ${MakeClean_BINARY_DIR}/ToClean
9 ${MakeClean_SOURCE_DIR}/ToClean
11 OUTPUT_VARIABLE OUTPUT
15 "Building ToClean succeeded with the following output:\n"
20 "Building ToClean failed with the following output:\n"
25 # Get the set of files to check from the ToClean project.
26 INCLUDE(${MakeClean_BINARY_DIR}/ToClean/ToCleanFiles.cmake)
28 # Check for the existence of the files.
29 FOREACH(f ${TOCLEAN_FILES})
32 MESSAGE(FATAL_ERROR "File \"${f}\" does not exist!")
36 # Enable ANSI flags for the C executable.
38 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_ANSI_CFLAGS}")
39 ENDIF(CMAKE_ANSI_CFLAGS)
41 # Configure an executable to check that all the files are missing.
43 FOREACH(f ${TOCLEAN_FILES})
44 SET(CHECK_FILES "${CHECK_FILES} \"${f}\",\n")
46 CONFIGURE_FILE(${MakeClean_SOURCE_DIR}/check_clean.c.in
47 ${MakeClean_BINARY_DIR}/check_clean.c @ONLY IMMEDIATE)
48 ADD_EXECUTABLE(check_clean ${MakeClean_BINARY_DIR}/check_clean.c)
50 # After the executable builds, clean the files.
54 COMMAND ${CMAKE_CTEST_COMMAND}
56 ${MakeClean_SOURCE_DIR}/ToClean
57 ${MakeClean_BINARY_DIR}/ToClean
58 --build-generator ${CMAKE_GENERATOR}
59 --build-project ToClean
60 --build-makeprogram ${CMAKE_MAKE_PROGRAM}
63 COMMENT "Clean the ToClean Project"