[CMake] [CMAKE] PROJECT command and CMAKE_SYSTEM_NAME

Bill Hoffman bill.hoffman at kitware.com
Wed Feb 10 13:08:58 EST 2010


Martin Guillon wrote:
> 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....


You are sort of stuck...   It is a chicken and the egg type of problem. 
   You could try something like this:

project(Foo NONE)
SET (CMAKE_USER_MAKE_RULES_OVERRIDE ...)
enable_language(CXX)
enable_language(C)

Or you could use execute_process in your override files to try and guess 
the system yourself.

-Bill


More information about the CMake mailing list