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
|
include(${CMAKE_MODULE_PATH}/DistCommon.cmake)
function(run_dist_check PACKAGE_PREFIX EXT)
set(tarball ${PACKAGE_PREFIX}.tar${EXT})
if (NOT EXISTS ${tarball})
message(FATAL_ERROR "Can't find dist tarball '${tarball}'")
endif()
# Remove the directory we're about to extract to
file(REMOVE_RECURSE ${PACKAGE_PREFIX})
# Untar the distribution we want to check
set(TAR_OPTION "zxf")
if (${EXT} STREQUAL ".bz2")
set(TAR_OPTION "jxf")
endif()
FIND_PROGRAM(NINJA_COMMAND NAMES ninja ninja-build)
if (${NINJA_COMMAND} STREQUAL "NINJA_COMMAND-NOTFOUND")
message(FATAL_ERROR "Can't find the 'ninja' or 'ninja-build' program.")
endif ()
execute_process_and_check_result(
COMMAND ${CMAKE_COMMAND} -E tar ${TAR_OPTION} ${tarball}
WORKING_DIRECTORY .
ERROR_MSG "Command to untar ${tarball} failed."
)
# Officially, I should make the contents of the untarred dist directory read-only,
# but that will cause the build to fail (intltool is unhappy).
# Create a build directory and configure the Cmake build
set(BUILD_DIR "_cmake_build")
set(INSTALL_DIR "_cmake_install")
file(REMOVE_RECURSE ${BUILD_DIR} ${INSTALL_DIR})
file(MAKE_DIRECTORY ${BUILD_DIR} ${INSTALL_DIR})
execute_process_and_check_result(
COMMAND ${CMAKE_COMMAND} -G Ninja
-D CMAKE_INSTALL_PREFIX=../${INSTALL_DIR}
../${PACKAGE_PREFIX}
WORKING_DIRECTORY ${BUILD_DIR}
ERROR_MSG "CMake configure command failed."
)
# Run ninja in the build directory
execute_process_and_check_result(
COMMAND ${CMAKE_COMMAND} -E env ${NINJA_COMMAND}
WORKING_DIRECTORY ${BUILD_DIR}
ERROR_MSG "Ninja build failed."
)
# Run ninja install
execute_process_and_check_result(
COMMAND ${CMAKE_COMMAND} -E env ${NINJA_COMMAND} install
WORKING_DIRECTORY ${BUILD_DIR}
ERROR_MSG "Ninja install failed."
)
# Run ninja check in the build directory
execute_process_and_check_result(
COMMAND ${CMAKE_COMMAND} -E env ${NINJA_COMMAND} check
WORKING_DIRECTORY ${BUILD_DIR}
ERROR_MSG "Ninja check failed."
)
message("distcheck complete.")
endfunction()
run_dist_check(${PACKAGE_PREFIX} .gz)
|