[CMake] overriding CMAKE_MODULE_PATH list

Alexander Neundorf a.neundorf-work at gmx.net
Sun Feb 21 10:36:33 EST 2010


On Friday 19 February 2010, Luigi Calori wrote:
> I would like to have some clarification about module and include
> effective search order:
>
> I am in the following situation:
>
> I use (configure) a project that is overriding some CMake standard Find
> modules by doing in his main CMakeLists.txt file:
>
> SET(CMAKE_MODULE_PATH "<ProjectModuleFolder>;${CMAKE_MODULE_PATH}")
>
> I would like to being able to override, at configure time the project
> modules with mine.

Then the project may get some find-modules which behave differently than what 
it expects. Why do you want to do this ?

> Doing:
> cmake -DCMAKE_MODULE_PATH:PATH=<myModuleFolder>
> does not work (my files are searched AFTER projects files)

Yes, because the other project appends its apth to the already existing one, 
so your ends up at the end.

> Is it safe to just change project CMakeLists.txt to
> SET(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};<ProjectModuleFolder>")
>
> Or, on older CMake version this could result in getting standard CMake
> modules found first?

Everything in CMAKE_MODULE_PATH will be searched before cmake's own module 
directory.

Alex


More information about the CMake mailing list