[CMake] CMAKE_SYSTEM not available

Martin Apel martin.apel at simpack.de
Wed Oct 7 10:28:41 EDT 2009


Philip Lowman wrote:
> On Wed, Sep 30, 2009 at 5:24 AM, Martin Apel <martin.apel at simpack.de
> <mailto:martin.apel at simpack.de>> wrote:
>
>     I had a similar issue with CMAKE_SYSTEM_NAME. I have put platform
>     specific default settings into files called "Linux.cmake" and
>     "Windows.cmake",
>     where the file is included as
>       INCLUDE (${CMAKE_SYSTEM_NAME}.cmake)
>
>     However it's not possible to initialize some variables, because
>     this include statement has to be after the PROJECT command.
>     I tried to set CMAKE_EXE_LINKER_FLAGS_INIT inside these
>     platform-specific files, but it seems that it's too late to set
>     them after
>     the PROJECT command. So I have a cycle:
>     - I cannot use the above include statement before the PROJECT call
>     - but if I use it after the PROJECT call I cannot set some
>     variables anymore (I can set them, but they have no effect,
>     because in the above example
>       CMAKE_EXE_LINKER_FLAGS is initialized from
>     CMAKE_EXE_LINKER_FLAGS_INIT during the PROJECT call)
>
>     Currently I work around this by not setting
>     CMAKE_EXE_LINKER_FLAGS_INIT, but CMAKE_EXE_LINKER_FLAGS inside my
>     Linux.cmake. This used to work fine with CMake 2.6, but 2.8 issues
>     a warning, that I am overwriting a cached variable.
>
>     What is the recommended way to initialize platform-specific flags,
>     which are held in the cache?
>
>
> You are correct that conditionals don't work prior to project() in the
> toplevel file but they seem to work fine within the platform override
> .cmake file itself.  You might try having one flags file with whatever
> conditionals you need for Linux, Windows, etc.
>
> For example:
> http://www.cmake.org/Wiki/CMake_FAQ#Make_Override_Files
> <avk-blocked://www.cmake.org/Wiki/CMake_FAQ#Make_Override_Files>
>
> -- 
> Philip Lowman
Hi Philip,

thanks for the info. This did the trick.

Martin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20091007/7cbfa4f8/attachment.htm>


More information about the CMake mailing list