View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0012442CMakeCMakepublic2011-09-02 16:202012-02-06 06:07
Reporterkhusmann 
Assigned ToDavid Cole 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionduplicate 
PlatformOSLinuxOS Version
Product VersionCMake-2-8 
Target VersionFixed in VersionCMake 2.8.6 
Summary0012442: find_library iterates through paths before names
Descriptionfind_library will check all the paths in its search before moving to the next name to check. I would expect it to work the opposite way: checking all the names before it moves to the next path. If the former detection scheme is intentional, it should be specified in the documentation.
Steps To ReproduceGiven a CMakeLists:
cmake_minimum_required(VERSION 2.8)
find_library(foo NAMES boost_system-mt boost_system HINTS /packages/boost/lib)
message(STATUS ${foo})

And if the following files exist:
/packages/boost/lib/libboost_system.so
/usr/lib/libboost_system-mt.so

It will find /usr/lib/libbost_system-mt.so instead of /packages/boost/lib/libboost_system.so as I would expect. (Because the directories in HINTS should be completely searched before system directories are)
TagsNo tags attached.
Attached Files

 Relationships
duplicate of 0010718closedKitware Robot FIND_XXX command results should be determined by whichever alternative name is highest on the SUPER_PATH 

  Notes
(0027322)
David Cole (manager)
2011-09-02 17:05

Resolving as duplicate. The duplicate bug also contains this link in a note that I added to it:

http://www.cmake.org/pipermail/cmake/2010-July/thread.html#38284 [^]

That very long mailing list discussion was all about whether or not (or how) we could possibly switch the existing behavior with the one that you are looking for.

One way for you to do this on your own is to split the call into multiple calls, and search all names in a single path before moving on to the next call that contains only the next path, and so on, for however many paths you have.

Please feel free, to re-open this issue if you disagree with the resolution, or if you think this case is significantly different than 0010718 (I think it's exactly the same issue...)

If you'd like to discuss things further, I'd recommend bringing it over to the CMake mailing list, where there is a wider audience of readers that may have some input or insight to share.
(0027324)
khusmann (reporter)
2011-09-02 17:42
edited on: 2011-09-02 17:43

Sorry for reopening (because yes, it is an exact duplicate), but I wanted to add this note before it's completely closed:

Your solution to split the call into multiple calls would work if I was just dealing with my own code, but the place where I need it resolved is in the FindBoost module. (And the problem probably affects other modules as well, like a FindPython module as demonstrated in the mailing list).

Because of this find_library bug, FindBoost can find the headers of one version of boost, but then use the libraries of a different version of boost. Should I report this instead as a bug for the FindBoost module?

As for a temporary fix, I suppose I could copy FindBoost.cmake into my project's cmake/modules dir and then modify it to split the call as you talk about, but that seems rather hack-ish. Is there another solution to this that I'm not seeing? If there's not an obvious answer here, I'll take it to the mailing list as you suggest.

(0027325)
David Cole (manager)
2011-09-02 17:49

Ask on the mailing list... Many more people familiar with FindBoost read that than read this...
(0028499)
David Cole (manager)
2012-02-06 06:07

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2011-09-02 16:20 khusmann New Issue
2011-09-02 17:00 David Cole Assigned To => David Cole
2011-09-02 17:00 David Cole Status new => assigned
2011-09-02 17:05 David Cole Note Added: 0027322
2011-09-02 17:05 David Cole Relationship added duplicate of 0010718
2011-09-02 17:05 David Cole Status assigned => resolved
2011-09-02 17:05 David Cole Fixed in Version => CMake 2.8.6
2011-09-02 17:05 David Cole Resolution open => duplicate
2011-09-02 17:42 khusmann Note Added: 0027324
2011-09-02 17:42 khusmann Status resolved => feedback
2011-09-02 17:42 khusmann Resolution duplicate => reopened
2011-09-02 17:43 khusmann Note Edited: 0027324
2011-09-02 17:49 David Cole Note Added: 0027325
2011-09-12 16:54 David Cole Status feedback => resolved
2011-09-12 16:54 David Cole Resolution reopened => duplicate
2012-02-06 06:07 David Cole Note Added: 0028499
2012-02-06 06:07 David Cole Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team