hdf5/bin/cmakehdf5
2012-12-20 10:39:37 -05:00

176 lines
5.6 KiB
Bash
Executable File

#! /bin/sh
# Build and Test HDF5 using cmake.
# Author: Allen Byrne
# Albert Cheng
# Creation Date: Nov 2012
# Copyright: The HDF Group, 2012
# Debug: remove the comment hash if you want DPRINT to do echo
DPRINT=:
#DPRINT=echo
# variable names
progname=`basename $0` # program name
cminfile="cmakemin.$$" # Cmake minimum file
cfgfile=$progname.$$ # configure file
$DPRINT $cfgfile
# Remove temporary generated files if exit 0
trap "rm -f $cminfile $cfgfile" 0
#==========
# main
#==========
# First generate the two needed input files, the $cimnfile and $cfgfile.
# Then use ctest to use the two input files.
# This works only in Jam for now.
# Exit if not running in Jam.
if [ `hostname` != jam ]; then
echo This is known to work in Jam for now.
echo It may fail in other machines.
echo Support for more platforms is coming.
echo
fi
#==========
# create the configure file
#==========
# Create the cmake minimum required file to be used by the following
# configure file. Though not absolute needed, it is better to generate
# this file before the configure file. Quote the EOF to preven substitution
# in the text.
#==========
#==========
cat > $cfgfile <<'EOF'
cmake_minimum_required(VERSION 2.8.6 FATAL_ERROR)
########################################################
# This dashboard is maintained by The HDF Group
# For any comments please contact cdashhelp@hdfgroup.org
#
########################################################
set (CTEST_DASHBOARD_ROOT ${CTEST_SCRIPT_DIRECTORY})
set (CTEST_SOURCE_DIRECTORY "../hdf5")
set (CTEST_BINARY_DIRECTORY ".")
set (CTEST_CMAKE_GENERATOR "Unix Makefiles")
set (CTEST_BUILD_CONFIGURATION "Release")
# -- CDash variables
#set (LOCAL_NO_SUBMIT TRUE)
set (MODEL "Experimental")
set (CDASH_LOCAL TRUE)
set (SITE_BUILDNAME_SUFFIX "SHARED")
# -- URL set for internal check, default is to not update
set (LOCAL_SKIP_UPDATE TRUE)
set (REPOSITORY_URL "http://svn.hdfgroup.uiuc.edu/hdf5/branches/hdf5_1_8")
# -- Standard build options
set (ADD_BUILD_OPTIONS "-DCMAKE_INSTALL_PREFIX:PATH=/usr/local/hdf5.1.8 -DHDF5_ALLOW_EXTERNAL_SUPPORT:STRING=\"SVN\" -DHDF5_PACKAGE_EXTLIBS:BOOL=ON")
# -----------------------------------------------------------
# -- Get environment
# -----------------------------------------------------------
## -- set hostname
## --------------------------
find_program (HOSTNAME_CMD NAMES hostname)
exec_program (${HOSTNAME_CMD} ARGS OUTPUT_VARIABLE HOSTNAME)
set (CTEST_SITE "${HOSTNAME}${CTEST_SITE_EXT}")
find_program (UNAME NAMES uname)
macro (getuname name flag)
exec_program ("${UNAME}" ARGS "${flag}" OUTPUT_VARIABLE "${name}")
endmacro (getuname)
getuname (osname -s)
getuname (osrel -r)
getuname (cpu -m)
message ("Dashboard script uname output: ${osname}-${osrel}-${cpu}\n")
if (SITE_BUILDNAME_SUFFIX)
set (CTEST_BUILD_NAME "${osname}-${osrel}-${cpu}-${SITE_BUILDNAME_SUFFIX}")
else (SITE_BUILDNAME_SUFFIX)
set (CTEST_BUILD_NAME "${osname}-${osrel}-${cpu}")
endif (SITE_BUILDNAME_SUFFIX)
# -----------------------------------------------------------
set (BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DSITE:STRING=${CTEST_SITE} -DBUILDNAME:STRING=${CTEST_BUILD_NAME}")
# -----------------------------------------------------------
find_package (Subversion)
set (CTEST_UPDATE_COMMAND ${Subversion_SVN_EXECUTABLE})
# -- Only clean build folder if LOCAL_CLEAR_BUILD is set
if (LOCAL_CLEAR_BUILD)
set (CTEST_START_WITH_EMPTY_BINARY_DIRECTORY TRUE)
ctest_empty_binary_directory (${CTEST_BINARY_DIRECTORY})
endif (LOCAL_CLEAR_BUILD)
#-----------------------------------------------------------------------------
# Send the main script as a note.
list (APPEND CTEST_NOTES_FILES
"${CMAKE_CURRENT_LIST_FILE}"
"${CTEST_SOURCE_DIRECTORY}/config/cmake/cacheinit.cmake"
)
# Check for required variables.
foreach (req
CTEST_CMAKE_GENERATOR
CTEST_SITE
CTEST_BUILD_NAME
)
if (NOT DEFINED ${req})
message(FATAL_ERROR "The containing script must set ${req}")
endif (NOT DEFINED ${req})
endforeach (req)
# Print summary information.
foreach (v
CTEST_SITE
CTEST_BUILD_NAME
CTEST_SOURCE_DIRECTORY
CTEST_BINARY_DIRECTORY
CTEST_CMAKE_GENERATOR
CTEST_BUILD_CONFIGURATION
CTEST_GIT_COMMAND
CTEST_CHECKOUT_COMMAND
CTEST_CONFIGURE_COMMAND
CTEST_SCRIPT_DIRECTORY
CTEST_USE_LAUNCHERS
)
set (vars "${vars} ${v}=[${${v}}]\n")
endforeach (v)
message ("Dashboard script configuration:\n${vars}\n")
#-----------------------------------------------------------------------------
#-- Do the work
#-----------------------------------------------------------------------------
SET (CTEST_CONFIGURE_COMMAND
"${CMAKE_COMMAND} -C \"${CTEST_SOURCE_DIRECTORY}/config/cmake/cacheinit.cmake\" -DCMAKE_BUILD_TYPE:STRING=${CTEST_BUILD_CONFIGURATION} ${BUILD_OPTIONS} \"-G${CTEST_CMAKE_GENERATOR}\" \"${CTEST_SOURCE_DIRECTORY}\"")
CTEST_START (${MODEL})
if (NOT LOCAL_SKIP_UPDATE)
CTEST_UPDATE (SOURCE "${CTEST_SOURCE_DIRECTORY}")
endif (NOT LOCAL_SKIP_UPDATE)
CTEST_CONFIGURE (BUILD "${CTEST_BINARY_DIRECTORY}")
CTEST_READ_CUSTOM_FILES ("${CTEST_BINARY_DIRECTORY}")
if (NOT LOCAL_NO_SUBMIT)
CTEST_SUBMIT (PARTS Update Configure Notes)
endif (NOT LOCAL_NO_SUBMIT)
CTEST_BUILD (BUILD "${CTEST_BINARY_DIRECTORY}" APPEND)
if (NOT LOCAL_NO_SUBMIT)
CTEST_SUBMIT (PARTS Build)
endif (NOT LOCAL_NO_SUBMIT)
if (NOT LOCAL_SKIP_TEST)
CTEST_TEST (BUILD "${CTEST_BINARY_DIRECTORY}" APPEND)
if (NOT LOCAL_NO_SUBMIT)
CTEST_SUBMIT (PARTS Test)
endif (NOT LOCAL_NO_SUBMIT)
endif (NOT LOCAL_SKIP_TEST)
message ("DONE")
EOF
# Run ctest
ctest -S $cfgfile -C Release -O testhdf.log -VV