-
Notifications
You must be signed in to change notification settings - Fork 371
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
CMake: Improve dependency management for mct and csm_share #5964
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly good. I have some suggestions, you can decide what's worth adding.
Btw, are you thinking of changing share/util/CMakeLists.txt
to actually be a cmake project, rather than whatever it is now?
add_library(mct INTERFACE) | ||
target_link_libraries(mct INTERFACE ${MCT_LIB} ${MPEU_LIB}) | ||
target_include_directories(mct INTERFACE ${INSTALL_SHAREDPATH}/include) | ||
target_compile_definitions(mct INTERFACE "MCT_INTERFACE") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I grepped for MCT_INTERFACE
in the whole repo+submodules, and I can't see where it is used. I see it set in the CPPDEFS var, but never used. Maybe we can get rid of this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also not sure where this is use but there is code in CIME to allow MCT or MOAB to be used as the coupler. We need to keep that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean we need to keep ability to use MOAB, not "keep MCT_INTERFACE in CPPDEFS", right?
Also, is there an example in e3sm of a compset using moab instead of mct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that's what I mean.
Its not in master yet but you can run a moab case on this branch (on Chrysalis only for now) https://github.com/sarich/E3SM/tree/sarich/moab/update-moab-driver
e.g. ./create_test SMS_Vmoab.ne4pg2_oQU480.WCYCL1850NS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MCT_INTERFACE
does not appear to be used in CIME either, but there's not much harm in keeping it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imho, if something is unused (and pointless), it should be removed. Pointless code tends to pile up, until we have no idea of what is actually needed/used. I vote for pruning it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you are right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rljacob , I looked at Sarich's Moab branch and he's not using this cppdef there either.
Hmm, it looks like the CI build fails with a link error for the case it tries to build. The same case builds fine on mappy so I may have some digging to do. |
@@ -29,7 +29,7 @@ endif() | |||
|
|||
# Create the interface library, and set target properties | |||
add_library (csm_share INTERFACE) | |||
target_link_libraries (csm_share INTERFACE ${CSM_SHARE_LIB};mct;${PIOLIBS}) | |||
target_link_libraries (csm_share INTERFACE ${CSM_SHARE_LIB};mct;spio) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we maybe to the same thing we did for MCT also for spio? That is, adding
find_package(PIO)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, did exactly that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant adding it inside the FindCsmShare.cmake
module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see. Yes let me do that.
components/cmake/common_setup.cmake
Outdated
# Have to do this here for now because the macros must be loaded in order for | ||
# the netcdf cmake variables to be set. Once scorpio has a good package-config, | ||
# this won't be necessary | ||
if (NOT TARGET netcdf) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need this if guard. subsequent calls to find_package
will do nothing if the package was already found...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that depends on the implementation, but I'm not sure. I wanted to keep the findX modules as simple as possible, so they don't set or check XX_FOUND
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think CMake states it clearly
Once one of the calls succeeds the result variable will be set and stored in the cache so that no call will search again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That could be for find_package when it does things the "normal" way, IE loading the package-config.cmake. When you are rolling your own find module, I don't think this is true. The example FindXXX.cmake guidance in the documentation has all that stuff explicit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, no big deal. I think the logic for skipping second calls works regardless of search mode (provided that FindXXX.cmake sets <PackageName>_FOUND=TRUE
). But I am not entirely sure, so let's not stop progress based on this detail.
This ensures correct link order
CMake: Improve dependency management for mct and csm_share Neither of these packages are cmake packages, so we have to roll our own Find$package.cmake modules. These can be pretty simple for e3sm since we build them ourselves (no worries about version or not found etc). Also, remove a lot of unused for special handling of clm and stuff for pio building. [BFB]
Second merge to next for this PR. [BFB]
Third merge to next for this PR. [BFB]
|
||
# Create the interface library, and set target properties | ||
add_library(netcdf INTERFACE) | ||
target_link_libraries(netcdf INTERFACE ${pnetcdf_lib};${netcdf_c_lib};${netcdf_f_lib}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
target_link_libraries(netcdf INTERFACE ${pnetcdf_lib};${netcdf_c_lib};${netcdf_f_lib}) | |
target_link_libraries(netcdf INTERFACE ${pnetcdf_lib};${netcdf_f_lib};${netcdf_c_lib}) |
Fourth merge to next for this PR. [BFB]
This will ensure correct link order
Fifth merge to next for this PR. [BFB]
This branch looks like it did a lot of work on the netcdf/pnetcdf dependency but that's not mentioned in the title or description. |
Neither of these packages are cmake packages, so we have to roll our own Find$package.cmake modules. These can be pretty simple for e3sm since we build them ourselves (no worries about version or not found etc).
Also, remove a lot of unused for special handling of clm and stuff for pio building.
[BFB]