-
Notifications
You must be signed in to change notification settings - Fork 45
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
Extend TriBITS TPL system to better accommodate Find<TPLNAME>.cmake modules #67
Comments
…SPub#59 and TriBITSPub#67) Now it only calls FIND_PACKAGE(HDF5 ...) when TPL_HDF5_INCLUDE_DIRS and TPL_HDF5_LIBRARIES are not set. This skips the find when there is an override. This will avoid some confusion I would think. I also added logic so FIND_PACKAGE(HDF5 ...) will to also find hdf5_fortran when HDF5_REQUIRE_FORTRAN is TRUE. This should match existing behavior perfectly when the user does not set any of the cache vars. The creates a better default find operation. This will get refactored more as part of TriBITS TriBITSPub#59 before it is finished.
…TSPub#67) See TriBITS TriBITSPub#67 for details.
…SPub#67) See TriBITS TriBITSPub#67 for details.
…riBITS TriBITSPub#59 and TriBITSPub#67) With this update, FindTPLHDF5.cmake should maintain good backward compatibility but will still call FIND_PACKAGE(HDF5 ...) by default if the user does nothing.
Now it only calls FIND_PACKAGE(HDF5 ...) when TPL_HDF5_INCLUDE_DIRS and TPL_HDF5_LIBRARIES and other TPL find variables are not set (see TriBITS #67). This skips the find when there is an override. This will avoid some confusion I would think. I also added logic so FIND_PACKAGE(HDF5 ...) will to also find hdf5_fortran when HDF5_REQUIRE_FORTRAN is TRUE. This should match existing behavior perfectly when the user does not set any of the cache vars. The creates a better default find operation. With this update, FindTPLHDF5.cmake should maintain good backward compatibility but will still call FIND_PACKAGE(HDF5 ...) by default if the user does nothing. Win win.
This as now been pushed to the master branch for the TriBITS repos on github and casl-dev and I snapshotted this to Trilinos in the commit:
Documentation on how to use FIND_PACKAGE() in a TriBITS TPL is shown online here. I am not super happy with that documentation but at least it is a start. I am sure we will find more issues as we extend other |
I am closing this story. Further improvements will be done offline. |
I tested this and it works, but I have to say that I dislike the magic that is behind Anyhow, can we apply the same logic to |
Nico, It is important to always call As for BLAS, LAPACK, and BOOST, yes, of course we can use the same approach. Feel free to follow the example in FindTPLHDF5.cmake and update these as well. As with HDF5, we need to make sure that existing overrides still hold. All we are doing is changing the default search. That might technically break backward compatibility as well but if the |
I don't really understand much of what comes after the
You say that that
With a structure like
it looks like I will move around the BLAS and LAPACK files just like that, but really I don't know what I'm doing. |
Yes, it is all based on variables and the behavior is unit tested to make sure it is correct. We just need to document this process a little better but what is described now here should be sufficient to help people use this. I know this is not ideal but this setup is the best I could do given the constraints (i.e. want a better default find but need to maintain the existing overrides to maintain backward compatibility and need to continue to support better uniform control for overrides) and the fact that CMake is not the most flexible language in existence.
I will take a look at the pull-request in a bit here. |
Could everything from |
It could be but it would make the code more complex IMHO, or at least more verbose and longer since you have to define the vars somehow if you call |
The reason why I'd prefer
over
is that, as a developer, the former gives you the guarantee that you don't need to fiddle with (Also, I think I didn't understand what you mean by
-- It's called once in any case, right?) |
…iBITS TriBITSPub#67) This should have *exactly* the same behavior as before but hopefully now will make it more clear what is happening and why.
@nschloe, take a look at updated |
This may not be ideal in Nico's eyes but it works. I am afraid that to clean this up more will require some refactoring (and unit testing) to change how the function TRIBITS_TPL_FIND_INCLUDE_DIRS_AND_LIBRARIES() works.
Hopefully this will be even a little more clear. I will now update the TriBITS docuemntation for this approach.
…iBITSPub#67) This structure meets Nico's approval. Hopefully this will be a little more clear when FIND_PACKAGE(<tplName> ...) gets called. I still need to write better documentation for how TRIBITS_TPL_FIND_INCLUDE_DIRS_AND_LIBRARIES() behaves. That will come later.
The current approach for utilizing Find.cmake modules (such as are shipped with CMake) is to call
FIND_PACKAGE(<TPLNAME>)
, then set the variablesTPL_<TPLNAME>_INCLUDE_DIRS
andTPL_<TPLNAME>_LIBRARIES
, then callTRIBITS_TPL_FIND_INCLUDE_DIRS_AND_LIBRARIES()
. The problem with this approach is that it bypasses the variables<TPLNAME>_INCLUDE_DIRS
and<TPL>_LIBRARY_NAMES
.To demonstrate the problem, in pull-request #59,
FIND_PACKAGE(HDF5)
only finds thehdf5
library and not the other libraries, for example, needed by CASL VERA which are specified with:Using
FIND_PACKAGE(HDF5)
bypasses the variablesHDF5_LIBRARY_NAMES
andHDF5_LIBRARY_DIRS
which are used to point to the desired libs, which include the extra libraries.To demonstrate this, I checked out the branch
findpackage-hdf5
for TriBITS for VERA and configured with:This showed in the configure output:
See, the problem is that the other required libraries
hdf5_hl
,hdf5_cpp
andhdf5_fortran
are not listed.When I tried to build this software, I got a bunch of link failures (as you would expect).
Now yes, you could manually set
TPL_<TPLNAME>_INCLUDE_DIRS
andTPL_<TPLNAME>_LIBRARIES
but that is very verbose and it would break a lot of configure scripts (most importantly, CASL VERA).What I would like to propose in this issue ticket is that we upgrade
TRIBITS_TPL_FIND_INCLUDE_DIRS_AND_LIBRARIES()
to allow it to take in defaults for the libraries and include directories (outputs fromFIND_PACKAGE(<TPLNAME>)
) but if the user sets the cache variables<TPLNAME>_INCLUDE_DIRS
,<TPL>_LIBRARY_NAMES
, or<TPL>_LIBRARY_DIRS
, then the standard existing search for libraries is used. So, you would writeFindTPLHDF5.cmake
like:What this does is it maintains the current behavior of the find module when any of the exist variables are set by the user but if none are set, then
FIND_PACKAGE(HDF5)
will be used instead. To support this mode and allow tweaking, the functionTRIBITS_TPL_ALLOW_PACKAGE_PREFIND()
which will be used like:The function
TRIBITS_TPL_ALLOW_PACKAGE_PREFIND()
should take into consideration:TPL_<TPLNAME>_INCLUDE_DIRS
orTPL_<TPLNAME>_LIBRARIES
is set, then returnFALSE
.<TPLNAME>_INCLUDE_DIRS
,<TPL>_LIBRARY_NAMES
, or<TPL>_LIBRARY_DIRS
is set and<TPLNAME>_FORCE_PACKAGE_PREFIND=FALSE
, then returnFALSE
.<TPLNAME>_INCLUDE_DIRS
,<TPL>_LIBRARY_NAMES
, or<TPL>_LIBRARY_DIRS
is set but<TPLNAME>_FORCE_PACKAGE_PREFIND=TRUE
, then returnTRUE
.Idea behind
<TPLNAME>_FORCE_PACKAGE_PREFIND
is to allow the user, or theFindTPL<TPNAME>.cmake
module itself, to always callFIND_PACKAGE(<TPLNAME> ...)
unlessTPL_<TPLNAME>_INCLUDE_DIRS
orTPL_<TPLNAME>_LIBRARIES
are set. The reason this is important is that the cache variable names<TPLNAME>_INCLUDE_DIRS
and<TPLNAME>_LIBRARY_DIRS
collide with the names used by many of the standardFind<TPLNAME>.cmake
modules, such as is the case with HDF5 (see above).Tasks:
TRIBITS_TPL_ALLOW_PACKAGE_PREFIND()
FindTPLHDF5.cmake
on the branchfindpackage-hdf5
to useTRIBITS_TPL_ALLOW_PACKAGE_PREFIND()
as shown above (and get it to findhdf5_fortran
when Fortran is enabled to keep backward compatibility).FindTPLHDF5.cmake
file on Trilinos and VERA to ensure correct behavior.findpackage-hdf5
into TriBITS github/master branch, snapshot to Trilinos, etc.The text was updated successfully, but these errors were encountered: