#!/bin/bash # display help text usage () { cat < if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor CXX C++ compiler command CXXFLAGS C++ compiler flags CXXCPP C++ preprocessor F77 Fortran 77 compiler command FFLAGS Fortran 77 compiler flags FC Fortran compiler command FCFLAGS Fortran compiler flags Use these variables to override the choices made by \`configure' or to help it to find libraries and programs with nonstandard names/locations. EOF } # report an error regarding the arguments invalid_arg () { cat < while getopts -- ":-:" optchar; do case "${optchar}" in -) # OPTARG now contains everything after double dashes case "${OPTARG}" in prefix=*) # remove prefix consisting of everything up to equal sign prefix=${OPTARG#*=} ;; help) usage exit 0 ;; with-*) # get the name of the package; everything before equal sign pkgname=${OPTARG%=*} pkgname=${pkgname#with-} # get the location of the package; everyhing after equal sign pkgloc=${OPTARG#*=} # expand to full path since CMake changes to source directory (!) pkgloc=$(echo $(sh -c "cd $(dirname ${pkgloc}); pwd")/$(basename ${pkgloc})) # packages need different suffix for their root (sic) case "${pkgname}" in agmg |\ boost |\ ert |\ zlib) rootvar="${pkgname^^}_ROOT" ;; superlu) rootvar="${pkgname^^}_PREFIX" ;; *) rootvar="${pkgname}_DIR" ;; esac # add this to the list of existing features FEATURES="${FEATURES} -D${rootvar}=${pkgloc}" ;; disable-*) # get the name of the package pkgname=${OPTARG#disable-} # casing is of course different case "${pkgname}" in agmg |\ ert |\ superlu) pkgname="${pkgname^^}" ;; openmp) pkgname="OpenMP" ;; gxx11check) pkgname="CXX11Features" ;; esac FEATURES="${FEATURES} -DCMAKE_DISABLE_FIND_PACKAGE_${pkgname}=TRUE" ;; enable-*) # what kind of library are we building; shared or static? kind=${OPTARG#enable-} case "${kind}" in shared) shared="ON" ;; static) shared="OFF" ;; *) invalid_arg --enable-${kind} exit 1 ;; esac FEATURES="${FEATURES} -DBUILD_opm-core_SHARED:BOOL=${shared}" ;; *) # remove everything *after* the equal sign arg=${OPTARG%=*} invalid_arg --$arg exit 1 ;; esac ;; *) invalid_arg -$OPTARG exit 1 ;; esac done # remove all arguments processed by getopts shift $((OPTIND-1)) # pass everything on to CMake env "$@" cmake "$(dirname $0)" "-DCMAKE_INSTALL_PREFIX=$prefix" ${FEATURES}