MantisBT - CMake
View Issue Details
0014781CMakeCMakepublic2014-03-01 03:162014-10-06 10:32
Ruslan Baratov 
Brad King 
normalminoralways
closedfixed 
Windows
 
 
0014781: Document that find_package searches cmake-gui locations only on Windows
On windows find_package command detect FooConfig.cmake file inside temporary build
directory instead of CMAKE_INSTALL_PREFIX path.
1) build Foo in '_build/Foo' directory
2) install Foo with '_install' prefix
3) build Boo in '_build/Boo' directory

Projects layout:
- Foo/CMakeLists.txt
- Boo/CMakeLists.txt
- _builds/Foo/FooConfig.cmake # temp config build
- _builds/Boo
- _install/lib/cmake/Foo/FooConfig.cmake # real config

Output:
  CMake Error at /.../_builds/Foo/FooConfig.cmake:30 (include):
  include could not find load file: /.../lib/cmake/Foo/FooTargets.cmake
Works fine:
* if remove '_build/Foo' directory after Foo install
* on Mac OS X

CMake version 3.0.0-rc1

Example available here:
* https://github.com/forexample/package-example [^]
No tags attached.
Issue History
2014-03-01 03:16Ruslan BaratovNew Issue
2014-03-03 08:38Brad KingNote Added: 0035225
2014-03-03 09:37Ruslan BaratovNote Added: 0035232
2014-03-03 10:29Brad KingNote Added: 0035234
2014-03-03 10:29Brad KingStatusnew => resolved
2014-03-03 10:29Brad KingResolutionopen => no change required
2014-03-03 14:19Ruslan BaratovNote Added: 0035241
2014-03-03 14:19Ruslan BaratovStatusresolved => feedback
2014-03-03 14:19Ruslan BaratovResolutionno change required => reopened
2014-03-03 14:41Brad KingNote Added: 0035242
2014-03-03 14:41Brad KingAssigned To => Brad King
2014-03-03 14:41Brad KingStatusfeedback => assigned
2014-03-03 14:41Brad KingResolutionreopened => fixed
2014-03-03 14:41Brad KingSummaryfind_package don't respect variable CMAKE_INSTALL_PREFIX properly => Document that find_package searches cmake-gui locations only on Windows
2014-03-03 14:57Ruslan BaratovNote Added: 0035243
2014-03-03 15:02Brad KingStatusassigned => resolved
2014-10-06 10:32Robert MaynardNote Added: 0036929
2014-10-06 10:32Robert MaynardStatusresolved => closed

Notes
(0035225)
Brad King   
2014-03-03 08:38   
The find_package command documentation:

 http://www.cmake.org/cmake/help/v3.0/command/find_package.html [^]

enumerates the sequence of search locations and options to disable them. Build directories are considered in some of the steps.

If your FooConfig.cmake in the build tree is not suitable for being found (perhaps because it is there only to later be installed) then it should be tucked away at a path within the build tree that the command does not search.
(0035232)
Ruslan Baratov   
2014-03-03 09:37   
Okay, sorry, I missed that (just thinking that it's current project build directory, i.e. _builds/Boo).

But in this case why Mac OS X acts differently?
(0035234)
Brad King   
2014-03-03 10:29   
Re 0014781:0035232: If you used cmake-gui to create the build tree on Windows but not on OS X then the corresponding step in find_package may behave differently. Otherwise you'll have to carefully consider how each documented step would work on each of the two systems to see where the difference lies.
(0035241)
Ruslan Baratov   
2014-03-03 14:19   
> Re 0014781:0035232: If you used cmake-gui to create the build tree on Windows
> but not on OS X then the corresponding step in find_package may behave
> differently. Otherwise you'll have to carefully consider how each documented
> step would work on each of the two systems to see where the difference lies.

In both cases cmake-gui used. Steps to reproduce:

01. open cmake-gui
02. cmake-gui: set source directory to Foo
03. cmake-gui: set build directory to _builds/Foo
04. cmake-gui: run configure (generator = Xcode)
05. cmake-gui: run generate
06. open _builds/Foo/Foo.xcodeproj in Xcode
07. xcode: build target ALL (file _builds/Foo/FooConfig.cmake created)
08. cmake-gui: set source directory to Boo
09. cmake-gui: set build directory to _builds/Boo
10. cmake-gui: run configure (generator = Xcode)

Error occurs:

  Could not find a package configuration file provided by "Foo" with any of
  the following names:

    FooConfig.cmake
    foo-config.cmake

Expected that FooConfig.cmake will be found in _builds/Foo directory.

According to find_package (5) documentation:

  Search project build trees recently configured in a cmake-gui(1). This can be
  skipped if NO_CMAKE_BUILDS_PATH is passed. It is intended for the case when a
  user is building multiple dependent projects one after another.

Suboption NO_CMAKE_BUILDS_PATH is not set. If I understand correctly
"recently configured project" is Foo.

Works fine on windows using Visual Studio generator.

Note that I've update example on github that I mention earlier (I've add
NO_CMAKE_BUILDS_PATH). So if you want to reproduce all steps you need to
remove NO_CMAKE_BUILDS_PATH from Boo/CMakeLists.txt.
(0035242)
Brad King   
2014-03-03 14:41   
Oops, I forgot that the cmake-gui search locations are used only on Windows. I've updated the documentation:

 Help: Mention in find_package that cmake-gui step is Windows-only (0014781)
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=69d73d27 [^]
(0035243)
Ruslan Baratov   
2014-03-03 14:57   
Cool, thank you!
(0036929)
Robert Maynard   
2014-10-06 10:32   
Closing resolved issues that have not been updated in more than 4 months.