File: FindMakeDistCheck.cmake

package info (click to toggle)
geos 3.14.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 31,212 kB
  • sloc: cpp: 199,103; xml: 56,065; ansic: 6,162; sh: 287; makefile: 26
file content (61 lines) | stat: -rw-r--r-- 2,428 bytes parent folder | download | duplicates (4)
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
# Inspired by CMake Distcheck for LAAS-CNRS
#
# DEFINE_DISTCHECK
# ---------------
#
# Add a distcheck target to check the generated tarball.
#
# This step calls `make dist' to generate a copy of the sources as it
# stands in the current git HEAD i.e., unversioned files are skipped.
#
# Then:
# - create _build and _inst to respectively create a build
#   and an installation directory.
# - run cmake with _inst as the installation prefix
# - run make, make check, make install and make uninstall
# - remove _build and _inst.
# - remove dist directory and confirm success.
#
# During the compilation phase, all files in the source tree are modified
# to *not* be writeable to detect bad compilation steps which tries to modify
# the source tree. Permissions are reverted at the end of the check.
#
macro(AddMakeDistCheck)
  find_program(_tar tar)
  find_program(_bzip2 bzip2)
  string(TOLOWER "${CPACK_SOURCE_PACKAGE_FILE_NAME}" _distbasename)
  set(_distname "${_distbasename}.tar.bz2")
  set(_builddir "${CMAKE_BINARY_DIR}/${_distbasename}/_build")
  set(_instdir  "${CMAKE_BINARY_DIR}/${_distbasename}/_inst")
  # message(STATUS "GEOS: _distbasename: ${_distbasename}")
  # message(STATUS "GEOS: _distname: ${_distname}")
  # message(STATUS "GEOS: _builddir: ${_builddir}")
  # message(STATUS "GEOS: _instdir: ${_instdir}")

  add_custom_target(distcheck
    COMMAND rm -rf "${_distbasename}"
      && \(${_bzip2} -d -c "${_distname}" | ${_tar} xf -\)
      && mkdir -vp "${_builddir}"
      && mkdir -vp "${_instdir}"
      && cd "${_builddir}"
      && ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX:PATH="${_instdir}" ..
        || \(echo "ERROR: the cmake configuration failed." && false\)
      && make
        || \(echo "ERROR: the compilation failed." && false\)
      && make test
        || \(echo "ERROR: the test suite failed." && false\)
      && make install
        || \(echo "ERROR: the install target failed." && false\)
      && make uninstall
        || \(echo "ERROR: the uninstall target failed." && false\)
      && make clean
        || \(echo "ERROR: the clean target failed." && false\)
      && cd ../..
      && rm -rf "${_distbasename}"
      && echo "=============================================================="
      && echo "${_distname} is ready for distribution."
      && echo "=============================================================="
    )

  add_dependencies(distcheck dist)
endmacro()