Skip to content

Commit

Permalink
Further work on getting an install-fortran option working. Cmake only…
Browse files Browse the repository at this point in the history
… so far, and now works with static AND shared builds.
  • Loading branch information
Ward Fisher committed Nov 18, 2014
1 parent 04b8640 commit 7947e31
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 13 deletions.
13 changes: 8 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,14 @@ IF(ENABLE_LOGGING)
ENDIF()

# Option to automatically build netcdf-fortran.
OPTION(BUILD_FORTRAN "Download and build netcdf-fortran automatically." OFF)
IF(BUILD_FORTRAN)
CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/fortran_install.sh.in"
"${CMAKE_BINARY_DIR}/fortran_install.sh")
ENDIF(BUILD_FORTRAN)
IF(NOT MSVC)
OPTION(BUILD_FORTRAN "Download and build netcdf-fortran automatically (EXPERIMENTAL)." OFF)
IF(BUILD_FORTRAN)
CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/fortran_install.sh.in"
"${CMAKE_BINARY_DIR}/fortran_install.sh"
@ONLY)
ENDIF(BUILD_FORTRAN)
ENDIF()

# Option to use HDF4
OPTION(ENABLE_HDF4 "Build netCDF-4 with HDF5 read capability(HDF4, HDF5 and Zlib required)." OFF)
Expand Down
2 changes: 1 addition & 1 deletion PostInstall.cmake
Original file line number Diff line number Diff line change
@@ -1 +1 @@
EXECUTE_PROCESS(COMMAND sh -c "${CMAKE_BINARY_DIR}/fortran_install.sh")
EXECUTE_PROCESS(COMMAND sh -c "${CMAKE_BINARY_DIR}/fortran_install.sh -t cmake")
63 changes: 56 additions & 7 deletions fortran_install.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,66 @@
# Script to automatically build, install netcdf-fortran.
# Very rought draft.

DOCMAKE=""
MARG=""
if [ $# -lt 1 ]; then
echo ""
echo "WARNING! THIS SCRIPT IS NOT MEANT TO BE RUN MANUALLY."
echo "WARNING! THIS SCRIPT IS NOT MEANT TO BE RUN MANUALLY."
echo ""
exit 1
fi

while getopts "t:" o; do
case "${o}" in
t)
MARG=${OPTARG}
;;
*)
echo "Specify type with -t. Types are autotools or cmake."
exit 1
;;
esac
done

case ${MARG} in
cmake)
DOCMAKE="TRUE"
;;
autotools)
;;
*)
echo "Illegal type. Types are autotools or cmake."
exit 1
;;
esac




###
# Fetch netcdf-fortran from git
# Fetch netcdf-fortran from git if need be.
###
git clone http://github.com/unidata/netcdf-fortran
cd netcdf-fortran
mkdir -p build
cd build
git checkout v4.4.1

if [ ! -d "netcdf-fortran" ]; then
git clone http://github.com/unidata/netcdf-fortran
cd netcdf-fortran
git checkout v4.4.1
fi

###
# Invoke cmake to build netcdf-fortran
###
cmake .. -DCMAKE_PREFIX_PATH=@CMAKE_INSTALL_PREFIX@ -DCMAKE_INSTALL_PREFIX=@CMAKE_INSTALL_PREFIX@ && make && make test && make install

if [ "x$DOCMAKE" = "xTRUE" ]; then

mkdir -p build
cd build
cmake .. -DCMAKE_PREFIX_PATH=@CMAKE_INSTALL_PREFIX@ -DCMAKE_INSTALL_PREFIX=@CMAKE_INSTALL_PREFIX@ -DBUILD_SHARED_LIBS=@BUILD_SHARED_LIBS@ -DTEST_PARALLEL=@ENABLE_PARALLEL@ && make && make test && make install

else

echo "Autotools support is not yet complete."


fi

0 comments on commit 7947e31

Please sign in to comment.