From 5230ac8748520b176845453e117d7a6153a1781b Mon Sep 17 00:00:00 2001 From: "Christopher M. Punches" Date: Sun, 16 Aug 2026 01:18:55 -0400 Subject: [PATCH] Separate clean from distclean MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit clean removes what the build produced and leaves the configured build system, so a build following it proceeds without reconfiguring. Deleting the build system from clean broke that: the target lives in the Makefile it removes, so nothing in the directory could drive a rebuild afterward. distclean empties the directory, build system included. It is terminal — the next step is `cmake -B ` from outside — and it is what proves a change against a tree carrying no state from earlier runs. --- CMakeLists.txt | 48 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d3af3d..14ecdb8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -132,23 +132,49 @@ add_subdirectory(docs ${CMAKE_BINARY_DIR}/docs-build) # --------------------------------------------------------------------- # Clean # --------------------------------------------------------------------- -# clean removes what the build produced: the artifact directories, the -# generated documentation, and the test scratch areas. -# -# The generated build system stays. CMakeCache.txt, the makefiles, -# CMakeFiles/, and the CMake file API directory under .cmake/ are what an -# IDE reads to know the project's targets exist; deleting them leaves the -# directory unconfigured, so every target in the IDE stops resolving until -# the project is reloaded. Removing the build system is what configuring a -# fresh directory is for. +# clean removes everything the build produced and leaves the configured +# build system in place, so the next build proceeds from the directory +# as it stands. set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES - ${DPM_TEST_RESULTS_DIR} - ${CMAKE_BINARY_DIR}/Testing + # Build artifacts. ${CMAKE_BINARY_DIR}/bin ${CMAKE_BINARY_DIR}/lib ${CMAKE_BINARY_DIR}/modules ${DPM_TEST_DIR} ${DPM_DOCS_DIR} + + # Test scratch areas. + ${DPM_TEST_RESULTS_DIR} + ${CMAKE_BINARY_DIR}/Testing +) + +# distclean empties the build directory, the generated build system +# included, leaving what a freshly created directory holds: nothing. +# +# It is a terminal operation. Nothing inside the directory can drive a +# build afterwards, so the next step is `cmake -B ` from outside +# it. Use it to prove a change against a tree carrying no state from +# earlier runs. +add_custom_target(distclean + COMMAND ${CMAKE_COMMAND} -E rm -rf + ${CMAKE_BINARY_DIR}/bin + ${CMAKE_BINARY_DIR}/lib + ${CMAKE_BINARY_DIR}/modules + ${DPM_TEST_DIR} + ${DPM_DOCS_DIR} + ${DPM_TEST_RESULTS_DIR} + ${CMAKE_BINARY_DIR}/Testing + ${CMAKE_BINARY_DIR}/CMakeFiles + ${CMAKE_BINARY_DIR}/CMakeCache.txt + ${CMAKE_BINARY_DIR}/Makefile + ${CMAKE_BINARY_DIR}/cmake_install.cmake + ${CMAKE_BINARY_DIR}/CTestTestfile.cmake + ${CMAKE_BINARY_DIR}/DartConfiguration.tcl + ${CMAKE_BINARY_DIR}/.cmake + ${CMAKE_BINARY_DIR}/CMakeDoxyfile.in + ${CMAKE_BINARY_DIR}/CMakeDoxygenDefaults.cmake + ${CMAKE_BINARY_DIR}/docs-build + COMMENT "Emptying the build directory" ) # ---------------------------------------------------------------------