Skip to content

Commit

Permalink
Update cleanup.cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
lyndskg authored Jan 7, 2024
1 parent 671ad7b commit 9928aa8
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion cleanup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,51 @@
## cmake/cleanup.cmake

# Clean build artifacts

# Remove CMake-generated build directory contents
file(REMOVE_RECURSE "${CMAKE_BINARY_DIR}/CMakeFiles")
file(REMOVE "${CMAKE_BINARY_DIR}/Makefile")

# Remove additional build artifacts and directories
file(REMOVE_RECURSE "${CMAKE_BINARY_DIR}/src")
file(REMOVE_RECURSE "${CMAKE_BINARY_DIR}/test")
file(REMOVE "${CMAKE_BINARY_DIR}/black_scholes_cpp")


# Clean compiled object files and libraries

# Gather a list of generated object files and libraries
file(GLOB_RECURSE cmake_generated_files "${CMAKE_BINARY_DIR}/*.o" "${CMAKE_BINARY_DIR}/*.a")

# Iterate through the list and remove each file
foreach(file ${cmake_generated_files})
file(REMOVE "${file}")
endforeach()


# Clean compiled executables

# Gather a list of generated executables
file(GLOB cmake_executables "${CMAKE_BINARY_DIR}/*")

# Iterate through the list and remove each file or directory
foreach(file ${cmake_executables})
# If the current item in the list is a directory and not the 'cmake' directory,
if(IS_DIRECTORY "${file}" AND NOT "${file}" STREQUAL "${CMAKE_BINARY_DIR}/cmake")
## recursively remove the directory and its contents.
file(REMOVE_RECURSE "${file}")
# Else if the current item is not a directory and not the 'CMake' directory,
elseif(NOT "${file}" STREQUAL "${CMAKE_BINARY_DIR}/cmake")
## remove the individual file.
file(REMOVE "${file}")
endif()
endforeach()


# Clean CTest artifacts

# Remove CTest-generated testing artifacts
file(REMOVE_RECURSE "${CMAKE_BINARY_DIR}/Testing")

# Display successful message
# Display successful cleanup message
message(STATUS "Build artifacts cleaned.")

0 comments on commit 9928aa8

Please sign in to comment.