[CMake] Adding C(XX)FLAGS by using an environment variable?

Mike Jackson mike.jackson at imts.us
Wed Jul 2 11:05:09 EDT 2008



On Jul 2, 2008, at 6:41 AM, Mike Arthur wrote:

> I'm wanting to try and add C(XX)FLAGS by using an environment  
> variable so I
> can pass "-fmessage-length=0" only when compiling inside Eclipse.
>
> Is there any way to do this? CMake doesn't seem to respect C(XX) 
> FLAGS as
> environment variables at "make" time.
> -- 
> Cheers,
> Mike Arthur
>

Also,
    Are you using the Eclipse generator or just the Makefiles  
generator? Also what version of CMake.

You may be able to wrap the -fmessage-length=0 in some cmake code  
based on the generator being used.

IF( CMAKE_GENERATOR STREQUAL "Eclipse CDT4")
   SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fmessage-length=0")
ENDIF( CMAKE_GENERATOR STREQUAL "Eclipse CDT4")
IF( CMAKE_GENERATOR STREQUAL "Eclipse CDT4")
   SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmessage-length=0")
ENDIF( CMAKE_GENERATOR STREQUAL "Eclipse CDT4")

-- 
Mike Jackson   Senior Research Engineer
Innovative Management & Technology Services



More information about the CMake mailing list