source: LMDZ6/branches/Amaury_dev/tools/netcdf95/CMakeLists.txt @ 5228

Last change on this file since 5228 was 4918, checked in by Laurent Fairhead, 7 months ago

Reintegrated NetCDF95 in LMDZ so that it is compiled and made available by the makelmdz_fcm script.
The makelmdz_fcm creates the libnetcdf95 library and copies it in the tools/netcdf/lib directory, copying
the mod files in the tools/netcdf/include library.

File size: 1.9 KB
Line 
1cmake_minimum_required(VERSION 3.16)
2list(APPEND CMAKE_MESSAGE_CONTEXT NetCDF95)
3set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build")
4project(NetCDF95 LANGUAGES Fortran C)
5enable_testing()
6list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
7set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release Profile)
8add_library(netcdf95 nf95_abort.f90 netcdf95.f90 nf95_def_dim.f90
9  nf95_inq_dimid.f90 nf95_inquire_dimension.f90 nf95_constants.f90
10  nc_constants.f90)
11add_subdirectory(Attributes)
12add_subdirectory(Datasets)
13add_subdirectory(Groups)
14add_subdirectory(Variables)
15set_target_properties(netcdf95 PROPERTIES Fortran_MODULE_DIRECTORY
16  ${PROJECT_BINARY_DIR}/modules)
17target_include_directories(netcdf95 PUBLIC
18  $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/modules>)
19
20if(CMAKE_Fortran_COMPILER_ID MATCHES NAG)
21  target_include_directories(netcdf95 PRIVATE ${CMAKE_CURRENT_LIST_DIR})
22endif()
23
24find_package(netCDF REQUIRED)
25find_package(NetCDF_Fortran REQUIRED)
26target_link_libraries(netcdf95 PUBLIC NetCDF_Fortran::netcdff
27  PRIVATE netCDF::netcdf)
28add_subdirectory(Tests)
29add_library(${PROJECT_NAME}::netcdf95 ALIAS netcdf95)
30configure_file(${PROJECT_NAME}Config.cmake.in ${PROJECT_NAME}Config.cmake @ONLY)
31
32# Start installation part
33
34if(CMAKE_Fortran_COMPILER_ID MATCHES GNU)
35  set(install_include_dir include)
36  install(FILES ${PROJECT_BINARY_DIR}/modules/netcdf95.mod TYPE INCLUDE)
37else()
38  set(install_include_dir include/${PROJECT_NAME})
39  install(DIRECTORY ${PROJECT_BINARY_DIR}/modules/ DESTINATION
40    ${install_include_dir})
41endif()
42
43install(TARGETS netcdf95 EXPORT ${PROJECT_NAME}Targets INCLUDES
44  DESTINATION ${install_include_dir})
45install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
46  DESTINATION lib/cmake/${PROJECT_NAME})
47install(EXPORT ${PROJECT_NAME}Targets DESTINATION
48  lib/cmake/${PROJECT_NAME} NAMESPACE ${PROJECT_NAME}::)
49
50# End installation part
51
52export(EXPORT ${PROJECT_NAME}Targets NAMESPACE ${PROJECT_NAME}::)
Note: See TracBrowser for help on using the repository browser.