Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change internal flag organization in CMake build to not be global #2053

Merged
merged 5 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
289 changes: 152 additions & 137 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}
)
)
2 changes: 2 additions & 0 deletions hydro/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# additions that WRF-Hydro's top CMakeLists.txt handles
add_compile_options( ${PROJECT_COMPILE_OPTIONS} )
add_compile_definitions( ${PROJECT_COMPILE_DEFINITIONS} )
set(CMAKE_Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/hydro/mods)
add_definitions(-DMPP_LAND)
if (WRF_HYDRO_NUDGING STREQUAL "1")
Expand Down
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 @@ -109,10 +111,9 @@ foreach( n RANGE 0 31 )

endforeach()

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