[CMake] [CMAKE] PROJECT command and CMAKE_SYSTEM_NAME

Martin Guillon MGuillon at movea.com
Wed Feb 10 12:50:25 EST 2010


Wow I didn't know about CMAke inserting the project thingy!!!

Ok now let me explain a little more. We want to simplify our Cmakelists and make macros to help our users.
 Now thanks to you we figured out the source of the problem.
This is the CMakeLists we want

SET (CMAKE_USER_MAKE_RULES_OVERRIDE
        "${CMAKE_SOURCE_DIR}/CMake/Utils/flag_overrides.cmake")
SET (CMAKE_USER_MAKE_RULES_OVERRIDE_C
        "${CMAKE_SOURCE_DIR}/CMake/Utils/c_flag_overrides.cmake")
SET (CMAKE_USER_MAKE_RULES_OVERRIDE_CXX
        "${CMAKE_SOURCE_DIR}/CMake/Utils/cxx_flag_overrides.cmake")

PROJECT(rootProject)

# Init our build system
INCLUDE (CMake/CMakeInit.cmake)

We want to set the CMAKE_USER_MAKE_RULES_OVERRIDE in the CMakeInit.cmake so it is hidden to developpers.  To do that we must do it before the PROJECT command or it wont work

But we also want to use CMAKE_SYSTEM_NAME in CMakeInit.cmake  which wont work if we put in CMakeInit.cmake   before the PROJECT command.

So we are quite stuck....

Is there a command(other than project) that would initialize CMAke so that after that command call we can access CMAKE_SYSTEM_NAME?

Thanks

MArtin

-----Original Message-----
From: cmake-bounces at cmake.org [mailto:cmake-bounces at cmake.org] On Behalf Of Bill Hoffman
Sent: Wednesday, February 10, 2010 5:22 PM
To: Tyler Roscoe
Cc: cmake at cmake.org; Martin Guillon
Subject: Re: [CMake] [CMAKE] PROJECT command and CMAKE_SYSTEM_NAME

Tyler Roscoe wrote:
> On Wed, Feb 10, 2010 at 04:54:47PM +0100, Martin Guillon wrote:
>> Let s say we have a very simple CMakeLists.txt Like that
>>
>> cmake_minimum_required(VERSION 2.6)
>> MESSAGE (STATUS "The system is \"${CMAKE_SYSTEM_NAME}\"")
>>
>> Now as is the CMakelists works fine.
>>
>> The problem appears when we add a PROJECT(TOTO) If I do so wherever I 
>> put it I get
>> -- The system is ""
> 
> The project() command does a bunch of stuff, including defining and 
> redefining various variables.
> 
> What are you trying to do?
> 

In addition to that, if the top level CMakeLists.txt file is missing a project command, CMake will insert one for you at the very top...

So:
make_minimum_required(VERSION 2.6)
MESSAGE (STATUS "The system is \"${CMAKE_SYSTEM_NAME}\"")

is really:
project(Project)
make_minimum_required(VERSION 2.6)
MESSAGE (STATUS "The system is \"${CMAKE_SYSTEM_NAME}\"")

-Bill

--
Bill Hoffman
Kitware, Inc.
28 Corporate Drive
Clifton Park, NY 12065
bill.hoffman at kitware.com
http://www.kitware.com
518 881-4905 (Direct)
518 371-3971 x105
Fax (518) 371-4573
_______________________________________________
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


More information about the CMake mailing list