Update version info for release v4.6.1 (#2122)
[WRF.git] / frame / CMakeLists.txt
blob4543c4694e2e791ae4927090ebf1e6b949355f7a
1 # WRF CMake Build
3 get_filename_component( FOLDER_COMPILE_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME)
4 set( 
5     WRF_INCLUDE_FILES
6     module_internal_header_util.F
7     ${CMAKE_BINARY_DIR}/frame/module_state_description.F
8     )
11 ########################################################################################################################
12 # Extra stuff for things that depend on registry code
13 # https://stackoverflow.com/a/50640971
14 # Generate all the combinations dynamically, not a fan of this file breakdown
15 ########################################################################################################################
16 set( nl_dyn_source )
17 foreach( n RANGE 0 7 )
18   
19   wrf_c_preproc_fortran( 
20                         TARGET_NAME     nl_set_${n}
21                         OUTPUT_DIR      ${CMAKE_CURRENT_BINARY_DIR}/preproc/
22                         EXTENSION       ".f90"
23                         PREFIX          "nl_set_${n}_"
24                         INCLUDES        ${CMAKE_CURRENT_SOURCE_DIR}
25                                         ${CMAKE_BINARY_DIR}/inc
26                         DEPENDENCIES    registry_code
27                         DEFINITIONS     ${PROJECT_COMPILE_DEFINITIONS} NNN=${n} NL_set_ROUTINES
28                         SOURCES         nl_access_routines.F
29                         )
30   wrf_c_preproc_fortran( 
31                       TARGET_NAME     nl_get_${n}
32                       OUTPUT_DIR      ${CMAKE_CURRENT_BINARY_DIR}/preproc/
33                       EXTENSION       ".f90"
34                       PREFIX          "nl_get_${n}_"
35                       INCLUDES        ${CMAKE_CURRENT_SOURCE_DIR}
36                                       ${CMAKE_BINARY_DIR}/inc
37                       DEPENDENCIES    registry_code
38                       DEFINITIONS     ${PROJECT_COMPILE_DEFINITIONS} NNN=${n} NL_get_ROUTINES
39                       SOURCES         nl_access_routines.F
40                       )
42   add_dependencies( ${PROJECT_NAME}_Core nl_get_${n} nl_set_${n} )
44   list(
45         APPEND
46         nl_dyn_source
47         ${CMAKE_CURRENT_BINARY_DIR}/preproc/nl_set_${n}_nl_access_routines.f90
48         ${CMAKE_CURRENT_BINARY_DIR}/preproc/nl_get_${n}_nl_access_routines.f90
49         )
51 endforeach()
53 if ( ${USE_M4} )
54   wrf_m4_preproc_fortran( 
55                           TARGET_NAME     md_calls
56                           OUTPUT_DIR      ${CMAKE_CURRENT_BINARY_DIR}/preproc/
57                           EXTENSION       ".inc"
58                           SOURCES         md_calls.m4
59                           TARGET_SCOPE    ${PROJECT_NAME}_Core
60                           FLAGS           ${M4_FLAGS}
61                           )
62   
63 else()
64   # Copy from arch quickly
65   # Normally I would say we just add it as source but it is an include file and I don't want to potentially 
66   # pollute the include chain by adding in arch/ *and* I want to maintain the order of operations
67   # for target dependencies
68   wrf_copy_source_files(
69                         TARGET_NAME     md_calls
70                         OUTPUT_DIR      ${CMAKE_CURRENT_BINARY_DIR}/preproc/
71                         SOURCES         ${PROJECT_SOURCE_DIR}/arch/md_calls.inc
72                         )
73 endif()
75 add_dependencies( ${PROJECT_NAME}_Core md_calls )
76 target_include_directories(
77                             ${PROJECT_NAME}_Core
78                             PRIVATE
79                               ${CMAKE_CURRENT_BINARY_DIR}/preproc/
80                             )
81 ########################################################################################################################
83 # Now define base framework
85 ########################################################################################################################
86 set( MODULE_DM module_dm_stubs.F )
87 if ( ${USE_RSL_LITE} )
88   message( STATUS "Setting module_dm to RSL_LITE" )
89   set(
90       MODULE_DM
91       ${PROJECT_SOURCE_DIR}/external/RSL_LITE/module_dm.F
92       ${PROJECT_SOURCE_DIR}/external/RSL_LITE/feedback_domain_em_part1.F
93       ${PROJECT_SOURCE_DIR}/external/RSL_LITE/feedback_domain_em_part2.F
94       ${PROJECT_SOURCE_DIR}/external/RSL_LITE/force_domain_em_part2.F
95       ${PROJECT_SOURCE_DIR}/external/RSL_LITE/interp_domain_em_part1.F
96       ${PROJECT_SOURCE_DIR}/external/RSL_LITE/interp_domain_em_part2.F
97       ${PROJECT_SOURCE_DIR}/external/RSL_LITE/interp_domain_em_part3.F
98       ${PROJECT_SOURCE_DIR}/external/RSL_LITE/interp_domain_em_small.F
99       )
100 endif()
102 target_sources(
103                 ${PROJECT_NAME}_Core
104                 PRIVATE
105                   ${WRF_INCLUDE_FILES}
107                   module_configure.F
108                   module_driver_constants.F
109                   module_domain_type.F
110                   module_domain.F
111                   module_streams.F
112                   module_wrf_error.F
113                   module_machine.F
114                   module_timing.F
115                   # module_dm.F
116                   ${MODULE_DM}
117                   module_cpl.F
118                   module_cpl_oasis3.F
121                   ${nl_dyn_source}                                     # GENERATED
123                   clog.c
124                   collect_on_comm.c
125                   hires_timer.c
126                   libmassv.F
127                   
128                   module_clear_halos.F
129                   module_comm_dm.F
130                   module_comm_dm_0.F
131                   module_comm_dm_1.F
132                   module_comm_dm_2.F
133                   module_comm_dm_3.F
134                   module_comm_dm_4.F
135                   module_comm_nesting_dm.F
136                   
137                   
138                                     
139                   module_integrate.F
140                   
141                   module_io.F
142                   module_io_quilt.F
143                   
144                   module_nesting.F
145                   module_quilt_outbuf_ops.F
146                   module_sm.F
147                   module_tiles.F
148                   
149                   pack_utils.c
150                   wrf_debug.F
151                   wrf_num_bytes_between.c
152                   wrf_shutdown.F
153                   )
155 # Disable optimizations on these files always
156 set_source_files_properties(
157                             ${nl_dyn_source}
158                             PROPERTIES
159                             COMPILE_OPTIONS_OPTIMIZATION
160                               $<$<COMPILE_LANGUAGE:Fortran>:${WRF_FCNOOPT}>
161                             )
163 install( 
164         FILES       ${WRF_INCLUDE_FILES}
165         DESTINATION include/${FOLDER_COMPILE_TARGET}
166         )