[CMake] Adding Platform files

Eric Noulard eric.noulard at gmail.com
Sat Dec 15 04:46:36 EST 2012


2012/12/14 Tim Gallagher <tim.gallagher at gatech.edu>:
> Hi,
>
> I have a folder inside my code repository we use to store custom modules and that folder was added to the search path. Inside that folder I added one called Platform/ and put a custom platform file in there. But CMake says it can't find the platform file.

How did you "add the folder to the search path" ?

In order for this to work one should modify CMAKE_MODULE_PATH
with something like:

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/MyCMakeModules")

the "Platform" directory should be below this custom dir.

**HOWEVER** you should be aware that platform files are read very
early in the CMake process and in any case during the "project(...)" command
processing.

So the CMAKE_MODULE_PATH modifications should appear BEFORE
any project(...) CMake command in order to be taken into account for that
particular project.

Usually you have something like:

cmake_minimum_required(VERSION 2.8)

# Update CMAKE_MODULE_PATH very soon
# in order to have access to Platform/xxxx.cmake files
# and avoid "unknown platform warning"
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/MyCMakeModules")

project(MyProject C)
....

With that it works for me.

> Is it possible to add custom platforms without having to put them in the CMake install tree?

Yes definitely.
I guess you may be modifying CMAKE_MODULE_PATH "too late"?

-- 
Erk
Le gouvernement représentatif n'est pas la démocratie --
http://www.le-message.org


More information about the CMake mailing list