diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2012-04-16 09:40:15 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2012-04-16 09:40:15 +0200 |
commit | 6f682d7d94a30433531137476cd4aaa4dd200f3b (patch) | |
tree | 673f943db1f1df0e583509858f2c62c78708f9a7 /ecmake/cmake/Modules | |
parent | 2224f05d43a0d782b626d09f397767597b3d7f4f (diff) | |
parent | 23929ded8ba244359e871e1d02ee1d05d060ea71 (diff) | |
download | skeletons-6f682d7d94a30433531137476cd4aaa4dd200f3b.zip skeletons-6f682d7d94a30433531137476cd4aaa4dd200f3b.tar.gz |
Merge branch 'master' of asynk.ch:templates
Diffstat (limited to 'ecmake/cmake/Modules')
-rw-r--r-- | ecmake/cmake/Modules/EFLCheck.cmake | 12 | ||||
-rw-r--r-- | ecmake/cmake/Modules/EFLlcov.cmake | 31 | ||||
-rw-r--r-- | ecmake/cmake/Modules/FindCheck.cmake | 28 | ||||
-rw-r--r-- | ecmake/cmake/Modules/FindEcore.cmake | 59 | ||||
-rw-r--r-- | ecmake/cmake/Modules/FindEdje.cmake | 28 | ||||
-rw-r--r-- | ecmake/cmake/Modules/FindEet.cmake | 28 | ||||
-rw-r--r-- | ecmake/cmake/Modules/FindEfreet.cmake | 28 | ||||
-rw-r--r-- | ecmake/cmake/Modules/FindEina.cmake | 28 | ||||
-rw-r--r-- | ecmake/cmake/Modules/FindElementary.cmake | 28 | ||||
-rw-r--r-- | ecmake/cmake/Modules/FindEvas.cmake | 28 | ||||
-rw-r--r-- | ecmake/cmake/Modules/MakeDistcheck.cmake | 122 |
11 files changed, 420 insertions, 0 deletions
diff --git a/ecmake/cmake/Modules/EFLCheck.cmake b/ecmake/cmake/Modules/EFLCheck.cmake new file mode 100644 index 0000000..f729325 --- /dev/null +++ b/ecmake/cmake/Modules/EFLCheck.cmake @@ -0,0 +1,12 @@ +include(CTest) +ENABLE_TESTING() +add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure) + +find_package(Check) +set (CHECK_ENABLED ${CHECK_FOUND}) + +set(EFL_COVERAGE false CACHE BOOL "Whether coverage support should be built.'") +if (EFL_COVERAGE) + include(EFLlcov REQUIRED) + ENABLE_COVERAGE() +endif (EFL_COVERAGE) diff --git a/ecmake/cmake/Modules/EFLlcov.cmake b/ecmake/cmake/Modules/EFLlcov.cmake new file mode 100644 index 0000000..e151df9 --- /dev/null +++ b/ecmake/cmake/Modules/EFLlcov.cmake @@ -0,0 +1,31 @@ +macro(ENABLE_COVERAGE) + if (CHECK_ENABLED) + find_program(LCOV_BINARY lcov HINTS ${EFL_LCOV_PATH}) + find_program(GENHTML_BINARY genhtml HINTS ${EFL_LCOV_PATH}) + set(EFL_COVERAGE_CFLAGS "-fprofile-arcs -ftest-coverage") + set(EFL_COVERAGE_LIBS "gcov") + endif (CHECK_ENABLED) + + if (DEFINED LCOV_BINARY) + set(EFL_COVERAGE_ENABLED true) + add_custom_target(lcov-reset + COMMAND rm -rf ${CMAKE_BINARY_DIR}/coverage + COMMAND find ${CMAKE_BINARY_DIR} -name "*.gcda" -delete + COMMAND ${LCOV_BINARY} --zerocounters --directory ${CMAKE_BINARY_DIR} + ) + + add_custom_target(lcov-report + COMMAND mkdir ${CMAKE_BINARY_DIR}/coverage + COMMAND ${LCOV_BINARY} --capture --compat-libtool --output-file ${CMAKE_BINARY_DIR}/coverage/coverage.info --directory ${CMAKE_BINARY_DIR} + COMMAND ${LCOV_BINARY} --remove ${CMAKE_BINARY_DIR}/coverage/coverage.info '*.h' --output-file ${CMAKE_BINARY_DIR}/coverage/coverage.cleaned.info + COMMAND ${GENHTML_BINARY} -t "${PACKAGE}" -o "${CMAKE_BINARY_DIR}/coverage/html" "${CMAKE_BINARY_DIR}/coverage/coverage.cleaned.info" + COMMAND echo "Coverage Report at ${CMAKE_BINARY_DIR}/coverage/html" + ) + + add_custom_target(coverage + COMMAND ${CMAKE_MAKE_PROGRAM} lcov-reset + COMMAND ${CMAKE_MAKE_PROGRAM} check + COMMAND ${CMAKE_MAKE_PROGRAM} lcov-report + ) + endif (DEFINED LCOV_BINARY) +endmacro(ENABLE_COVERAGE) diff --git a/ecmake/cmake/Modules/FindCheck.cmake b/ecmake/cmake/Modules/FindCheck.cmake new file mode 100644 index 0000000..795b615 --- /dev/null +++ b/ecmake/cmake/Modules/FindCheck.cmake @@ -0,0 +1,28 @@ +# - Try to find check +# Once done this will define +# CHECK_FOUND - System has check +# CHECK_INCLUDE_DIRS - The check include directories +# CHECK_LIBRARIES - The libraries needed to use check +# CHECK_DEFINITIONS - Compiler switches required for using check + +find_package(PkgConfig) +pkg_check_modules(PC_LIBCHECK QUIET check) +set(CHECK_DEFINITIONS ${PC_LIBCHECK_CFLAGS_OTHER}) + +find_path(CHECK_INCLUDE_DIR check.h + HINTS ${PC_LIBCHECK_INCLUDEDIR} ${PC_LIBCHECK_INCLUDE_DIRS} + PATH_SUFFIXES check ) + +find_library(CHECK_LIBRARY NAMES check + HINTS ${PC_LIBCHECK_LIBDIR} ${PC_LIBCHECK_LIBRARY_DIRS} ) + +set(CHECK_LIBRARIES ${CHECK_LIBRARY} ) +set(CHECK_INCLUDE_DIRS ${CHECK_INCLUDE_DIR} ) + +include(FindPackageHandleStandardArgs) +# handle the QUIETLY and REQUIRED arguments and set CHECK_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args(check DEFAULT_MSG + CHECK_LIBRARY CHECK_INCLUDE_DIR) + +mark_as_advanced(CHECK_INCLUDE_DIR CHECK_LIBRARY ) diff --git a/ecmake/cmake/Modules/FindEcore.cmake b/ecmake/cmake/Modules/FindEcore.cmake new file mode 100644 index 0000000..9778347 --- /dev/null +++ b/ecmake/cmake/Modules/FindEcore.cmake @@ -0,0 +1,59 @@ +# - Try to find ecore +# Once done this will define +# ECORE_FOUND - System has ecore +# ECORE_INCLUDE_DIRS - The ecore include directories +# ECORE_LIBRARIES - The libraries needed to use ecore +# ECORE_DEFINITIONS - Compiler switches required for using ecore + +# Use FIND_PACKAGE( Ecore COMPONENTS ... ) to enable modules +IF( Ecore_FIND_COMPONENTS ) + FOREACH( component ${Ecore_FIND_COMPONENTS} ) + STRING( TOUPPER ${component} _COMPONENT ) + SET( ECORE_USE_${_COMPONENT} 1 ) + ENDFOREACH( component ) +ENDIF( Ecore_FIND_COMPONENTS ) + +find_package(PkgConfig) +pkg_check_modules(PC_LIBECORE QUIET ecore) +set(ECORE_DEFINITIONS ${PC_LIBECORE_CFLAGS_OTHER}) + +find_path(ECORE_INCLUDE_DIR Ecore.h + HINTS ${PC_LIBECORE_INCLUDEDIR} ${PC_LIBECORE_INCLUDE_DIRS} + PATH_SUFFIXES ecore ) + +find_library(ECORE_LIBRARY NAMES ecore + HINTS ${PC_LIBECORE_LIBDIR} ${PC_LIBECORE_LIBRARY_DIRS} ) + +set(ECORE_LIBRARIES ${ECORE_LIBRARY} ) +set(ECORE_INCLUDE_DIRS ${ECORE_INCLUDE_DIR} ) + +include(FindPackageHandleStandardArgs) +# handle the QUIETLY and REQUIRED arguments and set ECORE_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args(ecore DEFAULT_MSG + ECORE_LIBRARY ECORE_INCLUDE_DIR) + +mark_as_advanced( ECORE_INCLUDE_DIR ECORE_LIBRARY ) + +if (ECORE_USE_ECORE-X) + pkg_check_modules(PC_LIBECORE_X QUIET ecore-x) + set(ECORE_X_DEFINITIONS ${PC_LIBECORE_X_CFLAGS_OTHER}) + + find_path(ECORE_X_INCLUDE_DIR Ecore_X.h + HINTS ${PC_LIBECORE_X_INCLUDEDIR} ${PC_LIBECORE_X_INCLUDE_DIRS} + PATH_SUFFIXES ecore ) + + find_library(ECORE_X_LIBRARY NAMES ecore_x + HINTS ${PC_LIBECORE_X_LIBDIR} ${PC_LIBECORE_X_LIBRARY_DIRS} ) + + set(ECORE_X_LIBRARIES ${ECORE_X_LIBRARY} ) + set(ECORE_X_INCLUDE_DIRS ${ECORE_X_INCLUDE_DIR} ) + + include(FindPackageHandleStandardArgs) +# handle the QUIETLY and REQUIRED arguments and set ECORE_X_FOUND to TRUE +# if all listed variables are TRUE + find_package_handle_standard_args(ecore_x DEFAULT_MSG + ECORE_X_LIBRARY ECORE_X_INCLUDE_DIR) + + mark_as_advanced( ECORE_X_INCLUDE_DIR ECORE_X_LIBRARY ) +endif (ECORE_USE_ECORE-X) diff --git a/ecmake/cmake/Modules/FindEdje.cmake b/ecmake/cmake/Modules/FindEdje.cmake new file mode 100644 index 0000000..927b31d --- /dev/null +++ b/ecmake/cmake/Modules/FindEdje.cmake @@ -0,0 +1,28 @@ +# - Try to find edje +# Once done this will define +# EDJE_FOUND - System has edje +# EDJE_INCLUDE_DIRS - The edje include directories +# EDJE_LIBRARIES - The libraries needed to use edje +# EDJE_DEFINITIONS - Compiler switches required for using edje + +find_package(PkgConfig) +pkg_check_modules(PC_LIBEDJE QUIET edje) +set(EDJE_DEFINITIONS ${PC_LIBEDJE_CFLAGS_OTHER}) + +find_path(EDJE_INCLUDE_DIR Edje.h + HINTS ${PC_LIBEDJE_INCLUDEDIR} ${PC_LIBEDJE_INCLUDE_DIRS} + PATH_SUFFIXES edje ) + +find_library(EDJE_LIBRARY NAMES edje + HINTS ${PC_LIBEDJE_LIBDIR} ${PC_LIBEDJE_LIBRARY_DIRS} ) + +set(EDJE_LIBRARIES ${EDJE_LIBRARY} ) +set(EDJE_INCLUDE_DIRS ${EDJE_INCLUDE_DIR} ) + +include(FindPackageHandleStandardArgs) +# handle the QUIETLY and REQUIRED arguments and set EDJE_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args(edje DEFAULT_MSG + EDJE_LIBRARY EDJE_INCLUDE_DIR) + +mark_as_advanced(EDJE_INCLUDE_DIR EDJE_LIBRARY ) diff --git a/ecmake/cmake/Modules/FindEet.cmake b/ecmake/cmake/Modules/FindEet.cmake new file mode 100644 index 0000000..ae215d3 --- /dev/null +++ b/ecmake/cmake/Modules/FindEet.cmake @@ -0,0 +1,28 @@ +# - Try to find eet +# Once done this will define +# EET_FOUND - System has eet +# EET_INCLUDE_DIRS - The eet include directories +# EET_LIBRARIES - The libraries needed to use eet +# EET_DEFINITIONS - Compiler switches required for using eet + +find_package(PkgConfig) +pkg_check_modules(PC_LIBEET QUIET eet) +set(EET_DEFINITIONS ${PC_LIBEET_CFLAGS_OTHER}) + +find_path(EET_INCLUDE_DIR Eet.h + HINTS ${PC_LIBEET_INCLUDEDIR} ${PC_LIBEET_INCLUDE_DIRS} + PATH_SUFFIXES eet ) + +find_library(EET_LIBRARY NAMES eet + HINTS ${PC_LIBEET_LIBDIR} ${PC_LIBEET_LIBRARY_DIRS} ) + +set(EET_LIBRARIES ${EET_LIBRARY} ) +set(EET_INCLUDE_DIRS ${EET_INCLUDE_DIR} ) + +include(FindPackageHandleStandardArgs) +# handle the QUIETLY and REQUIRED arguments and set EET_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args(eet DEFAULT_MSG + EET_LIBRARY EET_INCLUDE_DIR) + +mark_as_advanced( EET_INCLUDE_DIR EET_LIBRARY ) diff --git a/ecmake/cmake/Modules/FindEfreet.cmake b/ecmake/cmake/Modules/FindEfreet.cmake new file mode 100644 index 0000000..d245206 --- /dev/null +++ b/ecmake/cmake/Modules/FindEfreet.cmake @@ -0,0 +1,28 @@ +# - Try to find efreet +# Once done this will define +# EFREET_FOUND - System has efreet +# EFREET_INCLUDE_DIRS - The efreet include directories +# EFREET_LIBRARIES - The libraries needed to use efreet +# EFREET_DEFINITIONS - Compiler switches required for using efreet + +find_package(PkgConfig) +pkg_check_modules(PC_LIBEFREET QUIET efreet) +set(EFREET_DEFINITIONS ${PC_LIBEFREET_CFLAGS_OTHER}) + +find_path(EFREET_INCLUDE_DIR Efreet.h + HINTS ${PC_LIBEFREET_INCLUDEDIR} ${PC_LIBEFREET_INCLUDE_DIRS} + PATH_SUFFIXES efreet ) + +find_library(EFREET_LIBRARY NAMES efreet + HINTS ${PC_LIBEFREET_LIBDIR} ${PC_LIBEFREET_LIBRARY_DIRS} ) + +set(EFREET_LIBRARIES ${EFREET_LIBRARY} ) +set(EFREET_INCLUDE_DIRS ${EFREET_INCLUDE_DIR} ) + +include(FindPackageHandleStandardArgs) +# handle the QUIETLY and REQUIRED arguments and set EFREET_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args(efreet DEFAULT_MSG + EFREET_LIBRARY EFREET_INCLUDE_DIR) + +mark_as_advanced(EFREET_INCLUDE_DIR EFREET_LIBRARY ) diff --git a/ecmake/cmake/Modules/FindEina.cmake b/ecmake/cmake/Modules/FindEina.cmake new file mode 100644 index 0000000..acbd799 --- /dev/null +++ b/ecmake/cmake/Modules/FindEina.cmake @@ -0,0 +1,28 @@ +# - Try to find eina +# Once done this will define +# EINA_FOUND - System has eina +# EINA_INCLUDE_DIRS - The eina include directories +# EINA_LIBRARIES - The libraries needed to use eina +# EINA_DEFINITIONS - Compiler switches required for using eina + +find_package(PkgConfig) +pkg_check_modules(PC_LIBEINA QUIET eina) +set(EINA_DEFINITIONS ${PC_LIBEINA_CFLAGS_OTHER}) + +find_path(EINA_INCLUDE_DIR Eina.h + HINTS ${PC_LIBEINA_INCLUDEDIR} ${PC_LIBEINA_INCLUDE_DIRS} + PATH_SUFFIXES eina ) + +find_library(EINA_LIBRARY NAMES eina + HINTS ${PC_LIBEINA_LIBDIR} ${PC_LIBEINA_LIBRARY_DIRS} ) + +set(EINA_LIBRARIES ${EINA_LIBRARY} ) +set(EINA_INCLUDE_DIRS ${EINA_INCLUDE_DIR} "${EINA_INCLUDE_DIR}/eina" ) + +include(FindPackageHandleStandardArgs) +# handle the QUIETLY and REQUIRED arguments and set EINA_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args(eina DEFAULT_MSG + EINA_LIBRARY EINA_INCLUDE_DIR) + +mark_as_advanced(EINA_INCLUDE_DIR EINA_LIBRARY ) diff --git a/ecmake/cmake/Modules/FindElementary.cmake b/ecmake/cmake/Modules/FindElementary.cmake new file mode 100644 index 0000000..5b75bfc --- /dev/null +++ b/ecmake/cmake/Modules/FindElementary.cmake @@ -0,0 +1,28 @@ +# - Try to find elementary +# Once done this will define +# ELEMENTARY_FOUND - System has elementary +# ELEMENTARY_INCLUDE_DIRS - The elementary include directories +# ELEMENTARY_LIBRARIES - The libraries needed to use elementary +# ELEMENTARY_DEFINITIONS - Compiler switches required for using elementary + +find_package(PkgConfig) +pkg_check_modules(PC_LIBELEMENTARY QUIET elementary) +set(ELEMENTARY_DEFINITIONS ${PC_LIBELEMENTARY_CFLAGS_OTHER}) + +find_path(ELEMENTARY_INCLUDE_DIR Elementary.h + HINTS ${PC_LIBELEMENTARY_INCLUDEDIR} ${PC_LIBELEMENTARY_INCLUDE_DIRS} + PATH_SUFFIXES elementary ) + +find_library(ELEMENTARY_LIBRARY NAMES elementary + HINTS ${PC_LIBELEMENTARY_LIBDIR} ${PC_LIBELEMENTARY_LIBRARY_DIRS} ) + +set(ELEMENTARY_LIBRARIES ${ELEMENTARY_LIBRARY} ) +set(ELEMENTARY_INCLUDE_DIRS ${PC_LIBELEMENTARY_INCLUDEDIR} ${PC_LIBELEMENTARY_INCLUDE_DIRS} ) + +include(FindPackageHandleStandardArgs) +# handle the QUIETLY and REQUIRED arguments and set ELEMENTARY_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args(elementary DEFAULT_MSG + ELEMENTARY_LIBRARY ELEMENTARY_INCLUDE_DIR) + +mark_as_advanced(ELEMENTARY_INCLUDE_DIR ELEMENTARY_LIBRARY ) diff --git a/ecmake/cmake/Modules/FindEvas.cmake b/ecmake/cmake/Modules/FindEvas.cmake new file mode 100644 index 0000000..fe980d3 --- /dev/null +++ b/ecmake/cmake/Modules/FindEvas.cmake @@ -0,0 +1,28 @@ +# - Try to find evas +# Once done this will define +# EVAS_FOUND - System has evas +# EVAS_INCLUDE_DIRS - The evas include directories +# EVAS_LIBRARIES - The libraries needed to use evas +# EVAS_DEFINITIONS - Compiler switches required for using evas + +find_package(PkgConfig) +pkg_check_modules(PC_LIBEVAS QUIET evas) +set(EVAS_DEFINITIONS ${PC_LIBEVAS_CFLAGS_OTHER}) + +find_path(EVAS_INCLUDE_DIR Evas.h + HINTS ${PC_LIBEVAS_INCLUDEDIR} ${PC_LIBEVAS_INCLUDE_DIRS} + PATH_SUFFIXES evas ) + +find_library(EVAS_LIBRARY NAMES evas + HINTS ${PC_LIBEVAS_LIBDIR} ${PC_LIBEVAS_LIBRARY_DIRS} ) + +set(EVAS_LIBRARIES ${EVAS_LIBRARY} ) +set(EVAS_INCLUDE_DIRS ${EVAS_INCLUDE_DIR} ) + +include(FindPackageHandleStandardArgs) +# handle the QUIETLY and REQUIRED arguments and set EVAS_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args(evas DEFAULT_MSG + EVAS_LIBRARY EVAS_INCLUDE_DIR) + +mark_as_advanced(EVAS_INCLUDE_DIR EVAS_LIBRARY ) diff --git a/ecmake/cmake/Modules/MakeDistcheck.cmake b/ecmake/cmake/Modules/MakeDistcheck.cmake new file mode 100644 index 0000000..1f383a5 --- /dev/null +++ b/ecmake/cmake/Modules/MakeDistcheck.cmake @@ -0,0 +1,122 @@ +# - adds support for the 'make distcheck' command -*- cmake -*- +# Dependencies: +# 1. CPack generating ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz. +# 2. Having a "dist" target, e.g: +# add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source) +# Usage: +# add_distcheck() ... called exactly once per project in the top-level +# CMakeLists.txt; it adds the 'dist' and 'distcheck' +# targets +# +# This module implements the 'make dist' and 'make distcheck' +# commands. +# It supports the following variables: +# +# DISTCHECK_TMPDIR ... directory for temporary files +# DISTCHECK_FILENAME ... basename of existing tar.gz.; defaults to +# ${CPACK_SOURCE_PACKAGE_FILE_NAME} +# DISTCHECK_CMAKEFLAGS +# ... flags which are given to 'cmake' by 'make distcheck' +# DISTCHECK_BUILDTARGETS +# ... the build-targets tried by 'make distcheck'; +# defaults to nothing (--> all) +# DISTCHECK_INSTALLTARGETS +# ... the install-targets tried by 'make distcheck'; +# defaults to 'install' +# +# Example: +# --- top-level CMakeLists.txt --- +# add_subdirectory(foo) +# ... +# ... +# set(CPACK_PACKAGE_VERSION_MAJOR ${ECRIRE_VERSION_MAJOR}) +# set(CPACK_PACKAGE_VERSION_MINOR ${ECRIRE_VERSION_MINOR}) +# set(CPACK_PACKAGE_VERSION_PATCH ${ECRIRE_VERSION_MICRO}) +# set(CPACK_SOURCE_GENERATOR "TGZ") +# set(CPACK_SOURCE_IGNORE_FILES +# "${CMAKE_BINARY_DIR};/.git/;~$;${CPACK_SOURCE_IGNORE_FILES}") +# include(CPack) +# add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source) +# +# find_package(Distcheck) +# add_distcheck() +# +# +# Copyright (C) 2012 Tom Hacohen <tom@stosb.com> +# Based on the work done by: +# Copyright (C) 2006 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> +# +# Redistribution and use, with or without modification, are permitted +# provided that the following conditions are met: +# +# 1. Redistributions must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# 2. The name of the author may not be used to endorse or promote +# products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +macro(add_distcheck) + set(MakeDist_FOUND 1) + + set(DISTCHECK_TMPDIR "${CMAKE_BINARY_DIR}/.make-dist" CACHE PATH "directory for temporary files created by'make dist*'") + set(DISTCHECK_FILENAME ${CPACK_SOURCE_PACKAGE_FILE_NAME} CACHE PATH "basename of the tarball created by 'make dist'") + set(DISTCHECK_CMAKEFLAGS CACHE STRING "flags which are given to 'cmake' by 'make distcheck'") + set(DISTCHECK_BUILDTARGETS "" CACHE STRING "build-target(s) tried by 'make distcheck'") + set(DISTCHECK_INSTALLTARGETS install CACHE STRING "install-target(s) tried by 'make distcheck'") + + mark_as_advanced(DISTCHECK_TMPDIR DISTCHECK_FILENAME DISTCHECK_CMAKEFLAGS DISTCHECK_BUILDTARGETS DISTCHECK_INSTALLTARGETS) + + set(DISTCHECK_BASESOURCEDIR "${DISTCHECK_TMPDIR}/source") + set(DISTCHECK_SOURCEDIR "${DISTCHECK_BASESOURCEDIR}/${DISTCHECK_FILENAME}") + set(DISTCHECK_BUILDDIR "${DISTCHECK_TMPDIR}/build") + set(DISTCHECK_INSTALLTARGETS "install") + add_custom_target(distcheck + # Create the tarball + COMMAND ${CMAKE_MAKE_PROGRAM} dist + + # Create the temp dir. + COMMAND chmod -Rf a+w "${DISTCHECK_TMPDIR}" 2>/dev/null || : + COMMAND rm -rf "${DISTCHECK_TMPDIR}" + COMMAND mkdir -p "${DISTCHECK_SOURCEDIR}" "${DISTCHECK_BUILDDIR}" + + # extract tarball + COMMAND tar xzf ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz -C "${DISTCHECK_BASESOURCEDIR}" + # write-protect sources to detect modifies-sourcetree bugs + COMMAND chmod -R a-w "${DISTCHECK_SOURCEDIR}" + + COMMAND cd "${DISTCHECK_BUILDDIR}" && ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX:PATH="${DISTCHECK_TMPDIR}/install" ${DISTCHECK_CMAKEFLAGS} "${DISTCHECK_SOURCEDIR}" + + COMMAND cd "${DISTCHECK_BUILDDIR}" && ${CMAKE_MAKE_PROGRAM} ${DISTCHECK_BUILDTARGETS} + + # execute 'make install' without DESTDIR + COMMAND cd "${DISTCHECK_BUILDDIR}" && ${CMAKE_MAKE_PROGRAM} ${DISTCHECK_INSTALLTARGETS} DESTDIR= + # write protect installation path to detect writing outside of DESTDIR + COMMAND chmod -R a-w "${DISTCHECK_TMPDIR}/install" + # execute 'make install' with DESTDIR and move the files to a better location + COMMAND cd "${DISTCHECK_BUILDDIR}" && ${CMAKE_MAKE_PROGRAM} ${DISTCHECK_INSTALLTARGETS} DESTDIR="${DISTCHECK_TMPDIR}/install-tmp" + COMMAND mv "${DISTCHECK_TMPDIR}/install-tmp/${DISTCHECK_TMPDIR}/install" "${DISTCHECK_TMPDIR}/install-destdir" + + # generate list of files which were installed by the both 'make + # install' commands above and compare them + COMMAND cd "${DISTCHECK_TMPDIR}/install" && find -type f | sort > ../files.install + COMMAND cd "${DISTCHECK_TMPDIR}/install-destdir" && find -type f | sort > ../files.destdir + COMMAND cd "${DISTCHECK_TMPDIR}" && diff files.install files.destdir + + # cleanup tmpdir + COMMAND chmod -R u+Xw "${DISTCHECK_TMPDIR}" 2>/dev/null || : + COMMAND rm -rf "${DISTCHECK_TMPDIR}" + ) +endmacro(add_distcheck) + |