Skip to content

Commit

Permalink
Move internal flags and compile definitions to variables rather than …
Browse files Browse the repository at this point in the history
…applied globablly
  • Loading branch information
islas committed Apr 24, 2024
1 parent b7f31dc commit e909e57
Show file tree
Hide file tree
Showing 11 changed files with 228 additions and 178 deletions.
357 changes: 196 additions & 161 deletions CMakeLists.txt

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion chem/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,17 @@ target_link_libraries(
convert_emiss
PRIVATE
${PROJECT_NAME}_Core
)
)

target_compile_options(
convert_emiss
PRIVATE
${PROJECT_COMPILE_OPTIONS}
)


target_compile_definitions(
convert_emiss
PRIVATE
${PROJECT_COMPILE_DEFINITIONS}
)
4 changes: 4 additions & 0 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

# Always build

# Suffice it to say everything under this is WRF-specific while also being external
add_compile_options ( "${PROJECT_COMPILE_OPTIONS}" )
add_compile_definitions( "${PROJECT_COMPILE_DEFINITIONS}" )

add_subdirectory( io_int )
add_subdirectory( io_grib1 )
add_subdirectory( io_grib_share )
Expand Down
3 changes: 1 addition & 2 deletions external/io_adios2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ target_include_directories( ${FOLDER_COMPILE_TARGET}


# First preprocess
get_directory_property( DIR_DEFS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS )
get_target_property ( FOLDER_COMPILE_TARGET_INCLUDES ${FOLDER_COMPILE_TARGET} INCLUDE_DIRECTORIES )
wrf_c_preproc_fortran(
TARGET_NAME ${FOLDER_COMPILE_TARGET}_c_preproc_wrf_io
OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/preproc/
EXTENSION ".f90"
INCLUDES ${FOLDER_COMPILE_TARGET_INCLUDES}
DEFINITIONS ${DIR_DEFS}
DEFINITIONS ${PROJECT_COMPILE_DEFINITIONS}
SOURCES wrf_io.F90
)

Expand Down
3 changes: 1 addition & 2 deletions external/io_netcdf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,13 @@ target_include_directories(


# First preprocess
get_directory_property( DIR_DEFS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS )
get_target_property ( FOLDER_COMPILE_TARGET_INCLUDES ${FOLDER_COMPILE_TARGET} INCLUDE_DIRECTORIES )
wrf_c_preproc_fortran(
TARGET_NAME ${FOLDER_COMPILE_TARGET}_c_preproc_wrf_io
OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/preproc/
EXTENSION ".f90"
INCLUDES ${FOLDER_COMPILE_TARGET_INCLUDES}
DEFINITIONS ${DIR_DEFS}
DEFINITIONS ${PROJECT_COMPILE_DEFINITIONS}
SOURCES wrf_io.F90
)

Expand Down
3 changes: 1 addition & 2 deletions external/io_netcdfpar/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,13 @@ target_include_directories(


# First preprocess
get_directory_property( DIR_DEFS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS )
get_target_property ( FOLDER_COMPILE_TARGET_INCLUDES ${FOLDER_COMPILE_TARGET} INCLUDE_DIRECTORIES )
wrf_c_preproc_fortran(
TARGET_NAME ${FOLDER_COMPILE_TARGET}_c_preproc_wrf_io
OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/preproc/
EXTENSION ".f90"
INCLUDES ${FOLDER_COMPILE_TARGET_INCLUDES}
DEFINITIONS ${DIR_DEFS}
DEFINITIONS ${PROJECT_COMPILE_DEFINITIONS}
SOURCES wrf_io.F90
)

Expand Down
3 changes: 1 addition & 2 deletions external/io_pnetcdf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@ target_include_directories( ${FOLDER_COMPILE_TARGET}


# First preprocess
get_directory_property( DIR_DEFS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS )
get_target_property ( FOLDER_COMPILE_TARGET_INCLUDES ${FOLDER_COMPILE_TARGET} INCLUDE_DIRECTORIES )
wrf_c_preproc_fortran(
TARGET_NAME ${FOLDER_COMPILE_TARGET}_c_preproc_wrf_io
OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/preproc/
EXTENSION ".f90"
INCLUDES ${FOLDER_COMPILE_TARGET_INCLUDES}
DEFINITIONS ${DIR_DEFS}
DEFINITIONS ${PROJECT_COMPILE_DEFINITIONS}
SOURCES wrf_io.F90
)

Expand Down
7 changes: 3 additions & 4 deletions frame/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ set(
# Generate all the combinations dynamically, not a fan of this file breakdown
########################################################################################################################
set( nl_dyn_source )
get_directory_property( DIR_DEFS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS )
foreach( n RANGE 0 7 )

wrf_c_preproc_fortran(
Expand All @@ -25,7 +24,7 @@ foreach( n RANGE 0 7 )
INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_BINARY_DIR}/inc
DEPENDENCIES registry_code
DEFINITIONS ${DIR_DEFS} NNN=${n} NL_set_ROUTINES
DEFINITIONS ${PROJECT_COMPILE_DEFINITIONS} NNN=${n} NL_set_ROUTINES
SOURCES nl_access_routines.F
)
wrf_c_preproc_fortran(
Expand All @@ -36,7 +35,7 @@ foreach( n RANGE 0 7 )
INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_BINARY_DIR}/inc
DEPENDENCIES registry_code
DEFINITIONS ${DIR_DEFS} NNN=${n} NL_get_ROUTINES
DEFINITIONS ${PROJECT_COMPILE_DEFINITIONS} NNN=${n} NL_get_ROUTINES
SOURCES nl_access_routines.F
)

Expand Down Expand Up @@ -166,4 +165,4 @@ set_source_files_properties(
install(
FILES ${WRF_INCLUDE_FILES}
DESTINATION include/${FOLDER_COMPILE_TARGET}
)
)
3 changes: 3 additions & 0 deletions main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# WRF CMake Build
set( FOLDER_COMPILE_TARGETS )

add_compile_options ( "${PROJECT_COMPILE_OPTIONS}" )
add_compile_definitions( "${PROJECT_COMPILE_DEFINITIONS}" )

# First make true executables
if ( ${WRF_CORE} STREQUAL "PLUS" )
add_executable(
Expand Down
3 changes: 1 addition & 2 deletions phys/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
# Quickly preprocess some files so that cmake can understand the module dependencies
#
########################################################################################################################
get_directory_property( DIR_DEFS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS )
wrf_c_preproc_fortran(
TARGET_NAME module_ra_rrtmg_preproc
OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/preproc/
EXTENSION ".f90"
INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDENCIES registry_code
DEFINITIONS ${DIR_DEFS}
DEFINITIONS ${PROJECT_COMPILE_DEFINITIONS}
SOURCES module_ra_rrtmg_lwk.F
module_ra_rrtmg_lwf.F
module_ra_rrtmg_swk.F
Expand Down
5 changes: 3 additions & 2 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# WRF CMake Build
add_compile_options ( "${PROJECT_COMPILE_OPTIONS}" )
add_compile_definitions( "${PROJECT_COMPILE_DEFINITIONS}" )

#!TODO ORGANIZE THIS FOLDER
set( FOLDER_COMPILE_TARGET registry )
Expand Down Expand Up @@ -99,10 +101,9 @@ elseif ( ${WRF_CORE} STREQUAL "DA" OR ${WRF_CORE} STREQUAL "DA_4D_VAR" )

endif()

get_directory_property( DIR_DEFS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS )
wrf_expand_definitions(
RESULT_VAR REGISTRY_DEFS
DEFINITIONS ${DIR_DEFS}
DEFINITIONS ${PROJECT_COMPILE_DEFINITIONS}
)

# How this is not a bigger thing or not resolved is beyond me
Expand Down

0 comments on commit e909e57

Please sign in to comment.