[cmake-developers] User vs CMake include mismatch handling

Alexander Neundorf neundorf at kde.org
Thu Oct 7 14:04:10 EDT 2010


On Wednesday 06 October 2010, David Cole wrote:
> The really robust solution here is the simple one.
>
> It is to implement CMAKE_CURRENT_LIST_DIR and for files that must
> explicitly reference a file "in the same directory as me", use that
> explicitly.
>
> Otherwise, behavior is exactly the same as it is now.
>
> Explicit reference to the file you mean is the only guaranteed way to get
> the file you mean. 

This basically means that each include() and find_package() in CMAKE_ROOT has 
to use ${CMAKE_CURRENT_LIST_DIR} to make sure it gets the file from 
CMAKE_ROOT.
This are 398 places in CMAKE_ROOT which have to be looked at and modified 
accordingly.
That's what we get automatically and future-proof with the patch.

> Anything else is a guess and will be wrong some of the time.

No.

Speaking as CMake developer: I would expect that when I do include(SomeFile) 
in a file in CMAKE_ROOT in cmake version x.y.z, that I can use all features 
of SomeFile.cmake of this release.

Is this a guarantee we want to provide ?

I always assumed this. Otherwise I cannot safely use any feature which has 
been added to SomeModule.cmake after its initial release, because some 
project may have an own copy of that file from its initial release.

If we want to ensure this, then cmake has to prefer CMAKE_ROOT over 
CMAKE_MODULE_PATH when include()/find_package() is called from inside 
CMAKE_ROOT.


Alex



More information about the cmake-developers mailing list