MantisBT - CMake
View Issue Details
0012866CMakeCMakepublic2012-01-09 16:012016-06-10 14:31
manday 
Kitware Robot 
normalminoralways
closedmoved 
CMake 2.8.7 
 
0012866: find_library, find_path et al should check (user provided) path
find_library, find_path and similar commands (are there any others, judge for yourself) should, if the user provided a path, check whether this path fulfils the requirements, id est,

whether it contains the specified file for find_path
whether it is the specified library for find_library

if the given path is found invalid, normal search is performed and -NOTFOUND set as usual, if the library could not be found.

To implement this consistently, the user provided path should simply serve as a Path-Hint for the next time find_* is invoked.
No tags attached.
Issue History
2012-01-09 16:01mandayNew Issue
2012-01-09 16:35James BiglerNote Added: 0028220
2012-01-09 16:37Eric NOULARDNote Added: 0028221
2012-01-10 08:29mandayNote Added: 0028225
2012-01-10 08:47Eric NOULARDNote Added: 0028229
2012-08-11 21:09David ColeStatusnew => backlog
2012-08-11 21:09David ColeNote Added: 0030350
2016-06-10 14:28Kitware RobotNote Added: 0041961
2016-06-10 14:28Kitware RobotStatusbacklog => resolved
2016-06-10 14:28Kitware RobotResolutionopen => moved
2016-06-10 14:28Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0028220)
James Bigler   
2012-01-09 16:35   
Are you wanting the user specified path to be searched before any system paths? From what I understand in the documentation, these paths are searched third.

In my own projects to get my path searched first I have to issue the find_* command twice, with the first time with NO_DEFAULT_PATH specified to guarantee that only my path will be searched (see the find_library_local_first macro in Modules/FindCUDA.cmake -- I know, I know. I should have prefixed that macro with something. I didn't realize it at the time).
(0028221)
Eric NOULARD   
2012-01-09 16:37   
Could you provide two example of use?
The first corresponding to what you do now.
The second one corresponding to what you expect to be able to do.

What do you mean by
> if the user provided a path
??

Provided a path as an argument of which options of find_path/find_library?

Did you read the full documentation of e.g. find_path
cmake --help-command find_path

There is already many ways for the user to specify preferred PATH
search using HINTS, PATH (with ENV variant) and
NO_xxx_PATH options as well.

I suggest you propose such feature on the Mailing List before filing
a new feature request. It's easier to discuss and avoid bug entries
inflation.
(0028225)
manday   
2012-01-10 08:29   
James Bigler, you are correct, user provided paths (id est HINTS and PATHS) are searched after a couple of default places. This does not agree with the part of my proposal where I suggest how to implement it consistently and easily.

In fact, the search order as specified in the documentation must be changed to (e.g. find_path)...

1. Search the file in the path the variable currently points to
2. ...
3. ...

Eric Noulard, if the above doesn't explain it well enough, let me know and I'll be more verbose. Basically, what I'm saying, axiomatically, is that

"On every configure (run of cmake) find_path (say) should search for the desired item and set the variable to -NOTFOUND if it does not succeed. If the variable is already cached, it should try the value of the variable first, before doing the search as it is currently specified".

I discussed the feature on IRC before filing this bug.
(0028229)
Eric NOULARD   
2012-01-10 08:47   
As noted by Michael on the mailing list
http://www.cmake.org/pipermail/cmake/2012-January/048517.html [^]

You can use CMAKE_PREFIX_PATH in order to indicate that you want
a particular path first.

> Eric Noulard, if the above doesn't explain it well enough, let me know and I'll be more verbose

Verbosity wasn't my issue. I would rather have a simple example project
with the appropriate find_... calls.

> On every configure (run of cmake) find_path (say) should search for the desired item and set the variable to -NOTFOUND if it does not succeed.

Unless I'm wrong this is the current behavior.

> If the variable is already cached, it should try the value of the variable first

From the find_path doc I read:
"Once one of the calls succeeds the result variable will be set and
       stored in the cache so that no call will search again."

so the difference here is that whenever a variable is cached there won't be
any search at all.

Would you like to change this?

> I discussed the feature on IRC before filing this bug.

Ok sorry about that I'm not on IRC.

> James Bigler, you are correct, user provided paths (id est HINTS and PATHS) are searched after a couple of default places. This does not agree with the part of my proposal where I suggest how to implement it consistently and easily

James's usage is explicitely documented in the doc:
"The default search order is designed to be most-specific to
       least-specific for common use cases. Projects may override the order
       by simply calling the command multiple times and using the NO_*
       options:

          find_path(<VAR> NAMES name PATHS paths... NO_DEFAULT_PATH)
          find_path(<VAR> NAMES name)
"

So unless I'm wrong you have all needed feature to implement a custom macro
that will have your wanted behavior.

I may be wrong but changing the default search path behavior of find_xxx
will certainly hard while maintaining backward compatibility.
(0030350)
David Cole   
2012-08-11 21:09   
Sending old, never assigned issues to the backlog.

(The age of the bug, plus the fact that it's never been assigned to anyone means that nobody is actively working on it...)

If an issue you care about is sent to the backlog when you feel it should have been addressed in a different manner, please bring it up on the CMake mailing list for discussion. Sign up for the mailing list here, if you're not already on it: http://www.cmake.org/mailman/listinfo/cmake [^]

It's easy to re-activate a bug here if you can find a CMake developer who has the bandwidth to take it on, and ferry a fix through to our 'next' branch for dashboard testing.
(0041961)
Kitware Robot   
2016-06-10 14:28   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.