File: OpmDistClean.cmake

package info (click to toggle)
opm-common 2022.10%2Bds-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 78,468 kB
  • sloc: cpp: 164,554; python: 2,872; sh: 216; xml: 174; ansic: 149; pascal: 136; makefile: 12
file content (89 lines) | stat: -rw-r--r-- 2,821 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# - 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)
  # which generator have we been using
  string (TOUPPER "${CMAKE_GENERATOR}" _gen)
  if (_gen MATCHES "UNIX MAKEFILES")
	set (_gen_is_makefiles TRUE)
	set (_gen_is_ninja FALSE)
  elseif (_gen MATCHES "NINJA")
	set (_gen_is_makefiles FALSE)
	set (_gen_is_ninja TRUE)
  else ()
	set (_gen_is_makefiles FALSE)
	set (_gen_is_ninja FALSE)
  endif ()

  set (DISTCLEAN_FILES
	CMakeCache.txt
	cmake_install.cmake
	config.h
	config.h.tmp
	${${opm}_NAME}-config.cmake
	${${opm}_NAME}-config-version.cmake
	${${opm}_NAME}-install.cmake
	${${opm}_NAME}.pc
	${${opm}_NAME}-install.pc
	${doxy_dir}/Doxyfile
	${doxy_dir}/Doxyfile.in
	CTestTestfile.cmake
	DartConfiguration.tcl
	lib/${${opm}_LIBTOOL_ARCHIVE}
	${${opm}_DEBUG}
	${tests_DEBUG}
	${examples_DEBUG}
	${tutorial_DEBUG}
	install_manifest.txt
	${${opm}_STYLESHEET_COPIED}
	${tests_INPUT_FILES}
	project-version.h
	project-version.tmp
	)
  if (_gen_is_makefiles)
	list (APPEND DISTCLEAN_FILES
	  Makefile)
  endif ()
  if (_gen_is_ninja)
	list (APPEND DISTCLEAN_FILES
	  build.ninja
	  rules.ninja
	  )
  endif ()

  # only remove these files if they were actually copied
  if (NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
	list (APPEND DISTCLEAN_FILES
	  dune.module
	  dunemod.tmp
	  )
  endif (NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
  # script to remove empty directories (can't believe this isn't included!)
  set (rmdir "${OPM_MACROS_ROOT}/cmake/Scripts/RemoveEmptyDir.cmake")
  add_custom_target (distclean
	COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR} -- clean
	COMMAND ${CMAKE_COMMAND} -E remove -f ${DISTCLEAN_FILES}
	COMMAND ${CMAKE_COMMAND} -E remove_directory CMakeFiles/
	COMMAND ${CMAKE_COMMAND} -E remove_directory Testing/
	COMMAND ${CMAKE_COMMAND} -DDIR=${CMAKE_LIBRARY_OUTPUT_DIRECTORY} -P ${rmdir}
	COMMAND ${CMAKE_COMMAND} -DDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} -P ${rmdir}
	COMMAND ${CMAKE_COMMAND} -DDIR:LOCATION=${doxy_dir} -P ${rmdir}
	COMMAND ${CMAKE_COMMAND} -DDIR:LOCATION=${tests_DIR} -P ${rmdir}
# 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)