Update version info for release v4.6.1 (#2122)
[WRF.git] / external / io_netcdfpar / CMakeLists.txt
blob91a57f366565865fbfc9ad30c98d38c6d35d9d47
1 # WRF CMake Build
3 get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME)
5 add_library(
6             ${FOLDER_COMPILE_TARGET}
7               STATIC
8               )
10 # Do this first to simplify steps later
11 set_target_properties( 
12                       ${FOLDER_COMPILE_TARGET} 
13                         PROPERTIES
14                           Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${FOLDER_COMPILE_TARGET}
15                           EXPORT_PROPERTIES        Fortran_MODULE_DIRECTORY
16                       )
19 target_link_libraries(
20                       ${FOLDER_COMPILE_TARGET}
21                         PUBLIC
22                           $<$<BOOL:${USE_OPENMP}>:$<TARGET_NAME_IF_EXISTS:OpenMP::OpenMP_Fortran>>
23                           $<$<BOOL:${USE_MPI}>:$<TARGET_NAME_IF_EXISTS:MPI::MPI_Fortran>>
24                           netCDF::netcdff
25                       )
28 target_include_directories(
29                             ${FOLDER_COMPILE_TARGET}
30                             PUBLIC
31                               $<TARGET_PROPERTY:${FOLDER_COMPILE_TARGET},Fortran_MODULE_DIRECTORY>
32                               $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/external/ioapi_share>
33                               $<INSTALL_INTERFACE:include/external/ioapi_share>
34                             PRIVATE
35                               ${CMAKE_CURRENT_SOURCE_DIR}
36                             )
39 # First preprocess
40 get_target_property   ( FOLDER_COMPILE_TARGET_INCLUDES ${FOLDER_COMPILE_TARGET} INCLUDE_DIRECTORIES )
41 wrf_c_preproc_fortran( 
42                         TARGET_NAME     ${FOLDER_COMPILE_TARGET}_c_preproc_wrf_io
43                         OUTPUT_DIR      ${CMAKE_CURRENT_BINARY_DIR}/preproc/
44                         EXTENSION       ".f90"
45                         INCLUDES        ${FOLDER_COMPILE_TARGET_INCLUDES}
46                         DEFINITIONS     ${PROJECT_COMPILE_DEFINITIONS}
47                         SOURCES         wrf_io.F90
48                         )
50 # Now M4 preprocess
51 wrf_m4_preproc_fortran( 
52                         TARGET_NAME     ${FOLDER_COMPILE_TARGET}_m4_preproc_wrf_io
53                         OUTPUT_DIR      ${CMAKE_CURRENT_BINARY_DIR}/preproc/
54                         PREFIX          "m4_preproc_"
55                         EXTENSION       ".f90"
56                         SOURCES         ${CMAKE_CURRENT_BINARY_DIR}/preproc/wrf_io.f90
57                         DEPENDENCIES    ${FOLDER_COMPILE_TARGET}_c_preproc_wrf_io
58                         TARGET_SCOPE    ${FOLDER_COMPILE_TARGET}
59                         FLAGS           ${M4_FLAGS}
60                         )
62 add_dependencies( ${FOLDER_COMPILE_TARGET} ${FOLDER_COMPILE_TARGET}_m4_preproc_wrf_io )
64 target_sources(
65                 ${FOLDER_COMPILE_TARGET}
66                 PRIVATE
67                   ${CMAKE_CURRENT_BINARY_DIR}/preproc/m4_preproc_wrf_io.f90
68                   module_wrfsi_static.F90
69                   field_routines.F90
70                   )
72 # Now build diffwrf
73 set( DIFFWRF_TARGET diffwrf_ncpar )
74 add_executable(
75                 ${DIFFWRF_TARGET}
76                 diffwrf.F90
77                 ${PROJECT_SOURCE_DIR}/frame/clog.c
78                 ${PROJECT_SOURCE_DIR}/frame/module_wrf_error.F
79                 ${PROJECT_SOURCE_DIR}/frame/wrf_debug.F
80                 )
82 target_link_libraries(
83                       ${DIFFWRF_TARGET}
84                         PRIVATE
85                           ${FOLDER_COMPILE_TARGET}
86                       )
87 set_target_properties( 
88                       ${DIFFWRF_TARGET}
89                         PROPERTIES
90                           # Just dump everything in here
91                           Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/modules/${DIFFWRF_TARGET}
92                           Fortran_FORMAT           FREE
93                       )
96 install(
97         TARGETS ${FOLDER_COMPILE_TARGET} ${DIFFWRF_TARGET}
98         EXPORT  ${EXPORT_NAME}Targets
99         RUNTIME DESTINATION bin/
100         ARCHIVE DESTINATION lib/
101         LIBRARY DESTINATION lib/
102         )