forked from NOAA-EMC/NCEPLIBS-ncio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
61 lines (57 loc) · 2.56 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
cmake_minimum_required(VERSION 2.6)
project(ncio)
set(VERSION v1.0.0)
enable_language (Fortran)
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE RELEASE CACHE STRING
"Choose the type of build, options are: PRODUCTION Debug Release."
FORCE)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
message("setting intel true")
set(IntelComp true )
# set(CMAKE_C_COMPILER icc)
# set(MPI_C_LIBRARIES icc)
# set(MPI_C_INCLUDE_PATH /apps/intel/parallel_studio_xe_2018.4.057/compilers_and_libraries_2018/linux/ipp/include)
# set(CMAKE_fortran_COMPILER ifort)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU*")
set(GNUComp true )
elseif(CMAKE_CXX_COMPILER_ID MATCHES "pgc*")
set(PGIComp true )
endif()
find_package(MPI REQUIRED)
find_package(NETCDF)
STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "RelWithDebInfo" BUILD_RELEASE)
STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "RELEASE" BUILD_RELEASE)
STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "PRODUCTION" BUILD_PRODUCTION)
STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "DEGUG" BUILD_DEBUG)
if( (BUILD_RELEASE) OR (BUILD_PRODUCTION) )
if(IntelComp)
message("setting intel flags")
include_directories(${MPI_INCLUDE_PATH} )
# set(CMAKE_Fortran_FLAGS "-O2 -convert big_endian -free -assume byterecl -xHOST -fp-model strict -traceback -axCORE-AVX2 " CACHE INTERNAL "" )
set(CMAKE_Fortran_FLAGS "-O2 -convert big_endian -free -assume byterecl -xHOST -fp-model strict -traceback " CACHE INTERNAL "" )
elseif(GNUComp)
set(CMAKE_Fortran_FLAGS "-O2 -ffree-form " CACHE INTERNAL "" )
include_directories(${MPI_INCLUDE_PATH}/gfortran/8.2.0 )
elseif(PGIComp)
else()
message("unkown compiler!")
exit()
endif()
endif()
set(LIBNAME ${CMAKE_PROJECT_NAME}_${VERSION})
#file(GLOB LIB_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/*.f90 )
file(GLOB LIB_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/module_fv3gfs_ncio.f90 )
add_definitions( ${CMAKE_Fortran_FLAGS} )
add_library(${LIBNAME} STATIC ${LIB_SRC} )
set(CMAKE_INCLUDE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/include")
set_target_properties(${LIBNAME} PROPERTIES Fortran_MODULE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/include")
target_include_directories(${LIBNAME} PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/include" ${NETCDF_INCLUDE} )
target_link_libraries(${LIBNAME} ${NETCDF_LIBRARY} )
file(MAKE_DIRECTORY ${CMAKE_INCLUDE_OUTPUT_DIRECTORY})
install(TARGETS ${LIBNAME}
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
install(DIRECTORY ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}/ DESTINATION include )