opm-simulators/cmake/Scripts/RemoveEmptyDir.cmake

16 lines
333 B
CMake
Raw Normal View History

2013-05-15 03:24:52 -05:00
# - Remove a directory if and only if it contains no files
#
# Pass the name of the directory as the DIR variable
if (DIR)
# check if empty
file (GLOB_RECURSE files "${DIR}/*")
# remove only if
if (NOT files)
execute_process (COMMAND
${CMAKE_COMMAND} -E remove_directory "${DIR}"
)
endif (NOT files)
endif (DIR)