update cmakelists

This commit is contained in:
张壹 2021-08-26 19:50:05 +08:00
parent 7b0a67b36c
commit 97be4f5091
2 changed files with 23 additions and 62 deletions

View File

@ -4,9 +4,18 @@ cmake_minimum_required(VERSION 3.15.2)
project(NETCDF_CXX)
message(STATUS "Platform: " ${CMAKE_HOST_SYSTEM_NAME})
if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows")
#set(CMAKE_C_COMPILER gcc)
#set(CMAKE_CXX_COMPILER g++)
if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux")
# netcdf C
set(LIB_NETCDF /usr/local)
elseif (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin" AND ${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64")
# netcdf C
set(LIB_NETCDF /usr/local)
elseif (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin")
# netcdf C
set(LIB_NETCDF /opt/homebrew)
elseif(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows")
set(LIB_NETCDF C:/Program\ Files/netCDF\ 4.8.0)
# 使config.sh windows
set(CMAKE_INSTALL_PREFIX D:/Library)
endif()
message(STATUS "Install prefix: " ${CMAKE_INSTALL_PREFIX})

View File

@ -1,65 +1,17 @@
#!/bin/bash
#!/bin/bash
package=NULL
runtype=configure
buildtype=Release
netcdflib=/usr/local
prefixdir=/opt/stow
cmd=${1}
package=netcdfcxx_legacy
address=/opt/stow
targetdir=/usr/local
while getopts "hr:p:b:n:d:t:" arg
do
case $arg in
h)
echo "Install and manage packages with the Stow software."
echo "-r running type: configure (default), build or install."
echo "-p package name."
echo "-b build type: Release (default) or Debug."
echo "-n netCDF library address: /usr/local (default)."
echo "-d install prefix: /opt/stow (default)."
echo "-t target prefix: /opt (default)."
exit 0;;
r)
runtype=${OPTARG};;
p)
package=${OPTARG};;
b)
buildtype=${OPTARG};;
n)
netcdflib=${OPTARG};;
d)
prefixdir=${OPTARG};;
t)
targetdir=${OPTARG};;
?)
echo "Error: unknow argument."
echo "Use -h option to see help information."
exit 1;;
esac
done
if [[ ${runtype} == "configure" && ! -d "build/" ]]; then
if [[ ${package} == "NULL" ]]; then
echo "Error: no package name."
echo "Use -h option to see help information."
exit 1
fi
mkdir build && cd build && cmake .. -DCMAKE_INSTALL_PREFIX=${prefixdir}/${package} -DCMAKE_BUILD_TYPE=${buildtype} -DLIB_NETCDF=${netcdflib}
elif [[ ${runtype} == "configure" ]]; then
if [[ ${package} == "NULL" ]]; then
echo "Error: no package name."
echo "Use -h option to see help information."
exit 1
fi
cd build && rm -rf * && cmake .. -DCMAKE_INSTALL_PREFIX=${prefixdir}/${package} -DCMAKE_BUILD_TYPE=${buildtype} -DLIB_NETCDF=${netcdflib}
elif [[ ${runtype} == "build" ]]; then
if [[ ${cmd} == "configure" && ! -d "build/" ]]; then
mkdir build && cd build && cmake .. -DCMAKE_INSTALL_PREFIX=${address}/${package} -DCMAKE_BUILD_TYPE=Release
elif [[ ${cmd} == "configure" ]]; then
cd build && rm -rf * && cmake .. -DCMAKE_INSTALL_PREFIX=${address}/${package} -DCMAKE_BUILD_TYPE=Release
elif [[ ${cmd} == "build" ]]; then
cd build && make
elif [[ ${runtype} == "install" ]]; then
if [[ ${package} == "NULL" ]]; then
echo "Error: no package name."
echo "Use -h option to see help information."
exit 1
fi
elif [[ ${cmd} == "install" ]]; then
cd build && sudo make install
sudo stow --dir=${prefixdir} --target=${targetdir} ${package}
sudo stow --dir=${address} --target=${targetdir} ${package}
fi