MantisBT - CMake
View Issue Details
0012325CMakeModulespublic2011-07-08 13:272011-07-08 14:41
Dan Thill 
Alex Neundorf 
normalminoralways
closedno change required 
WindowsWindows XP-64 SP25.2.3790
CMake 2.8.4 
 
0012325: FindDCMTK: Does not work when CMAKE_MODULE_PATH has been modified.
When FindDCMTK includes FindPackageHandleStandardArgs, this will fail if CMAKE_MODULE_PATH has been modified (under some circumstances). This was discovered when I was making my own copy of FindDCMTK with some bug fixes and putting it into my local source directory in order to override the stock one.
1) Make a copy of FindDCMTK.cmake and put into your local source directory.
2) In CMakeLists.txt, do the following:

-------------------------------------------
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
SET( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR} ${CMAKE_MODULE_PATH})

PROJECT(SomeProject)

FIND_PACKAGE(DCMTK)

-------------------------------------------

You will get the following error:


CMake Error at FindDCMTK.cmake:136 (include):
  include could not find load file:

    [full path to src directory]/FindPackageHandleStandardArgs.cmake
Call Stack (most recent call first):
  CMakeLists.txt:8 (FIND_PACKAGE)


CMake Error at FindDCMTK.cmake:137 (find_package_handle_standard_args):
  Unknown CMake command "find_package_handle_standard_args".
Call Stack (most recent call first):
  CMakeLists.txt:8 (FIND_PACKAGE)
Fix is modify FindDCMTK.cmake:135 and change:

include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)

to

include(FindPackageHandleStandardArgs)

No tags attached.
Issue History
2011-07-08 13:27Dan ThillNew Issue
2011-07-08 13:45Dan ThillNote Added: 0027019
2011-07-08 14:11Alex NeundorfNote Added: 0027020
2011-07-08 14:34Dan ThillNote Added: 0027021
2011-07-08 14:41Alex NeundorfNote Added: 0027022
2011-07-08 14:41Alex NeundorfAssigned To => Alex Neundorf
2011-07-08 14:41Alex NeundorfStatusnew => closed
2011-07-08 14:41Alex NeundorfResolutionopen => no change required

Notes
(0027019)
Dan Thill   
2011-07-08 13:45   
Obviously, the example I listed above is weird and can easily be fixed by me since I'm making my own copy. However, you can also see that if a user were trying to override FindPackageHandleStandardArgs by changing the CMAKE_MODULE_PATH and leaving FindDCMTK in the default location, FindDCMTK would not pick up the other version since it's bypassing the INCLUDE() search path machinery. This seems counterintuitive to me.
(0027020)
Alex Neundorf   
2011-07-08 14:11   
It has the fixed path to FindPackageHandleStandardArgs.cmake so it gets exactly the one it expects, i.e. the one shipping with the same version of cmake.
If somebody wants it to use a different version, he has to provide copies of both files, so the dependencies are ok.
Otherwise FindDCMTK.cmake might get a FindPackageHandleStandardArgs.cmake which does not support the features it expects and this would lead to a cmake error.

Alex
(0027021)
Dan Thill   
2011-07-08 14:34   
Fair enough. I've just noticed this same construct in other modules and realized this must be the rationale.
(0027022)
Alex Neundorf   
2011-07-08 14:41   
So I'm closing this one if you don't mind.

Alex