MantisBT - CMake
View Issue Details
0015331CMakeModulespublic2014-12-31 02:452014-12-31 05:15
AmiGO 
 
lowminoralways
closedwon't fix 
LinuxFedora20
CMake 2.8.12.2 
 
0015331: Impossible to use Modules from GIT as project-local module because of CMAKE_CURRENT_LIST_DIR
CMake package: cmake-2.8.12.2-2.fc20.x86_64

Here is the details:

https://github.com/Kitware/CMake/blob/master/Modules/FindLibLZMA.cmake [^]

Line 57:
 include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake)
Line 66:
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)

CMAKE_CURRENT_LIST_DIR causes CMake to search for CheckLibraryExists and FindPackageHandleStandardArgs in directory where the FindLibLZMA was placed.

So if I want to include FindLibLZMA in project-local CMake modules directory CMake will fail.

Sometimes before it looks like include(FindPackageHandleStandardArgs) and observed behaviour was correct but now it's broken.
1. Untar demo project from attachment;
2. Run cmake ./ in project directory;

CMake will fail with the following message:

CMake Error at cmake/FindLibLZMA.cmake:67 (include):
  include could not find load file:

    /home/AmiGO/soft/sources/zbackup/demo/cmake/FindPackageHandleStandardArgs.cmake
Call Stack (most recent call first):
  CMakeLists.txt:6 (find_package)


CMake Error at cmake/FindLibLZMA.cmake:68 (FIND_PACKAGE_HANDLE_STANDARD_ARGS):
  Unknown CMake command "FIND_PACKAGE_HANDLE_STANDARD_ARGS".
Call Stack (most recent call first):
  CMakeLists.txt:6 (find_package)


-- Configuring incomplete, errors occurred!

3. Comment line 67 and uncomment line 66;
4. Run cmake ./ again.

Now all becomes normal.
You should probably need to introduce something like ${CMAKE_MODULE_VENDOR_PATH} that will unwind to /usr/share/cmake/Modules and use it in GIT modules instead of ${CMAKE_CURRENT_LIST_DIR}.
No tags attached.
? demo.tar.xz (1,768) 2014-12-31 02:45
https://public.kitware.com/Bug/file/5336/demo.tar.xz
Issue History
2014-12-31 02:45AmiGONew Issue
2014-12-31 02:45AmiGOFile Added: demo.tar.xz
2014-12-31 05:15Rolf Eike BeerNote Added: 0037538
2014-12-31 05:15Rolf Eike BeerStatusnew => closed
2014-12-31 05:15Rolf Eike BeerResolutionopen => won't fix
2014-12-31 05:15Rolf Eike BeerCategoryCMake => Modules

Notes
(0037538)
Rolf Eike Beer   
2014-12-31 05:15   
This works exactly as intended. If you use a module that is shipped with any recent version of CMake it will use the other modules it depends on exactly from that version of CMake because it can rely on their interface.

If you want a Module that behaves differently then you should not only put a modified e.g. CheckLibraryExists.cmake in your project, but also a modified e.g. FindLZMA.cmake. If you copy modules from CMake git to your project you need to modify them anyway as you have to replace the license stub with the full BSD license. You can then also modify the include.