netcdf-c/cf.cmake
Dennis Heimbigner 4db4393e69 Begin changing over to use strlcat instead of strncat because
strlcat provides better protection against buffer overflows.

Code is taken from the FreeBSD project source code. Specifically:
https://github.com/freebsd/freebsd/blob/master/lib/libc/string/strlcat.c
License appears to be acceptable, but needs to be checked by e.g. Debian.

Step 1:
1. Add to netcdf-c/include/ncconfigure.h to use our version
   if not already available as determined by HAVE_STRLCAT in config.h.
2. Add the strlcat code to libdispatch/dstring.c
3. Turns out that strlcat was already defined in several places.
   So remove it from:
	ncgen3/genlib.c
	ncdump/dumplib.c
3. Define strlcat extern definition in ncconfigure.h.
4. Modify following directories to use strlcat:
	libdap2 libdap4 ncdap_test dap4_test
   Will do others in subsequent steps.
2017-11-23 10:55:24 -07:00

76 lines
1.4 KiB
CMake

# Visual Studio
case "$1" in
vs|VS) VS=1 ;;
linux|nix) unset VS ;;
*) echo "Must specify env: vs|linux"; exit 1; ;;
esac
if test "x$VS" = x1 ; then
if test "x$2" = xsetup ; then
VSSETUP=1
else
unset VSSETUP
fi
fi
#export NCPATHDEBUG=1
if test "x$VSSETUP" = x1 ; then
CFG="Debug"
else
CFG="Release"
fi
# Is netcdf-4 and/or DAP enabled?
NC4=1
DAP=1
if test "x$VS" != x ; then
FLAGS="-DCMAKE_PREFIX_PATH=c:/tools/nccmake"
else
FLAGS="$FLAGS -DCMAKE_INSTALL_PREFIX=`pwd`/ignore"
fi
if test "x$DAP" = x ; then
FLAGS="$FLAGS -DENABLE_DAP=false"
else
FLAGS="$FLAGS -DENABLE_DAP=true"
fi
if test "x$NC4" = x ; then
FLAGS="$FLAGS -DENABLE_NETCDF_4=false"
fi
FLAGS="$FLAGS -DENABLE_CONVERSION_WARNINGS=false"
FLAGS="$FLAGS -DENABLE_DAP_REMOTE_TESTS=true"
FLAGS="$FLAGS -DENABLE_TESTS=true"
FLAGS="$FLAGS -DENABLE_EXAMPLES=false"
#FLAGS="$FLAGS -DENABLE_HDF4=true"
FLAGS="$FLAGS -DENABLE_DYNAMIC_LOADING=false"
FLAGS="$FLAGS -DENABLE_WINSOCK2=false"
#FLAGS="$FLAGS -DENABLE_LARGE_FILE_TESTS=true"
rm -fr build
mkdir build
cd build
NCLIB=`pwd`
if test "x$VS" != x ; then
# Visual Studio
#CFG="RelWithDebInfo"
CFG="Release"
NCLIB="${NCLIB}/build/liblib/$CFG"
export PATH="${NCLIB}:${PATH}"
cmake $FLAGS ..
cmake --build . --config ${CFG}
cmake --build . --config ${CFG} --target RUN_TESTS
else
# GCC
NCLIB="${NCLIB}/build/liblib"
G="-GUnix Makefiles"
cmake "${G}" $FLAGS ..
#make all
#make test
fi
exit