esmf-org / esmf

The Earth System Modeling Framework (ESMF) is a suite of software tools for developing high-performance, multi-component Earth science modeling applications.
https://earthsystemmodeling.org/
Other
149 stars 70 forks source link

Update FindESMF.cmake to make ESMF::ESMF main target #226

Closed mathomp4 closed 3 months ago

mathomp4 commented 5 months ago

As detailed in #225, our UFS collaborators would like MAPL to provide a MAPL-targets.cmake file that uses ESMF::ESMF as the target within. From my testing, this can only seem to work if ESMF::ESMF is the main target provided by FindESMF.cmake and not an ALIAS.

So this PR does that, it essentially makes ESMF::ESMF the target the "main" add_library() call is run on and then makes ESMF the alias.

As far as I can tell, this works. All other needed changes are in GEOS and MAPL.

danrosen25 commented 4 months ago

Change requested broke the UFS build

ld: cannot find -lesmf
make[5]: *** [sorc/sfc_climo_gen.fd/CMakeFiles/sfc_climo_gen.dir/build.make:101: sorc/sfc_climo_gen.fd/sfc_climo_gen] Error 1
make[4]: *** [CMakeFiles/Makefile2:1401: sorc/sfc_climo_gen.fd/CMakeFiles/sfc_climo_gen.dir/all] Error 2
make[4]: *** Waiting for unfinished jobs....
mathomp4 commented 4 months ago

Change requested broke the UFS build

ld: cannot find -lesmf
make[5]: *** [sorc/sfc_climo_gen.fd/CMakeFiles/sfc_climo_gen.dir/build.make:101: sorc/sfc_climo_gen.fd/sfc_climo_gen] Error 1
make[4]: *** [CMakeFiles/Makefile2:1401: sorc/sfc_climo_gen.fd/CMakeFiles/sfc_climo_gen.dir/all] Error 2
make[4]: *** Waiting for unfinished jobs....

Well, huh. We might need to ask @AlexanderRichert-NOAA for some advice and help...

danrosen25 commented 4 months ago

I'm testing some more scenarios. Not every FindESMF.cmake file within the ufs-weather-model was consistent. It's possible that I clobbered a FindESMF.cmake file that was customized for a component. I would like to figure this out before making changes to the default library name of ESMF.

mathomp4 commented 4 months ago

I'm testing some more scenarios. Not every FindESMF.cmake file within the ufs-weather-model was consistent. It's possible that I clobbered a FindESMF.cmake file that was customized for a component. I would like to figure this out before making changes to the default library name of ESMF.

In GEOS one thing I've had to do (locally) is add aliases for esmf as well. But that was due to a long-ago choice local to us. Maybe UFS will need to move to ESMF::ESMF internally with this change? I am not sure.

I know from spack testing that if you build with spack, it doesn't seem to matter how many other FindESMF.cmake files I have around in GEOS, the one from the ESMF install wins!

danrosen25 commented 4 months ago

The issue is related to changing one of these three modules, which are already outdated.

I was able to build the ufs-weather-model with this newer version of the FindESMF module.

mathomp4 commented 4 months ago

Please copy these changes to the following files:

  • src/addon/ESMX/Comps/ESMX_Data/cmake/FindESMF.cmake
  • src/addon/ESMX/Driver/cmake/FindESMF.cmake

This should be done.