[CMake] overriding CMAKE_MODULE_PATH list

Luigi Calori l.calori at cineca.it
Fri Feb 19 07:11:50 EST 2010


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.

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

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?

Otherwise I have to propose a safer patch like:

set(USER_MODULE_PATH "" CACHE PATH "set this to define a folder for 
module override")
if(USER_MODULE_PATH)
    set(CMAKE_MODULE_PATH 
"${USER_MODULE_PATH};<ProjectModuleFolder>;${CMAKE_MODULE_PATH}")
else(USER_MODULE_PATH)
    set(CMAKE_MODULE_PATH "<ProjectModuleFolder>;${CMAKE_MODULE_PATH}")
endif(USER_MODULE_PATH)


Thanks in advance

Luigi
 



More information about the CMake mailing list