View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0014041CMakeCMakepublic2013-03-26 09:562013-10-07 10:04
ReporterMatthieu Gallien 
Assigned ToBrad King 
PrioritynormalSeverityblockReproducibilityalways
StatusclosedResolutionfixed 
PlatformLinuxOSDebianOS Versionunstable
Product Version 
Target VersionCMake 2.8.11Fixed in VersionCMake 2.8.11 
Summary0014041: CMake 2.8.11-rc1 regression: usr-move changes break cross-compiling use case
DescriptionI am doing cross compilation with oe-core and bitbake. I am using Config files and exported targets. I am using cmake 2.8.11-rc1.
The config file is generated with configure_package_config_file. The macro set_and_check is not using CMAKE_FIND_ROOT_PATH to locate the path or files set. It makes it fail when doing cross compilation with a path set in CMAKE_FIND_ROOT_PATH.

The same problem is present in the exported target file. I am using :
install(EXPORT QtJolieTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE QtJolieTargets.cmake NAMESPACE KF5:: )

The same checking of file existence is present and is also not using CMAKE_FIND_ROOT_PATH. This makes the import fail.
TagsNo tags attached.
Attached Filespatch file icon 0001-takes-into-account-CMAKE_FIND_ROOT_PATH-when-checkin.patch [^] (3,090 bytes) 2013-03-26 09:56 [Show Content]
txt file icon CMakeLists.txt [^] (1,357 bytes) 2013-04-02 16:15 [Show Content]
? file icon project1Config.cmake.in [^] (446 bytes) 2013-04-02 16:16
cpp file icon project1.cpp [^] (52 bytes) 2013-04-02 16:18
? file icon project1.h [^] (89 bytes) 2013-04-02 16:18
txt file icon CMakeLists-2.txt [^] (170 bytes) 2013-04-02 16:54 [Show Content]
cpp file icon project2.cpp [^] (52 bytes) 2013-04-02 16:54
? file icon project1Config-2.cmake.in [^] (400 bytes) 2013-04-02 17:01

 Relationships

  Notes
(0032703)
Brad King (manager)
2013-03-26 10:25

CMAKE_FIND_ROOT_PATH is only about the find_* commands. Once found these files should be loaded by their real full path. The tested files should exist at these full paths.

Please provide a complete minimal example demonstrating the issue. We need a sample project that installs the package config files and one that loads them and gets errors.
(0032708)
Matthieu Gallien (reporter)
2013-03-27 10:49

My point is that the find command will locate the config file prepending CMAKE_FIND_ROOT_PATH paths. The config file will be executed and will try to locate files without prepending the same variable. This will fail because I am doing cross compilation. The root path of the system is not / but some path a. The path in the config file is relative to the path a. For example, in my case a library is located /a/usr but the config file says it is located in /usr.
I will try my best o provide you quickly with an example that shows how to reproduce.
Maybe a better patch would be to not use if(NOT EXISTS ...) but to use FIND_FILE ?
(0032709)
Brad King (manager)
2013-03-27 11:02

Re 0014041:0032708: The main purpose of a package config file is to *know* where the rest of the package files are located. It shouldn't have to do any searching (unlike a find-module which must search because it doesn't come with the package).

Is the following correct?

You have a package that was built for another machine and at runtime on that other machine will be installed in /usr, and so has paths hard-coded for that. On the host machine it is in /a/usr so the full paths don't resolve without prepending /a.

Did this work with CMake 2.8.10?
(0032736)
Brad King (manager)
2013-04-01 10:20

Normally the install prefix is computed relative to the package config/targets file locations. However, a special case was introduced to handle the usr-move made by Linux distros:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0c727b90 [^]
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d4774140 [^]

I suspect that change is triggering this problem.
(0032743)
Matthieu Gallien (reporter)
2013-04-02 17:00

The steps to reproduce.
1) create a project1 directory with CMakeLists.txt, project1.cpp, project1.h and project1Config.cmake.in (renammed from project1Config-2.cmake.in)
2) create a build directory and call cmake .. -DCMAKE_INSTALL_PREFIX=/usr
3) call make install DESTDIR=/some/path
4) create a project2 directory with CMakeLists.txt (renammed from CMakeLists-2.txt) and project2.cpp
5) create a build directory and call cmake .. -DCMAKE_FIND_ROOT_PATH=/some/path -DCMAKE_INSTALL_PREFIX=/usr
(0032744)
Matthieu Gallien (reporter)
2013-04-02 17:09

Using cmake 2.8.10.2 tag allows one to configure the second project without errors.
Using cmake 2.8.10.20130321 allows one to reproduce my problem.
(0032745)
Brad King (manager)
2013-04-02 17:10

Re 0014041:0032743: DESTDIR is for installation during packaging. It is expected that the package will be extracted such that the files appear at their intended prefix before being used.

The value of CMAKE_INSTALL_PREFIX should be the actual location of the files when they are to be loaded. Build with -DCMAKE_INSTALL_PREFIX=/some/path/usr instead.
(0032746)
Matthieu Gallien (reporter)
2013-04-02 17:16

DESTDIR is what is used to build the package with oe-core and it is also what I had found more convenient to reproduce my problem. The fact is that CMAKE_INSTALL_PREFIX has to be /usr because it will really be /usr chen deployed on the target. On the development system, the development package is deployed under some prefix. This is what I was willing to simulate with DESTDIR. I could have used a mv directly.

The location of the config file is ${CMAKE_FIND_ROOT_PATH}/${CMAKE_INSTALL_PREFIX} on my development system and ${CMAKE_INSTALL_PREFIX} on my target system.
(0032747)
Brad King (manager)
2013-04-03 08:10
edited on: 2013-04-03 08:11

Re 0014041:0032746: Lots of projects hard-code paths to their installation prefix instead of being relocatable. How are they used in a cross-compiling scenario like this?

A lot of care went into making CMake-generated packages relocatable by computing locations relative to the package file locations. Unfortunately it is not safe to evaluate such relative paths in the presence of cross-prefix symlinks like "/lib -> /usr/lib" as is done by usr-move Linux distros. The changes mentioned in 0014041:0032736 add a special case for system-located install prefixes to switch to hard-coded full paths under the assumption that such prefixes will only be used for non-relocatable system packages.

As stated in 0014041:0032709 the entire point of package config files and target files created by install(EXPORT) is to know *exactly* where to find the rest of the package. It is not acceptable to do any searching. In your use case this requirement is in direct conflict with the usr-move changes mentioned above, so we may need another solution to that problem.

(0032750)
Brad King (manager)
2013-04-03 11:27

This commit should fix it:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6c613b43 [^]

Please test.
(0032753)
Matthieu Gallien (reporter)
2013-04-03 15:59

It works fine with your commit.
Thanks for your help.
(0034025)
Robert Maynard (manager)
2013-10-07 10:04

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

 Issue History
Date Modified Username Field Change
2013-03-26 09:56 Matthieu Gallien New Issue
2013-03-26 09:56 Matthieu Gallien File Added: 0001-takes-into-account-CMAKE_FIND_ROOT_PATH-when-checkin.patch
2013-03-26 10:25 Brad King Note Added: 0032703
2013-03-27 10:49 Matthieu Gallien Note Added: 0032708
2013-03-27 11:02 Brad King Note Added: 0032709
2013-04-01 10:20 Brad King Note Added: 0032736
2013-04-02 16:15 Matthieu Gallien File Added: CMakeLists.txt
2013-04-02 16:16 Matthieu Gallien File Added: project1Config.cmake.in
2013-04-02 16:18 Matthieu Gallien File Added: project1.cpp
2013-04-02 16:18 Matthieu Gallien File Added: project1.h
2013-04-02 16:54 Matthieu Gallien File Added: CMakeLists-2.txt
2013-04-02 16:54 Matthieu Gallien File Added: project2.cpp
2013-04-02 17:00 Matthieu Gallien Note Added: 0032743
2013-04-02 17:01 Matthieu Gallien File Added: project1Config-2.cmake.in
2013-04-02 17:09 Matthieu Gallien Note Added: 0032744
2013-04-02 17:10 Brad King Note Added: 0032745
2013-04-02 17:16 Matthieu Gallien Note Added: 0032746
2013-04-03 08:10 Brad King Note Added: 0032747
2013-04-03 08:11 Brad King Note Edited: 0032747
2013-04-03 10:50 Brad King Assigned To => Brad King
2013-04-03 10:50 Brad King Severity minor => block
2013-04-03 10:50 Brad King Status new => assigned
2013-04-03 10:50 Brad King Target Version => CMake 2.8.11
2013-04-03 10:51 Brad King Summary In CMake 2.8.11-rc1, CMAKE_FINC_ROOT_PATH is not used when loading a Config file or importing targets => CMake 2.8.11-rc1 regression: usr-move changes break cross-compiling use case
2013-04-03 11:27 Brad King Note Added: 0032750
2013-04-03 15:59 Matthieu Gallien Note Added: 0032753
2013-04-03 16:21 Brad King Status assigned => resolved
2013-04-03 16:21 Brad King Resolution open => fixed
2013-04-03 16:21 Brad King Fixed in Version => CMake 2.8.11
2013-10-07 10:04 Robert Maynard Note Added: 0034025
2013-10-07 10:04 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team