[CMake] Adding Platform files

Tim Gallagher tim.gallagher at gatech.edu
Sat Dec 15 06:57:30 EST 2012


Yup, you nailed it. The module path was being set after the call to project() and not before. 

Is there a naming convention for system names? I don't mind sending this upstream if there is interest. It's for Cray systems that use shared libraries (unlike Catamount which disables shared libraries). Makes building things like Paraview and Python much simpler on those platforms. I called it ModernCray since I have no idea what else it would be called.

Thanks,

Tim

----- Original Message -----
From: "Eric Noulard" <eric.noulard at gmail.com>
To: "tim gallagher" <tim.gallagher at gatech.edu>
Cc: "CMake List" <cmake at cmake.org>
Sent: Saturday, December 15, 2012 4:46:36 AM
Subject: Re: [CMake] Adding Platform files

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