summaryrefslogtreecommitdiff
path: root/legacy/eobj/cmake
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2012-04-05 15:31:15 +0000
committerTom Hacohen <tom@stosb.com>2012-04-05 15:31:15 +0000
commit4f3f37059c7ec45c7154a4d7f89f9d133c49cc94 (patch)
treebe48af36650e4ce576b81e6e9df4d4d04cd6e30d /legacy/eobj/cmake
parent8b6d230f5bfed840e2d12195d1f96c602c76da0d (diff)
Eobj: Initial commit.
SVN revision: 69932
Diffstat (limited to 'legacy/eobj/cmake')
-rw-r--r--legacy/eobj/cmake/Modules/EFLCheck.cmake12
-rw-r--r--legacy/eobj/cmake/Modules/EFLlcov.cmake31
-rw-r--r--legacy/eobj/cmake/Modules/FindCheck.cmake28
-rw-r--r--legacy/eobj/cmake/Modules/FindEcore.cmake59
-rw-r--r--legacy/eobj/cmake/Modules/FindEdje.cmake28
-rw-r--r--legacy/eobj/cmake/Modules/FindEet.cmake28
-rw-r--r--legacy/eobj/cmake/Modules/FindEfreet.cmake28
-rw-r--r--legacy/eobj/cmake/Modules/FindEina.cmake28
-rw-r--r--legacy/eobj/cmake/Modules/FindElementary.cmake28
-rw-r--r--legacy/eobj/cmake/Modules/FindEvas.cmake28
-rw-r--r--legacy/eobj/cmake/Modules/MakeDistcheck.cmake122
11 files changed, 420 insertions, 0 deletions
diff --git a/legacy/eobj/cmake/Modules/EFLCheck.cmake b/legacy/eobj/cmake/Modules/EFLCheck.cmake
new file mode 100644
index 0000000000..f72932533b
--- /dev/null
+++ b/legacy/eobj/cmake/Modules/EFLCheck.cmake
@@ -0,0 +1,12 @@
1include(CTest)
2ENABLE_TESTING()
3add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure)
4
5find_package(Check)
6set (CHECK_ENABLED ${CHECK_FOUND})
7
8set(EFL_COVERAGE false CACHE BOOL "Whether coverage support should be built.'")
9if (EFL_COVERAGE)
10 include(EFLlcov REQUIRED)
11 ENABLE_COVERAGE()
12endif (EFL_COVERAGE)
diff --git a/legacy/eobj/cmake/Modules/EFLlcov.cmake b/legacy/eobj/cmake/Modules/EFLlcov.cmake
new file mode 100644
index 0000000000..e151df99e8
--- /dev/null
+++ b/legacy/eobj/cmake/Modules/EFLlcov.cmake
@@ -0,0 +1,31 @@
1macro(ENABLE_COVERAGE)
2 if (CHECK_ENABLED)
3 find_program(LCOV_BINARY lcov HINTS ${EFL_LCOV_PATH})
4 find_program(GENHTML_BINARY genhtml HINTS ${EFL_LCOV_PATH})
5 set(EFL_COVERAGE_CFLAGS "-fprofile-arcs -ftest-coverage")
6 set(EFL_COVERAGE_LIBS "gcov")
7 endif (CHECK_ENABLED)
8
9 if (DEFINED LCOV_BINARY)
10 set(EFL_COVERAGE_ENABLED true)
11 add_custom_target(lcov-reset
12 COMMAND rm -rf ${CMAKE_BINARY_DIR}/coverage
13 COMMAND find ${CMAKE_BINARY_DIR} -name "*.gcda" -delete
14 COMMAND ${LCOV_BINARY} --zerocounters --directory ${CMAKE_BINARY_DIR}
15 )
16
17 add_custom_target(lcov-report
18 COMMAND mkdir ${CMAKE_BINARY_DIR}/coverage
19 COMMAND ${LCOV_BINARY} --capture --compat-libtool --output-file ${CMAKE_BINARY_DIR}/coverage/coverage.info --directory ${CMAKE_BINARY_DIR}
20 COMMAND ${LCOV_BINARY} --remove ${CMAKE_BINARY_DIR}/coverage/coverage.info '*.h' --output-file ${CMAKE_BINARY_DIR}/coverage/coverage.cleaned.info
21 COMMAND ${GENHTML_BINARY} -t "${PACKAGE}" -o "${CMAKE_BINARY_DIR}/coverage/html" "${CMAKE_BINARY_DIR}/coverage/coverage.cleaned.info"
22 COMMAND echo "Coverage Report at ${CMAKE_BINARY_DIR}/coverage/html"
23 )
24
25 add_custom_target(coverage
26 COMMAND ${CMAKE_MAKE_PROGRAM} lcov-reset
27 COMMAND ${CMAKE_MAKE_PROGRAM} check
28 COMMAND ${CMAKE_MAKE_PROGRAM} lcov-report
29 )
30 endif (DEFINED LCOV_BINARY)
31endmacro(ENABLE_COVERAGE)
diff --git a/legacy/eobj/cmake/Modules/FindCheck.cmake b/legacy/eobj/cmake/Modules/FindCheck.cmake
new file mode 100644
index 0000000000..795b61554f
--- /dev/null
+++ b/legacy/eobj/cmake/Modules/FindCheck.cmake
@@ -0,0 +1,28 @@
1# - Try to find check
2# Once done this will define
3# CHECK_FOUND - System has check
4# CHECK_INCLUDE_DIRS - The check include directories
5# CHECK_LIBRARIES - The libraries needed to use check
6# CHECK_DEFINITIONS - Compiler switches required for using check
7
8find_package(PkgConfig)
9pkg_check_modules(PC_LIBCHECK QUIET check)
10set(CHECK_DEFINITIONS ${PC_LIBCHECK_CFLAGS_OTHER})
11
12find_path(CHECK_INCLUDE_DIR check.h
13 HINTS ${PC_LIBCHECK_INCLUDEDIR} ${PC_LIBCHECK_INCLUDE_DIRS}
14 PATH_SUFFIXES check )
15
16find_library(CHECK_LIBRARY NAMES check
17 HINTS ${PC_LIBCHECK_LIBDIR} ${PC_LIBCHECK_LIBRARY_DIRS} )
18
19set(CHECK_LIBRARIES ${CHECK_LIBRARY} )
20set(CHECK_INCLUDE_DIRS ${CHECK_INCLUDE_DIR} )
21
22include(FindPackageHandleStandardArgs)
23# handle the QUIETLY and REQUIRED arguments and set CHECK_FOUND to TRUE
24# if all listed variables are TRUE
25find_package_handle_standard_args(check DEFAULT_MSG
26 CHECK_LIBRARY CHECK_INCLUDE_DIR)
27
28mark_as_advanced(CHECK_INCLUDE_DIR CHECK_LIBRARY )
diff --git a/legacy/eobj/cmake/Modules/FindEcore.cmake b/legacy/eobj/cmake/Modules/FindEcore.cmake
new file mode 100644
index 0000000000..97783472b3
--- /dev/null
+++ b/legacy/eobj/cmake/Modules/FindEcore.cmake
@@ -0,0 +1,59 @@
1# - Try to find ecore
2# Once done this will define
3# ECORE_FOUND - System has ecore
4# ECORE_INCLUDE_DIRS - The ecore include directories
5# ECORE_LIBRARIES - The libraries needed to use ecore
6# ECORE_DEFINITIONS - Compiler switches required for using ecore
7
8# Use FIND_PACKAGE( Ecore COMPONENTS ... ) to enable modules
9IF( Ecore_FIND_COMPONENTS )
10 FOREACH( component ${Ecore_FIND_COMPONENTS} )
11 STRING( TOUPPER ${component} _COMPONENT )
12 SET( ECORE_USE_${_COMPONENT} 1 )
13 ENDFOREACH( component )
14ENDIF( Ecore_FIND_COMPONENTS )
15
16find_package(PkgConfig)
17pkg_check_modules(PC_LIBECORE QUIET ecore)
18set(ECORE_DEFINITIONS ${PC_LIBECORE_CFLAGS_OTHER})
19
20find_path(ECORE_INCLUDE_DIR Ecore.h
21 HINTS ${PC_LIBECORE_INCLUDEDIR} ${PC_LIBECORE_INCLUDE_DIRS}
22 PATH_SUFFIXES ecore )
23
24find_library(ECORE_LIBRARY NAMES ecore
25 HINTS ${PC_LIBECORE_LIBDIR} ${PC_LIBECORE_LIBRARY_DIRS} )
26
27set(ECORE_LIBRARIES ${ECORE_LIBRARY} )
28set(ECORE_INCLUDE_DIRS ${ECORE_INCLUDE_DIR} )
29
30include(FindPackageHandleStandardArgs)
31# handle the QUIETLY and REQUIRED arguments and set ECORE_FOUND to TRUE
32# if all listed variables are TRUE
33find_package_handle_standard_args(ecore DEFAULT_MSG
34 ECORE_LIBRARY ECORE_INCLUDE_DIR)
35
36mark_as_advanced( ECORE_INCLUDE_DIR ECORE_LIBRARY )
37
38if (ECORE_USE_ECORE-X)
39 pkg_check_modules(PC_LIBECORE_X QUIET ecore-x)
40 set(ECORE_X_DEFINITIONS ${PC_LIBECORE_X_CFLAGS_OTHER})
41
42 find_path(ECORE_X_INCLUDE_DIR Ecore_X.h
43 HINTS ${PC_LIBECORE_X_INCLUDEDIR} ${PC_LIBECORE_X_INCLUDE_DIRS}
44 PATH_SUFFIXES ecore )
45
46 find_library(ECORE_X_LIBRARY NAMES ecore_x
47 HINTS ${PC_LIBECORE_X_LIBDIR} ${PC_LIBECORE_X_LIBRARY_DIRS} )
48
49 set(ECORE_X_LIBRARIES ${ECORE_X_LIBRARY} )
50 set(ECORE_X_INCLUDE_DIRS ${ECORE_X_INCLUDE_DIR} )
51
52 include(FindPackageHandleStandardArgs)
53# handle the QUIETLY and REQUIRED arguments and set ECORE_X_FOUND to TRUE
54# if all listed variables are TRUE
55 find_package_handle_standard_args(ecore_x DEFAULT_MSG
56 ECORE_X_LIBRARY ECORE_X_INCLUDE_DIR)
57
58 mark_as_advanced( ECORE_X_INCLUDE_DIR ECORE_X_LIBRARY )
59endif (ECORE_USE_ECORE-X)
diff --git a/legacy/eobj/cmake/Modules/FindEdje.cmake b/legacy/eobj/cmake/Modules/FindEdje.cmake
new file mode 100644
index 0000000000..927b31d5f1
--- /dev/null
+++ b/legacy/eobj/cmake/Modules/FindEdje.cmake
@@ -0,0 +1,28 @@
1# - Try to find edje
2# Once done this will define
3# EDJE_FOUND - System has edje
4# EDJE_INCLUDE_DIRS - The edje include directories
5# EDJE_LIBRARIES - The libraries needed to use edje
6# EDJE_DEFINITIONS - Compiler switches required for using edje
7
8find_package(PkgConfig)
9pkg_check_modules(PC_LIBEDJE QUIET edje)
10set(EDJE_DEFINITIONS ${PC_LIBEDJE_CFLAGS_OTHER})
11
12find_path(EDJE_INCLUDE_DIR Edje.h
13 HINTS ${PC_LIBEDJE_INCLUDEDIR} ${PC_LIBEDJE_INCLUDE_DIRS}
14 PATH_SUFFIXES edje )
15
16find_library(EDJE_LIBRARY NAMES edje
17 HINTS ${PC_LIBEDJE_LIBDIR} ${PC_LIBEDJE_LIBRARY_DIRS} )
18
19set(EDJE_LIBRARIES ${EDJE_LIBRARY} )
20set(EDJE_INCLUDE_DIRS ${EDJE_INCLUDE_DIR} )
21
22include(FindPackageHandleStandardArgs)
23# handle the QUIETLY and REQUIRED arguments and set EDJE_FOUND to TRUE
24# if all listed variables are TRUE
25find_package_handle_standard_args(edje DEFAULT_MSG
26 EDJE_LIBRARY EDJE_INCLUDE_DIR)
27
28mark_as_advanced(EDJE_INCLUDE_DIR EDJE_LIBRARY )
diff --git a/legacy/eobj/cmake/Modules/FindEet.cmake b/legacy/eobj/cmake/Modules/FindEet.cmake
new file mode 100644
index 0000000000..ae215d330c
--- /dev/null
+++ b/legacy/eobj/cmake/Modules/FindEet.cmake
@@ -0,0 +1,28 @@
1# - Try to find eet
2# Once done this will define
3# EET_FOUND - System has eet
4# EET_INCLUDE_DIRS - The eet include directories
5# EET_LIBRARIES - The libraries needed to use eet
6# EET_DEFINITIONS - Compiler switches required for using eet
7
8find_package(PkgConfig)
9pkg_check_modules(PC_LIBEET QUIET eet)
10set(EET_DEFINITIONS ${PC_LIBEET_CFLAGS_OTHER})
11
12find_path(EET_INCLUDE_DIR Eet.h
13 HINTS ${PC_LIBEET_INCLUDEDIR} ${PC_LIBEET_INCLUDE_DIRS}
14 PATH_SUFFIXES eet )
15
16find_library(EET_LIBRARY NAMES eet
17 HINTS ${PC_LIBEET_LIBDIR} ${PC_LIBEET_LIBRARY_DIRS} )
18
19set(EET_LIBRARIES ${EET_LIBRARY} )
20set(EET_INCLUDE_DIRS ${EET_INCLUDE_DIR} )
21
22include(FindPackageHandleStandardArgs)
23# handle the QUIETLY and REQUIRED arguments and set EET_FOUND to TRUE
24# if all listed variables are TRUE
25find_package_handle_standard_args(eet DEFAULT_MSG
26 EET_LIBRARY EET_INCLUDE_DIR)
27
28mark_as_advanced( EET_INCLUDE_DIR EET_LIBRARY )
diff --git a/legacy/eobj/cmake/Modules/FindEfreet.cmake b/legacy/eobj/cmake/Modules/FindEfreet.cmake
new file mode 100644
index 0000000000..d245206f11
--- /dev/null
+++ b/legacy/eobj/cmake/Modules/FindEfreet.cmake
@@ -0,0 +1,28 @@
1# - Try to find efreet
2# Once done this will define
3# EFREET_FOUND - System has efreet
4# EFREET_INCLUDE_DIRS - The efreet include directories
5# EFREET_LIBRARIES - The libraries needed to use efreet
6# EFREET_DEFINITIONS - Compiler switches required for using efreet
7
8find_package(PkgConfig)
9pkg_check_modules(PC_LIBEFREET QUIET efreet)
10set(EFREET_DEFINITIONS ${PC_LIBEFREET_CFLAGS_OTHER})
11
12find_path(EFREET_INCLUDE_DIR Efreet.h
13 HINTS ${PC_LIBEFREET_INCLUDEDIR} ${PC_LIBEFREET_INCLUDE_DIRS}
14 PATH_SUFFIXES efreet )
15
16find_library(EFREET_LIBRARY NAMES efreet
17 HINTS ${PC_LIBEFREET_LIBDIR} ${PC_LIBEFREET_LIBRARY_DIRS} )
18
19set(EFREET_LIBRARIES ${EFREET_LIBRARY} )
20set(EFREET_INCLUDE_DIRS ${EFREET_INCLUDE_DIR} )
21
22include(FindPackageHandleStandardArgs)
23# handle the QUIETLY and REQUIRED arguments and set EFREET_FOUND to TRUE
24# if all listed variables are TRUE
25find_package_handle_standard_args(efreet DEFAULT_MSG
26 EFREET_LIBRARY EFREET_INCLUDE_DIR)
27
28mark_as_advanced(EFREET_INCLUDE_DIR EFREET_LIBRARY )
diff --git a/legacy/eobj/cmake/Modules/FindEina.cmake b/legacy/eobj/cmake/Modules/FindEina.cmake
new file mode 100644
index 0000000000..acbd799f3e
--- /dev/null
+++ b/legacy/eobj/cmake/Modules/FindEina.cmake
@@ -0,0 +1,28 @@
1# - Try to find eina
2# Once done this will define
3# EINA_FOUND - System has eina
4# EINA_INCLUDE_DIRS - The eina include directories
5# EINA_LIBRARIES - The libraries needed to use eina
6# EINA_DEFINITIONS - Compiler switches required for using eina
7
8find_package(PkgConfig)
9pkg_check_modules(PC_LIBEINA QUIET eina)
10set(EINA_DEFINITIONS ${PC_LIBEINA_CFLAGS_OTHER})
11
12find_path(EINA_INCLUDE_DIR Eina.h
13 HINTS ${PC_LIBEINA_INCLUDEDIR} ${PC_LIBEINA_INCLUDE_DIRS}
14 PATH_SUFFIXES eina )
15
16find_library(EINA_LIBRARY NAMES eina
17 HINTS ${PC_LIBEINA_LIBDIR} ${PC_LIBEINA_LIBRARY_DIRS} )
18
19set(EINA_LIBRARIES ${EINA_LIBRARY} )
20set(EINA_INCLUDE_DIRS ${EINA_INCLUDE_DIR} "${EINA_INCLUDE_DIR}/eina" )
21
22include(FindPackageHandleStandardArgs)
23# handle the QUIETLY and REQUIRED arguments and set EINA_FOUND to TRUE
24# if all listed variables are TRUE
25find_package_handle_standard_args(eina DEFAULT_MSG
26 EINA_LIBRARY EINA_INCLUDE_DIR)
27
28mark_as_advanced(EINA_INCLUDE_DIR EINA_LIBRARY )
diff --git a/legacy/eobj/cmake/Modules/FindElementary.cmake b/legacy/eobj/cmake/Modules/FindElementary.cmake
new file mode 100644
index 0000000000..5b75bfcedd
--- /dev/null
+++ b/legacy/eobj/cmake/Modules/FindElementary.cmake
@@ -0,0 +1,28 @@
1# - Try to find elementary
2# Once done this will define
3# ELEMENTARY_FOUND - System has elementary
4# ELEMENTARY_INCLUDE_DIRS - The elementary include directories
5# ELEMENTARY_LIBRARIES - The libraries needed to use elementary
6# ELEMENTARY_DEFINITIONS - Compiler switches required for using elementary
7
8find_package(PkgConfig)
9pkg_check_modules(PC_LIBELEMENTARY QUIET elementary)
10set(ELEMENTARY_DEFINITIONS ${PC_LIBELEMENTARY_CFLAGS_OTHER})
11
12find_path(ELEMENTARY_INCLUDE_DIR Elementary.h
13 HINTS ${PC_LIBELEMENTARY_INCLUDEDIR} ${PC_LIBELEMENTARY_INCLUDE_DIRS}
14 PATH_SUFFIXES elementary )
15
16find_library(ELEMENTARY_LIBRARY NAMES elementary
17 HINTS ${PC_LIBELEMENTARY_LIBDIR} ${PC_LIBELEMENTARY_LIBRARY_DIRS} )
18
19set(ELEMENTARY_LIBRARIES ${ELEMENTARY_LIBRARY} )
20set(ELEMENTARY_INCLUDE_DIRS ${PC_LIBELEMENTARY_INCLUDEDIR} ${PC_LIBELEMENTARY_INCLUDE_DIRS} )
21
22include(FindPackageHandleStandardArgs)
23# handle the QUIETLY and REQUIRED arguments and set ELEMENTARY_FOUND to TRUE
24# if all listed variables are TRUE
25find_package_handle_standard_args(elementary DEFAULT_MSG
26 ELEMENTARY_LIBRARY ELEMENTARY_INCLUDE_DIR)
27
28mark_as_advanced(ELEMENTARY_INCLUDE_DIR ELEMENTARY_LIBRARY )
diff --git a/legacy/eobj/cmake/Modules/FindEvas.cmake b/legacy/eobj/cmake/Modules/FindEvas.cmake
new file mode 100644
index 0000000000..fe980d3541
--- /dev/null
+++ b/legacy/eobj/cmake/Modules/FindEvas.cmake
@@ -0,0 +1,28 @@
1# - Try to find evas
2# Once done this will define
3# EVAS_FOUND - System has evas
4# EVAS_INCLUDE_DIRS - The evas include directories
5# EVAS_LIBRARIES - The libraries needed to use evas
6# EVAS_DEFINITIONS - Compiler switches required for using evas
7
8find_package(PkgConfig)
9pkg_check_modules(PC_LIBEVAS QUIET evas)
10set(EVAS_DEFINITIONS ${PC_LIBEVAS_CFLAGS_OTHER})
11
12find_path(EVAS_INCLUDE_DIR Evas.h
13 HINTS ${PC_LIBEVAS_INCLUDEDIR} ${PC_LIBEVAS_INCLUDE_DIRS}
14 PATH_SUFFIXES evas )
15
16find_library(EVAS_LIBRARY NAMES evas
17 HINTS ${PC_LIBEVAS_LIBDIR} ${PC_LIBEVAS_LIBRARY_DIRS} )
18
19set(EVAS_LIBRARIES ${EVAS_LIBRARY} )
20set(EVAS_INCLUDE_DIRS ${EVAS_INCLUDE_DIR} )
21
22include(FindPackageHandleStandardArgs)
23# handle the QUIETLY and REQUIRED arguments and set EVAS_FOUND to TRUE
24# if all listed variables are TRUE
25find_package_handle_standard_args(evas DEFAULT_MSG
26 EVAS_LIBRARY EVAS_INCLUDE_DIR)
27
28mark_as_advanced(EVAS_INCLUDE_DIR EVAS_LIBRARY )
diff --git a/legacy/eobj/cmake/Modules/MakeDistcheck.cmake b/legacy/eobj/cmake/Modules/MakeDistcheck.cmake
new file mode 100644
index 0000000000..1f383a5994
--- /dev/null
+++ b/legacy/eobj/cmake/Modules/MakeDistcheck.cmake
@@ -0,0 +1,122 @@
1# - adds support for the 'make distcheck' command -*- cmake -*-
2# Dependencies:
3# 1. CPack generating ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz.
4# 2. Having a "dist" target, e.g:
5# add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
6# Usage:
7# add_distcheck() ... called exactly once per project in the top-level
8# CMakeLists.txt; it adds the 'dist' and 'distcheck'
9# targets
10#
11# This module implements the 'make dist' and 'make distcheck'
12# commands.
13# It supports the following variables:
14#
15# DISTCHECK_TMPDIR ... directory for temporary files
16# DISTCHECK_FILENAME ... basename of existing tar.gz.; defaults to
17# ${CPACK_SOURCE_PACKAGE_FILE_NAME}
18# DISTCHECK_CMAKEFLAGS
19# ... flags which are given to 'cmake' by 'make distcheck'
20# DISTCHECK_BUILDTARGETS
21# ... the build-targets tried by 'make distcheck';
22# defaults to nothing (--> all)
23# DISTCHECK_INSTALLTARGETS
24# ... the install-targets tried by 'make distcheck';
25# defaults to 'install'
26#
27# Example:
28# --- top-level CMakeLists.txt ---
29# add_subdirectory(foo)
30# ...
31# ...
32# set(CPACK_PACKAGE_VERSION_MAJOR ${ECRIRE_VERSION_MAJOR})
33# set(CPACK_PACKAGE_VERSION_MINOR ${ECRIRE_VERSION_MINOR})
34# set(CPACK_PACKAGE_VERSION_PATCH ${ECRIRE_VERSION_MICRO})
35# set(CPACK_SOURCE_GENERATOR "TGZ")
36# set(CPACK_SOURCE_IGNORE_FILES
37# "${CMAKE_BINARY_DIR};/.git/;~$;${CPACK_SOURCE_IGNORE_FILES}")
38# include(CPack)
39# add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
40#
41# find_package(Distcheck)
42# add_distcheck()
43#
44#
45# Copyright (C) 2012 Tom Hacohen <tom@stosb.com>
46# Based on the work done by:
47# Copyright (C) 2006 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
48#
49# Redistribution and use, with or without modification, are permitted
50# provided that the following conditions are met:
51#
52# 1. Redistributions must retain the above copyright notice, this
53# list of conditions and the following disclaimer.
54# 2. The name of the author may not be used to endorse or promote
55# products derived from this software without specific prior
56# written permission.
57#
58# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
59# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
60# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
61# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
62# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
63# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
64# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
65# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
66# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
67# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
68# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
69
70macro(add_distcheck)
71 set(MakeDist_FOUND 1)
72
73 set(DISTCHECK_TMPDIR "${CMAKE_BINARY_DIR}/.make-dist" CACHE PATH "directory for temporary files created by'make dist*'")
74 set(DISTCHECK_FILENAME ${CPACK_SOURCE_PACKAGE_FILE_NAME} CACHE PATH "basename of the tarball created by 'make dist'")
75 set(DISTCHECK_CMAKEFLAGS CACHE STRING "flags which are given to 'cmake' by 'make distcheck'")
76 set(DISTCHECK_BUILDTARGETS "" CACHE STRING "build-target(s) tried by 'make distcheck'")
77 set(DISTCHECK_INSTALLTARGETS install CACHE STRING "install-target(s) tried by 'make distcheck'")
78
79 mark_as_advanced(DISTCHECK_TMPDIR DISTCHECK_FILENAME DISTCHECK_CMAKEFLAGS DISTCHECK_BUILDTARGETS DISTCHECK_INSTALLTARGETS)
80
81 set(DISTCHECK_BASESOURCEDIR "${DISTCHECK_TMPDIR}/source")
82 set(DISTCHECK_SOURCEDIR "${DISTCHECK_BASESOURCEDIR}/${DISTCHECK_FILENAME}")
83 set(DISTCHECK_BUILDDIR "${DISTCHECK_TMPDIR}/build")
84 set(DISTCHECK_INSTALLTARGETS "install")
85 add_custom_target(distcheck
86 # Create the tarball
87 COMMAND ${CMAKE_MAKE_PROGRAM} dist
88
89 # Create the temp dir.
90 COMMAND chmod -Rf a+w "${DISTCHECK_TMPDIR}" 2>/dev/null || :
91 COMMAND rm -rf "${DISTCHECK_TMPDIR}"
92 COMMAND mkdir -p "${DISTCHECK_SOURCEDIR}" "${DISTCHECK_BUILDDIR}"
93
94 # extract tarball
95 COMMAND tar xzf ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz -C "${DISTCHECK_BASESOURCEDIR}"
96 # write-protect sources to detect modifies-sourcetree bugs
97 COMMAND chmod -R a-w "${DISTCHECK_SOURCEDIR}"
98
99 COMMAND cd "${DISTCHECK_BUILDDIR}" && ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX:PATH="${DISTCHECK_TMPDIR}/install" ${DISTCHECK_CMAKEFLAGS} "${DISTCHECK_SOURCEDIR}"
100
101 COMMAND cd "${DISTCHECK_BUILDDIR}" && ${CMAKE_MAKE_PROGRAM} ${DISTCHECK_BUILDTARGETS}
102
103 # execute 'make install' without DESTDIR
104 COMMAND cd "${DISTCHECK_BUILDDIR}" && ${CMAKE_MAKE_PROGRAM} ${DISTCHECK_INSTALLTARGETS} DESTDIR=
105 # write protect installation path to detect writing outside of DESTDIR
106 COMMAND chmod -R a-w "${DISTCHECK_TMPDIR}/install"
107 # execute 'make install' with DESTDIR and move the files to a better location
108 COMMAND cd "${DISTCHECK_BUILDDIR}" && ${CMAKE_MAKE_PROGRAM} ${DISTCHECK_INSTALLTARGETS} DESTDIR="${DISTCHECK_TMPDIR}/install-tmp"
109 COMMAND mv "${DISTCHECK_TMPDIR}/install-tmp/${DISTCHECK_TMPDIR}/install" "${DISTCHECK_TMPDIR}/install-destdir"
110
111 # generate list of files which were installed by the both 'make
112 # install' commands above and compare them
113 COMMAND cd "${DISTCHECK_TMPDIR}/install" && find -type f | sort > ../files.install
114 COMMAND cd "${DISTCHECK_TMPDIR}/install-destdir" && find -type f | sort > ../files.destdir
115 COMMAND cd "${DISTCHECK_TMPDIR}" && diff files.install files.destdir
116
117 # cleanup tmpdir
118 COMMAND chmod -R u+Xw "${DISTCHECK_TMPDIR}" 2>/dev/null || :
119 COMMAND rm -rf "${DISTCHECK_TMPDIR}"
120 )
121endmacro(add_distcheck)
122