LHAPATH Fix, master branch (2023.06.20.)
Taught FindLhapdf.cmake
about the ATLAS specific data path. This is because to ensure that the order between the paths would be stable, all parts of $LHAPDF_DATA_PATH
and $LHAPATH
need to be defined in a single place, inside of the FindLhapdf.cmake
module.
Longer version: @ewelina made me aware that the order of paths in $LHAPATH
is different between Athena,master,latest
and AthGeneration,master,latest
. It took a bit of investigation to understand the exact reason for this, but I believe I now do...
Currently $LHAPATH
is set up from 2 different places:
- https://gitlab.cern.ch/atlas/atlasexternals/-/blob/master/Build/AtlasLCG/modules/FindLhapdf.cmake
- https://gitlab.cern.ch/atlas/athena/-/blob/master/Generators/Superchic_i/SuperchicEnvironmentConfig.cmake
The way that environment variables are set up in AtlasLCG is that at the end of configuring a project, we ask the PACKAGES_FOUND global property of CMake for the full list of "packages" that were found by the project.
Then we iterate over these one-by-one, and collect the environment settings out of all of them.
As I now learned, the order of packages in this list is not "first seen, first in" as I thought previously, but rather "last seen, last in". I.e. if the project configuration comes across the previous two modules in the following order:
find_package(Lhapdf)
find_package(SuperchicEnvironment)
find_package(Lhapdf)
, then during the environment setup script generation these modules are listed in the SuperchicEnvironment
, Lhapdf
order. And I don't see a way of changing this.
As it happens, when configuring AthGeneration
, it is find_package(SuperchicEnvironment)
that is seen last by CMake before the environment generation is started. But when configuring Athena
, it is instead find_package(Lhapdf)
. (Athena
includes a few more packages that need LHAPDF, and those are processed after the generator packages.)
With all this in mind I still pondered for a bit about how to solve things, but in the end had to conclude that the only reliable setup is if the $LHAPATH
environment variable's setup is not left up to two separate modules. Instead every element of $LHAPATH
would have to be set up in a single place. (Yes, mucking about with PREPEND
and APPEND
could've fixed the issue for now, but I just didn't like the fragility of that setup.)
Very long story short, when this update is collected into atlas/athena, we will need to simplify https://gitlab.cern.ch/atlas/athena/-/blob/master/Generators/Superchic_i/SuperchicEnvironmentConfig.cmake at the same time.