[CMake] Sharing Modules between different installation of CMake

Robert Haines rhaines at manchester.ac.uk
Fri Feb 20 05:30:56 EST 2009


On 18 Feb 2009, at 21:57, Nicholas Yue wrote:

> Robert Haines wrote:
>> Hi,
>>
>>> I am testing different version of CMake on multiple platform to
>>> ensure my custom modules works fine on all combination.
>>>
>>> I find it troublesome to copy my custom module to all the different
>>> ../share/cmake-X.Y/Modules directory
>>>
>>> Is there an alternative to telling CMake that there are additional
>>> Module search path over and above those it normally searches?
>>
>> Sure, you can use: set(CMAKE_MODULE_PATH "/path/to/modules"). That  
>> path will be checked first so you can use it to override things in  
>> the CMake distribution too.
>>
>> In my projects I put the CMake stuff that I want to distribute with  
>> my code into a top-level directory called CMake and use it like so:  
>> set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMake").
>>
>> Cheers,
>> Rob
>>
> Is there a way to manage this without modifying the CMakeLists.txt  
> file e.g. via some environment variable(s)?

Yes, you can set most things from the command line in CMake so try this:

$ ccmake -DCMAKE_MODULE_PATH=/path/to/modules /path/to/project

No changes to CMakeLists.txt required...

Cheers,
Rob



More information about the CMake mailing list