cmake: Remove clobber script

CMake discourages in-tree builds (i.e., when PROJECT_SOURCE_DIR equals
PROJECT_BINARY_DIR), and so is the use of a clobber script for in-tree
builds.
This commit is contained in:
Xavier Del Campo Romero 2025-01-17 06:40:30 +01:00
parent e26c923811
commit 791428f66c
Signed by: xavi
GPG key ID: 84FF3612A9BF43F2
2 changed files with 0 additions and 116 deletions

View file

@ -153,11 +153,6 @@ ENDIF("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}")
# Must be the last ADD_SUBDIRECTORY for FIXUP_BUNDLE to work
ADD_SUBDIRECTORY(packaging)
# Generate a 'make clobber'-like clobber.sh/.bat script in case of an in-source build.
IF("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}")
SD_GENERATE_CLOBBER_SCRIPT()
ENDIF("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}")
# Add an unistall target.
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/cmake/uninstall.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake" IMMEDIATE @ONLY)

View file

@ -191,117 +191,6 @@ MACRO(SD_ADD_LIBRARY TARGET_NAME TARGET_TYPE)
ENDMACRO(SD_ADD_LIBRARY TARGET_NAME TARGET_TYPE)
# Generate clobber.sh/bat shell script (remove _any_ build system generated file)
MACRO(SD_GENERATE_CLOBBER_SCRIPT)
IF(MSVC)
SET(TGT_SCRIPT "${CMAKE_SOURCE_DIR}/clobber.bat")
FILE(WRITE "${TGT_SCRIPT}" "@echo off\n")
FILE(APPEND "${TGT_SCRIPT}" "rem CMake-generated script for in-source build tree total cleanup\n")
FILE(APPEND "${TGT_SCRIPT}" "rem (remove any build-system-generated file (+ .bak, *~, ... etc), \n")
FILE(APPEND "${TGT_SCRIPT}" "rem in case you want to get back to something like\n")
FILE(APPEND "${TGT_SCRIPT}" "rem right after a 'svn checkout' command).\n")
FILE(APPEND "${TGT_SCRIPT}" "\n")
FILE(APPEND "${TGT_SCRIPT}" "rem Check if we are on top of a CMake-enabled SD source tree\n")
FILE(APPEND "${TGT_SCRIPT}" "if not exist CMakeLists.txt goto ERROR\n")
FILE(APPEND "${TGT_SCRIPT}" "if not exist cmake goto ERROR\n")
FILE(APPEND "${TGT_SCRIPT}" "if not exist data goto ERROR\n")
FILE(APPEND "${TGT_SCRIPT}" "if not exist src goto ERROR\n")
FILE(APPEND "${TGT_SCRIPT}" "\n")
FILE(APPEND "${TGT_SCRIPT}" "echo Cleaning up in-source build tree ...\n")
FILE(APPEND "${TGT_SCRIPT}" "\n")
FILE(APPEND "${TGT_SCRIPT}" "rem CMake/compiler generated files and dirs\n")
FILE(APPEND "${TGT_SCRIPT}" "\n")
FILE(APPEND "${TGT_SCRIPT}" "del CMakeCache.txt\n")
FILE(APPEND "${TGT_SCRIPT}" "del CMakeLists.txt.user\n")
FILE(APPEND "${TGT_SCRIPT}" "del config.h\n")
FILE(APPEND "${TGT_SCRIPT}" "del CPackConfig.cmake\n")
FILE(APPEND "${TGT_SCRIPT}" "del CPackSourceConfig.cmake\n")
FILE(APPEND "${TGT_SCRIPT}" "del uninstall.cmake\n")
FILE(APPEND "${TGT_SCRIPT}" "del doxygen_config\n")
FILE(APPEND "${TGT_SCRIPT}" "del install_manifest.txt\n")
FILE(APPEND "${TGT_SCRIPT}" "del speed-dreams-2.ncb\n")
FILE(APPEND "${TGT_SCRIPT}" "del /ah speed-dreams-2.suo\n")
FILE(APPEND "${TGT_SCRIPT}" "del speed-dreams-2.sln\n")
FILE(APPEND "${TGT_SCRIPT}" "del version.h\n")
FILE(APPEND "${TGT_SCRIPT}" "del xmlversion_loc.txt\n")
FILE(APPEND "${TGT_SCRIPT}" "del /s /q *.vcproj*\n")
FILE(APPEND "${TGT_SCRIPT}" "del /s /q cmake_install.cmake\n")
FILE(APPEND "${TGT_SCRIPT}" "for /f \"tokens=*\" %%G in ('dir /b /ad /s CMakeFiles*') do rmdir /s /q %%G\n")
FILE(APPEND "${TGT_SCRIPT}" "for /f \"tokens=*\" %%G in ('dir /b /ad /s *.dir') do rmdir /s /q %%G\n")
FILE(APPEND "${TGT_SCRIPT}" "for /f \"tokens=*\" %%G in ('dir /b /ad /s Debug*') do rmdir /s /q %%G\n")
FILE(APPEND "${TGT_SCRIPT}" "for /f \"tokens=*\" %%G in ('dir /b /ad /s Release*') do rmdir /s /q %%G\n")
FILE(APPEND "${TGT_SCRIPT}" "rmdir /s /q _CPack_Packages\n")
FILE(APPEND "${TGT_SCRIPT}" "\n")
FILE(APPEND "${TGT_SCRIPT}" "rem Other useless files\n")
FILE(APPEND "${TGT_SCRIPT}" "del /s /q *.*~\n")
FILE(APPEND "${TGT_SCRIPT}" "del /s /q *.~*\n")
FILE(APPEND "${TGT_SCRIPT}" "del /s /q *.bak\n")
FILE(APPEND "${TGT_SCRIPT}" "del /s /q *.flc\n")
FILE(APPEND "${TGT_SCRIPT}" "del /s /q *.orig\n")
FILE(APPEND "${TGT_SCRIPT}" "del /s /q *.cbp\n")
FILE(APPEND "${TGT_SCRIPT}" "\n")
FILE(APPEND "${TGT_SCRIPT}" "echo Done.\n")
FILE(APPEND "${TGT_SCRIPT}" "\n")
FILE(APPEND "${TGT_SCRIPT}" "goto END\n")
FILE(APPEND "${TGT_SCRIPT}" "\n")
FILE(APPEND "${TGT_SCRIPT}" ":ERROR\n")
FILE(APPEND "${TGT_SCRIPT}" "\n")
FILE(APPEND "${TGT_SCRIPT}" "echo Bad current dir for that ; please run from the root folder of a CMake-enabled SD source tree.\n")
FILE(APPEND "${TGT_SCRIPT}" "\n")
FILE(APPEND "${TGT_SCRIPT}" ":END\n")
ELSE(MSVC)
SET(TGT_SCRIPT "${CMAKE_SOURCE_DIR}/clobber.sh")
FILE(WRITE "${TGT_SCRIPT}" "#!/bin/sh\n")
FILE(APPEND "${TGT_SCRIPT}" "# CMake-generated script for in-source build tree total cleanup\n")
FILE(APPEND "${TGT_SCRIPT}" "# (remove any build-system-generated file (+ .bak, *~, ... etc), \n")
FILE(APPEND "${TGT_SCRIPT}" "# in case you want to get back to something like\n")
FILE(APPEND "${TGT_SCRIPT}" "# right after a 'svn checkout' command).\n")
FILE(APPEND "${TGT_SCRIPT}" "\n")
FILE(APPEND "${TGT_SCRIPT}" "# Check if we are on top of a CMake-enabled SD source tree\n")
FILE(APPEND "${TGT_SCRIPT}" "if [ -f CMakeLists.txt -a -d cmake -a -d data -a -d src ] ; then\n")
FILE(APPEND "${TGT_SCRIPT}" "\n")
FILE(APPEND "${TGT_SCRIPT}" " echo \"Cleaning up in-source build tree ...\"\n")
FILE(APPEND "${TGT_SCRIPT}" " \n")
FILE(APPEND "${TGT_SCRIPT}" " # CMake/compiler generated files and dirs\n")
FILE(APPEND "${TGT_SCRIPT}" " rm -f CMakeCache.txt CMakeLists.txt.user config.h doxygen_config\n")
FILE(APPEND "${TGT_SCRIPT}" " rm -f CPackConfig.cmake CPackSourceConfig.cmake\n")
FILE(APPEND "${TGT_SCRIPT}" " rm -f uninstall.cmake\n")
FILE(APPEND "${TGT_SCRIPT}" " rm -f xmlversion_loc.txt install_manifest.txt version.h.txt\n")
FILE(APPEND "${TGT_SCRIPT}" " rm -fr _CPack_Packages\n")
FILE(APPEND "${TGT_SCRIPT}" " find . -depth -type d -name \"CMakeFiles\" -exec rm -fr {} \\;\n")
FILE(APPEND "${TGT_SCRIPT}" " find . -type f -name \"cmake_install.cmake\" -delete\n")
FILE(APPEND "${TGT_SCRIPT}" " find . -type f -name \"Makefile\" -delete\n")
FILE(APPEND "${TGT_SCRIPT}" " find . -type f -name \"*.so\" -delete\n")
FILE(APPEND "${TGT_SCRIPT}" " find src/tools -type f -name \"sd2-*\" -delete\n")
FILE(APPEND "${TGT_SCRIPT}" " find src/tools/xmlversion -type f -name \"xmlversion\" -delete\n")
FILE(APPEND "${TGT_SCRIPT}" " find src/main -type f -name \"speed-dreams-2\" -delete\n")
FILE(APPEND "${TGT_SCRIPT}" "\n")
FILE(APPEND "${TGT_SCRIPT}" " # Other useless files\n")
FILE(APPEND "${TGT_SCRIPT}" " find . -type f -name \"*.rej\" -delete\n")
FILE(APPEND "${TGT_SCRIPT}" " find . -type f -name \"*.orig\" -delete\n")
FILE(APPEND "${TGT_SCRIPT}" " find . -type f -name \"*.flc\" -delete\n")
FILE(APPEND "${TGT_SCRIPT}" " find . -type f -name \"*.bak\" -delete\n")
FILE(APPEND "${TGT_SCRIPT}" " find . -type f -name \"*.cbp\" -delete\n")
FILE(APPEND "${TGT_SCRIPT}" " find . -type f -name \"*.a\" -delete\n")
FILE(APPEND "${TGT_SCRIPT}" " find . -type f -name \"*~\" -delete\n")
FILE(APPEND "${TGT_SCRIPT}" " find . -type f -name \"*.~*\" -delete\n")
FILE(APPEND "${TGT_SCRIPT}" " \n")
FILE(APPEND "${TGT_SCRIPT}" " echo \"Done.\"\n")
FILE(APPEND "${TGT_SCRIPT}" " \n")
FILE(APPEND "${TGT_SCRIPT}" "else\n")
FILE(APPEND "${TGT_SCRIPT}" " echo \"Bad current dir for that ; please run from the root folder of a CMake-enabled SD source tree.\"\n")
FILE(APPEND "${TGT_SCRIPT}" "fi\n")
EXECUTE_PROCESS(COMMAND chmod ugo+x ${TGT_SCRIPT})
ENDIF(MSVC)
ENDMACRO(SD_GENERATE_CLOBBER_SCRIPT)
ADD_COMPILE_DEFINITIONS(HAVE_CONFIG_H)
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})