-
Notifications
You must be signed in to change notification settings - Fork 7
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
Find modules should mainly require <Pkg>_DIR to be set #36
Comments
Environment variables such as |
Here's my comment to #33: The purpose is to make use of a good practice in how to write Find package modules and to reduce the number of variables and standardise the experience for a user for all packages. As CMake is very flexible and provides little guidelines on how to write a good Find package module, many people have done it differently. I claim that many Find modules you will find are not very user friendly for those not proficient with the internals/use of CMake. Even CMake's Find modules and find_package itself lack in this respect. Why do I have to set a bunch of variables for each project (e.g., include path AND location of each single library), just because I installed the package in a non-custom directory ? Why is it not enough to just tell CMake where my installation is located instead ? Next, when I want to change from one installed version to another installed in a different location, why do I have to change all those variables manually. Why is it not enough to change the location of the installation ? To standardise the finding of dependencies was part of the CMake BASIS project. In my experience with the research software we published, this has made it easier for non-CMake experts to build our code. For every dependency, I want the user to only have to specify the installation directory via a Using a
I have mentioned before that this doesn't help because I don't even want to configure and install Eigen. It is a header-only library. I doubt the source tree of Eigen already contains a usable CMake package Config file.
I don't think it has anything to do with shadowing. It is about having users not to be familiar with CMake and it's find_package command behavior. And as mentioned above, with a simple variable setting, the |
Maybe it would be good to take advantage of this refactoring period to use Basis in the IRTK build process. @schuhschuh do you think you could give us a crashcourse on that / help with the migration? I guess you're already using it in your fork/branches? |
I have started to work on this with Stefan in his GitLab repository, but it has never reached a point where all my development could take place. I haven't done it myself because it is only worth the effort if there is commitment towards using CMake BASIS for the official IRTK version. As from what I see, it would have a few advantages:
And, features I would more likely take time to finally realise when actually used:
Another feature of CMake BASIS which may be controversial and need not be adopted:
|
@jopasserat @schuhschuh I am happy to discuss usage of BASIS at some point but I feel we are drifting away from the initial issue that Andreas is raising, which is to use My answer is no for the following reasons:
I can understand why CMake did not bother trying to formalize this, they can't go on a quest to fix the install scripts of the whole dev community. And neither would I. I apologize for the dry tone but I really feel we are bikeshedding here. |
You're missing the point. It is not necessary that all packages follow the same installation scheme. It is about the Find modules written specifically for a package that should encapsulate that knowledge. The most common location every software has in common is the installation prefix (i.e. top-level directory of the installation).
At least for CMake before version 3, this definitely was not the case. Many of the Find modules used such variable themselves.
I couldn't disagree more. First of all, you assume that a user knows that such variable is only meant to be a path where a Config.cmake file is located. A user shouldn't know such thing, which isn't even true. CMake has no such mechanism of requiring that a variable of such name is only used like this.
Sure, one can consider it petty details. But it's the petty details for something as a project structure and build configuration how easy and reliable it is to build it from source code for non-software developers. IMHO the important aspect of packaging (the refactored) IRTK was it's build configuration (i.e., CMake stuff). I know it's not the most exciting for a software developer, but it can make a real difference for the user. Look at the current setup. When I configure IRTK, I am overwhelmed with dozens of CMake variables in my CMake GUI, hiding all the actually relevant things. Instead of a single variable for each package that is intuitive (not counter-intuitive as you say). Why would you think as somebody not using CMake for your own development that "IRTK_DIR" is supposed to point to "/usr/local/lib/cmake/IRTK" instead of "/usr/local", the CMAKE_INSTALL_PREFIX I had used to install it ? Why do I, as a user that tries to install some software have to know where each dependency hides it's CMake package Config file ? Or let's say I install software in |
That this statement is inexact and CMake itself is not consistent with respect to this can be easily seen from the following text you can look up in the documentation of find_package:
From this you should conclude that CMake interprets an environment variable such as In CMake BASIS, the use is consistent and intuitive for non-CMake users. Still, those familiar with CMake can as well point |
You have me lost complete attention to your points on the following occasions:
My point, priority should be put elsewhere.
He or she still has to know where this variable should point to regardless of the naming convention you are discussing.
I am not sure what this implies and I am not certain I want to know. Moving on.
So this is really what this issue is all about ? The number of variables is not pleasing to your eyes ? And last but definitely not least the piece of documentation you decided to partially quote. This whole section is meant to highlight usage of inhibition variables to let the user tweak the search paths for CMake config files / find modules:
An then each step highlighting which specific variable should be enabled:
The relevant piece of documentation you should be quoting is at the beginning and is the following:
I have no further interest in discussing this issue and would appreciate if contribution efforts were directed elsewhere. Thanks. |
Don't come like this. It's not about me or how pleasing I find it. Keep the user in mind. I have made some experience with users with publicly available research software as well as other researchers in two labs now. I am certain they would greatly appreciate if we would take such issue more serious.
Of course I post only the relevant part, to show you that
Fine. I might else well direct them towards my own fork. |
The following improvements were made: - Use same coding standards at Kitware/CMake. The goal is to manage to submit them upstream to limit maintenance. - Add support for custom install locations via ROOT envvars. - Add more helpful error output when an install of one of these dependencies is not found.
When the CMake
find_package
command runs in CONFIG mode, it adds a cache variable named<Pkg>_DIR
which points to the location of the package configuration file. This works of course only for packages that provide such CMake configuration file.Same should be the case for custom Find modules. Usually it would be sufficient if a user sets this variable to the prefix where the package is installed. All other paths should be derived from it and when cached, be declared as advanced variables unless a file/directory was not found. As soon as it is set, the variable can be hidden (again) by making it advanced. This reduces the number of non-advanced variables a user is required to set for all dependencies to be properly discovered. It also leaves a more common "experience" for a user, no matter if a custom Find module is used or not. All they have to do is make sure that the "_DIR" variables are set properly.
The text was updated successfully, but these errors were encountered: