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

Cleanup CCPP cmake build #383

Merged
merged 7 commits into from
Sep 15, 2021
12 changes: 8 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
branch = dev/emc
[submodule "ccpp/framework"]
path = ccpp/framework
url = https://github.com/NCAR/ccpp-framework
branch = main
#url = https://github.com/NCAR/ccpp-framework
#branch = main
url = https://github.com/climbfuji/ccpp-framework
branch = ccpp_cmake_cleanup
[submodule "ccpp/physics"]
path = ccpp/physics
url = https://github.com/NCAR/ccpp-physics
branch = main
#url = https://github.com/NCAR/ccpp-physics
#branch = main
url = https://github.com/climbfuji/ccpp-physics
branch = ccpp_cmake_cleanup
18 changes: 3 additions & 15 deletions ccpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ project(CCPP-FV3
LANGUAGES C CXX Fortran)
set(PROJECT "CCPP-FV3")

# Attempt to add link library "NetCDF::NetCDF_Fortran" to target "ccppphys"
# which is not built in this directory.
cmake_policy(SET CMP0079 NEW)

#------------------------------------------------------------------------------
# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
Expand Down Expand Up @@ -94,12 +90,8 @@ endif()
# Build CCPP framework and physics

add_subdirectory(framework)

add_subdirectory(physics)
add_dependencies(ccppphys ccpp)
target_link_libraries(ccppphys PUBLIC w3nco::w3nco_d NetCDF::NetCDF_Fortran)
# This should not be necessary once framework and physics targets define BUILD_INTERFACE
target_include_directories(ccppphys PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/framework/src)
add_dependencies(ccpp_physics ccpp_framework)

#------------------------------------------------------------------------------
# Build fv3ccpp
Expand All @@ -124,16 +116,12 @@ add_library(
set_property(SOURCE driver/GFS_diagnostics.F90 APPEND_STRING PROPERTY COMPILE_FLAGS "-O0")


target_link_libraries(fv3ccpp PUBLIC ccpp)
target_link_libraries(fv3ccpp PUBLIC ccppphys)
target_link_libraries(fv3ccpp PUBLIC ccpp_framework)
target_link_libraries(fv3ccpp PUBLIC ccpp_physics)

if(OPENMP)
target_link_libraries(fv3ccpp PUBLIC OpenMP::OpenMP_Fortran)
endif()

# This should not be necessary once framework and physics targets define BUILD_INTERFACE
target_include_directories(fv3ccpp PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/framework/src
${CMAKE_CURRENT_BINARY_DIR}/physics)

set_target_properties(fv3ccpp PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)
target_include_directories(fv3ccpp PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>)
2 changes: 1 addition & 1 deletion ccpp/framework
Submodule framework updated 2 files
+6 −30 CMakeLists.txt
+11 −11 src/CMakeLists.txt
2 changes: 1 addition & 1 deletion ccpp/physics
Submodule physics updated 1 files
+16 −41 CMakeLists.txt