diff --git a/CMakeLists.txt b/CMakeLists.txt index 34b64cb7..bd8e7da9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -456,36 +456,8 @@ configure_la (opm-core ${opm-core_TARGET} opm-core_LIBTOOL_ARCHIVE) message (STATUS "Writing libtool archive ${opm-core_LIBTOOL_ARCHIVE}") ### clean in-source builds ### -set (DISTCLEAN_FILES - CMakeCache.txt - cmake_install.cmake - Makefile - config.h - ${opm-core_NAME}-config.cmake - ${opm-core_NAME}-config-version.cmake - ${opm-core_NAME}-install.cmake - ${opm-core_NAME}.pc - ${opm-core_NAME}-install.pc - Doxyfile - CTestTestfile.cmake - DartConfiguration.tcl - GNUmakefile - lib/${opm-core_LIBTOOL_ARCHIVE} - ${opm-core_DEBUG} - install_manifest.txt - ${opm-core_STYLESHEET_COPIED} - ) -add_custom_target (distclean - COMMAND ${CMAKE_COMMAND} -E remove -f ${DISTCLEAN_FILES} - COMMAND ${CMAKE_COMMAND} -E remove_directory CMakeFiles/ - COMMAND ${CMAKE_COMMAND} -E remove_directory Testing/ -# cannot depend on clean because it is only defined in the master Makefile -# not in CMakeFiles/Makefile where this target will end up -# DEPENDS clean - WORKING_DIRECTORY ${PROJECT_BINARY_DIR} - COMMENT Removing CMake-generated files - VERBATIM - ) +include (OpmDistClean) +opm_dist_clean (opm-core) # smart wrapper that auto-parallelizes builds file (COPY diff --git a/cmake/Modules/OpmDistClean.cmake b/cmake/Modules/OpmDistClean.cmake new file mode 100644 index 00000000..b569aa5d --- /dev/null +++ b/cmake/Modules/OpmDistClean.cmake @@ -0,0 +1,46 @@ +# - Cleanup configuration files +# +# Remove files generated by the configuration (not by the build); the +# purpose is to get back a clean directory with no build artifacts +# (some empty directories may be left behind, though) +# +# The following suffices are supported: +# _NAME Name of the project +# _STYLESHEET_COPIED Stylesheet that was copied for the documentation +# _LIBTOOL_ARCHIVE Libtool archive file generated for library +# _DEBUG Debug information extracted from library + +macro (opm_dist_clean opm) + + set (DISTCLEAN_FILES + CMakeCache.txt + cmake_install.cmake + Makefile + config.h + ${${opm}_NAME}-config.cmake + ${${opm}_NAME}-config-version.cmake + ${${opm}_NAME}-install.cmake + ${${opm}_NAME}.pc + ${${opm}_NAME}-install.pc + Doxyfile + CTestTestfile.cmake + DartConfiguration.tcl + GNUmakefile + lib/${${opm}_LIBTOOL_ARCHIVE} + ${${opm}_DEBUG} + install_manifest.txt + ${${opm}_STYLESHEET_COPIED} + ) + add_custom_target (distclean + COMMAND ${CMAKE_COMMAND} -E remove -f ${DISTCLEAN_FILES} + COMMAND ${CMAKE_COMMAND} -E remove_directory CMakeFiles/ + COMMAND ${CMAKE_COMMAND} -E remove_directory Testing/ +# cannot depend on clean because it is only defined in the master Makefile +# not in CMakeFiles/Makefile where this target will end up +# DEPENDS clean + WORKING_DIRECTORY ${PROJECT_BINARY_DIR} + COMMENT Removing CMake-generated files + VERBATIM + ) + +endmacro (opm_dist_clean opm)