update cmakelists
This commit is contained in:
		| @@ -4,9 +4,18 @@ cmake_minimum_required(VERSION 3.15.2) | |||||||
| project(NETCDF_CXX) | project(NETCDF_CXX) | ||||||
|  |  | ||||||
| message(STATUS "Platform: " ${CMAKE_HOST_SYSTEM_NAME}) | message(STATUS "Platform: " ${CMAKE_HOST_SYSTEM_NAME}) | ||||||
| if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows") | if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux") | ||||||
|     #set(CMAKE_C_COMPILER gcc) |     # 配置netcdf C语言库的地址 | ||||||
|     #set(CMAKE_CXX_COMPILER g++) |     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) |     set(CMAKE_INSTALL_PREFIX D:/Library) | ||||||
| endif() | endif() | ||||||
| message(STATUS "Install prefix: " ${CMAKE_INSTALL_PREFIX}) | message(STATUS "Install prefix: " ${CMAKE_INSTALL_PREFIX}) | ||||||
|   | |||||||
							
								
								
									
										70
									
								
								config.sh
									
									
									
									
									
								
							
							
						
						
									
										70
									
								
								config.sh
									
									
									
									
									
								
							| @@ -1,65 +1,17 @@ | |||||||
| #!/bin/bash | #!/bin/bash | ||||||
|  |  | ||||||
| package=NULL | cmd=${1} | ||||||
| runtype=configure | package=netcdfcxx_legacy | ||||||
| buildtype=Release | address=/opt/stow | ||||||
| netcdflib=/usr/local |  | ||||||
| prefixdir=/opt/stow |  | ||||||
| targetdir=/usr/local | targetdir=/usr/local | ||||||
|  |  | ||||||
| while getopts "hr:p:b:n:d:t:" arg | if [[ ${cmd} == "configure" && ! -d "build/" ]]; then | ||||||
| do | 	mkdir build && cd build && cmake .. -DCMAKE_INSTALL_PREFIX=${address}/${package} -DCMAKE_BUILD_TYPE=Release | ||||||
| 	case $arg in | elif [[ ${cmd} == "configure" ]]; then | ||||||
| 		h) | 	cd build && rm -rf * && cmake .. -DCMAKE_INSTALL_PREFIX=${address}/${package} -DCMAKE_BUILD_TYPE=Release | ||||||
| 			echo "Install and manage packages with the Stow software." | elif [[ ${cmd} == "build" ]]; then | ||||||
| 			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 |  | ||||||
| 	cd build && make | 	cd build && make | ||||||
| elif [[ ${runtype} == "install" ]]; then | elif [[ ${cmd} == "install" ]]; then | ||||||
| 	if [[ ${package} == "NULL" ]]; then |  | ||||||
| 		echo "Error: no package name." |  | ||||||
| 		echo "Use -h option to see help information." |  | ||||||
| 		exit 1 |  | ||||||
| 	fi |  | ||||||
| 	cd build && sudo make install | 	cd build && sudo make install | ||||||
| 	sudo stow --dir=${prefixdir} --target=${targetdir} ${package} | 	sudo stow --dir=${address} --target=${targetdir} ${package} | ||||||
| fi | fi | ||||||
		Reference in New Issue
	
	Block a user