[CMake] find_package() Config mode iteration gravely broken (Mac OpenCV KISS installation fails)

Alexander Neundorf a.neundorf-work at gmx.net
Tue Apr 30 15:44:35 EDT 2013


On Tuesday 30 April 2013, Andreas Mohr wrote:
> Hi,
> 
> tried to grab OpenCV on Mac OS 10.6 (via standard macports install),
> expected it to be a walk in the park.
> Imagine my surprise when this failed persistently and stubbornly.
> 
> Turns out internet is full of reports of OpenCV Config failure
> (and, I have to say, the sufficiently condescending tone of OpenCV website
> and its non-editability (immutable page / restricted registration) DOES NOT
> HELP). And those multiple *contemporary* reports/comments (stack overflow)
> are SHOCKINGLY uninformed (even a 3 minute cross reading of the relevant
> docs would have told people that there's something other than Module mode
> only, yet everybody is raising the complaint that "there is no
> FindOpenCV.cmake"!).
> 
> 
> 
> minimum-code reproducer sample (executed on current CMake master):
> 
> find_package_opencv/CMakeLists.txt:
> 
> cmake_minimum_required(VERSION 2.6)
> 
> # Fully UNDOCUMENTED debug helper var (I'm going to correct this
> # in my next round of submissions):
> set(CMAKE_FIND_DEBUG_MODE 1)
> 
> project(find_package_opencv CXX)
> 
> # opensnoop -n -a marker helper:
> file(WRITE /tmp/PRE_FIND_PACKAGE_CALL "")
> 
> # Does not matter whether NO_MODULE is specified...
> find_package(OpenCV REQUIRED NO_MODULE)
> 
> 
> 
> $ cmake ../find_package_opencv
> Checking framework prefix [/opt/local/]
> Consider /opt/local
> Consider /opt/local
> Consider /opt/local
> Consider /opt/local
> Checking framework prefix [/sw/]
> Consider /sw
> Consider /sw
> Consider /sw
> Consider /sw
> Checking framework prefix [/usr/]
> Consider /usr
> Consider /usr
> Consider /usr
> Consider /usr
> Checking framework prefix [/]
> Consider
> Consider
> Consider
> Consider
> Checking framework prefix [/usr/local/]
> Consider /usr/local
> Consider /usr/local
> Consider /usr/local
> Consider /usr/local
> Checking framework prefix [/usr/X11/]
> Consider /usr/X11
> Consider /usr/X11
> Consider /usr/X11
> Consider /usr/X11
> Checking framework prefix [/Users/USERNAME/Library/Frameworks/]
> Consider /Users/USERNAME/Library/Frameworks
> Consider /Users/USERNAME/Library/Frameworks
> Consider /Users/USERNAME/Library/Frameworks
> Consider /Users/USERNAME/Library/Frameworks
> Checking framework prefix [/Library/Frameworks/]
> Consider /Library/Frameworks
> Consider /Library/Frameworks
> Consider /Library/Frameworks
> Consider /Library/Frameworks
> Checking framework prefix [/Network/Library/Frameworks/]
> Consider /Network/Library/Frameworks
> Consider /Network/Library/Frameworks
> Consider /Network/Library/Frameworks
> Consider /Network/Library/Frameworks
> Checking framework prefix [/System/Library/Frameworks/]
> Consider /System/Library/Frameworks
> Consider /System/Library/Frameworks
> Consider /System/Library/Frameworks
> Consider /System/Library/Frameworks
> Checking framework prefix [/Applications/]
> Consider /Applications
> Consider /Applications
> Consider /Applications
> Consider /Applications
> Checking framework prefix [/Developer/Applications/]
> Consider /Developer/Applications
> Consider /Developer/Applications
> Consider /Developer/Applications
> Consider /Developer/Applications
> Checking bundle prefix [/opt/local/]
> Consider /opt/local
> Consider /opt/local
> Checking bundle prefix [/sw/]
> Consider /sw
> Consider /sw
> Checking bundle prefix [/usr/]
> Consider /usr
> Consider /usr
> Checking bundle prefix [/]
> Consider
> Consider
> Checking bundle prefix [/usr/local/]
> Consider /usr/local
> Consider /usr/local
> Checking bundle prefix [/usr/X11/]
> Consider /usr/X11
> Consider /usr/X11
> Checking bundle prefix [/Users/USERNAME/Library/Frameworks/]
> Consider /Users/USERNAME/Library/Frameworks
> Consider /Users/USERNAME/Library/Frameworks
> Checking bundle prefix [/Library/Frameworks/]
> Consider /Library/Frameworks
> Consider /Library/Frameworks
> Checking bundle prefix [/Network/Library/Frameworks/]
> Consider /Network/Library/Frameworks
> Consider /Network/Library/Frameworks
> Checking bundle prefix [/System/Library/Frameworks/]
> Consider /System/Library/Frameworks
> Consider /System/Library/Frameworks
> Checking bundle prefix [/Applications/]
> Consider /Applications
> Consider /Applications
> Checking bundle prefix [/Developer/Applications/]
> Consider /Developer/Applications
> Consider /Developer/Applications
> Checking prefix [/opt/local/]
> CheckDirectory (dir /opt/local/, suffix , d /opt/local/)
> FindConfigFile #2
> Checking file [/opt/local/OpenCVConfig.cmake]
> dir /opt/local *ci OpenCVConfig.cmake
> Checking file [/opt/local/opencv-config.cmake]
> dir /opt/local *ci opencv-config.cmake
> Consider /opt/local
> Consider /opt/local
> Consider /opt/local
> Consider /opt/local
> Consider /opt/local/lib64
> Consider /opt/local/lib64/cmake
> Consider /opt/local/lib
> Consider /opt/local/lib/cmake
> Consider /opt/local/lib/cmake/OpenCVConfig-version.cmake
> Visit /opt/local/lib/cmake/OpenCVConfig-version.cmake/
> CheckDirectory (dir /opt/local/lib/cmake/OpenCVConfig-version.cmake/,
> suffix , d /opt/local/lib/cmake/OpenCVConfig-version.cmake/)

Hmm, why does it think this is a directory ?

...
> For some reason the
> 
> Consider /opt/local/lib/cmake/OpenCVConfig-version.cmake
> Visit /opt/local/lib/cmake/OpenCVConfig-version.cmake/
> CheckDirectory (dir /opt/local/lib/cmake/OpenCVConfig-version.cmake/,
> suffix , d /opt/local/lib/cmake/OpenCVConfig-version.cmake/)
> FindConfigFile #2
> Checking file
> [/opt/local/lib/cmake/OpenCVConfig-version.cmake/OpenCVConfig.cmake]
> dir /opt/local/lib/cmake/OpenCVConfig-version.cmake *ci
> 
> part decides to go into la-la land,
> rather than actually checking the supposed-to-be-sibling-to-Config.cmake
> foo-version.cmake **file**.
> 
> 
> 
> All the while
> 
> # ls /opt/local/lib/cmake
> OpenCVConfig-version.cmake	OpenCVConfig.cmake
> 
> has been ready waiting for the takin'
> (oh and I forgot to mention that CMAKE_PREFIX_PATH contained /opt/local,
> as seen in custom-augmented log above).
> 
> # port list opencv
> opencv                         @2.4.5          graphics/opencv
> 
> 
> 
> At least the find failure message is sufficiently semi-informative, though.
> 
> Setting the OpenCV-specific manual OpenCV_DIR variable then works, for a
> change. THIS SHOULD NOT BE WHAT A USER IS SUPPOSED TO DO (read: I consider
> it to be a HACK, since this is way more specific than what a user would
> normally care to specify).
> PREFIX-only operation should be the universal default

Yes. Setting CMAKE_PREFIX_PATH should be enough.

> (unless there are specific requirements on certain installations),
> thus that should be working without any issues whatsoever.
<
> The entire lookup handling seems grossly overly complex (for better or
> worse, given usual very heavy requirements and expectations on a build
> system). Have to say that at least it is implemented as very nice helper
> classes...
> 
> One conclusion is: CMake should definitely try to reduce its complexity
> soon (spend efforts to merely contain the massive amounts of required
> complexity, discarding any outdated one!), especially in such highly
> involved areas. IMHO it's high time for compiling a sizeable list of
> outdated/rotten "features" to axe, then once a list has been agreed on,
> prepare releasing a FEATURE-BREAKING version 3 which drastically cuts
> needless and bug-inducing featuritis
> (I'm talking e.g. the <lowercase>-config.cmake vs. <RealCase>Config.cmake
> here, but there are many other things that are e.g.
> deprecated/mis-implemented/confusing).
> Docs per each command are already sky-high as is (especially in Find
> areas), 

Finally somebody complains that there are too much docs ! ;-)

I think it's time to add a "General" section to the docs, which documents the 
supported regexps, generator expressions, and the general order of searching 
of the find-commands.

Right now all that is repeated several times, in each command where that 
feature is used.

> there's no need to complicate handling (and thus memorability!!)
> even more by retaining support of needless/Darwin-disadvantaged variations.
> 
> 
> Locating installed packages on a system should not be that hard,

Well, it actually is, even if it doesn't sound like a hard problem.

Alex

P.S. I know this mail doesn't help you much...


More information about the CMake mailing list