[CMake] CMAKE_SYSTEM not available

Martin Apel martin.apel at simpack.de
Wed Sep 30 05:24:53 EDT 2009


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?

Regards,

Martin

Dieter Oberkofler wrote:
> Nothing wrong with calling project at the very beginning but in my case it
> was quite at the end of the CMakeLists.txt file and this made it fail. I was
> not aware of this "restriction" until now and did also not find any remarks
> in the documentation.
>
>   
>> -----Original Message-----
>> From: Tyler Roscoe [mailto:tyler at cryptio.net]
>> Sent: Tuesday, September 29, 2009 19:45
>> To: Dieter Oberkofler
>> Cc: cmake at cmake.org
>> Subject: Re: [CMake] CMAKE_SYSTEM not available
>>
>> On Tue, Sep 29, 2009 at 07:42:09PM +0200, Dieter Oberkofler wrote:
>>     
>>> The installation looks ok but I guess I just found out what is wrong.
>>> CMAKE_SYSTEM is only available after having used the PROJECT command.
>>> Is this really a needed and required dependency?
>>>       
>> Is there some reason you want to avoid calling project()?
>>
>> project() sets up a bunch of stuff. I guess you could try to call all
>> the relevant CMake modules yourself, but just putting a project(tmp) at
>> the top of your CMakeLists seems like a pretty good solution to me.
>>
>> tyler
>>     
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
>   


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090930/20e91376/attachment-0001.htm>


More information about the CMake mailing list