[CMake] Thoughts on Cross-compiling with CMake

Eric Noulard eric.noulard at gmail.com
Tue May 1 06:56:08 EDT 2007


2007/4/30, Alexander Neundorf <a.neundorf-work at gmx.net>:
> On Monday 30 April 2007 12:51, Bernhard Sputh wrote:
> > Hi Alexander,
> ...
> > Thank You for working on this. I have another suggestion related to
> > cross-compilation. It should be possible to provide Compiler / Environment
> > scripts with ones project. These scripts could be located for instance in a
> > directory called `${CMAKE_SOURCE_DIR}/CMake_Platform/' or similar. This way
> > a cross-compilation project could be distributed without the need to
> > include a, potentially non-working, patch to the CMake scripts.
>
> Yes, that's planned. I don't think it would be reasonable to ship cmake files
> for all existing compilers/platforms/operating systems.

I am just listening to this cross-compiling support for a while and
I think that providing project specific CMake scripts/macro is already supported
through the CMAKE_MODULE_PATH var.

I would find it easier not to enforce directory naming scheme for finding
such cross-compiling modules.

The "only" issue is to authorize some vars to be read AND treated
by CMake BEFORE PROJECT() macro is called just as if it has been
provided on the command-line.

Something like:

SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/MyCMake)
PROJECT(MyProject C)

seems OK to me.

<little_off_topic>
I think that authorizing to use of some CMake MACRO BEFORE
calling PROJECT which may trigger change
the behavior of PROJECT would be a nice generic feature.

As an example I tried to enforce out-of-source build in doing
a comparison between ${PROJECT_SOURCE_DIR} and  ${PROJECT_BINARY_DIR}
but it seemed that those vars are not set up until PROJECT is called.
Thus CMakeFiles/ and CMakeCache.txt are created before I can even
tell the user he must not build in-source.
As a consequence the next time he tries an out-of-source build it fails
because CMake find CMakeFiles/ and CMakeCache.txt in the source tree :((
Too bad.
</little_off_topic>


-- 
Erk


More information about the CMake mailing list