[CMake] Re: [cmake 2.5 CVS] CMAKE_${LANG}_FLAGS is initialized with space

Brandon Van Every bvanevery at gmail.com
Fri Dec 14 14:50:02 EST 2007


On Dec 14, 2007 7:43 AM, Rodolfo Lima <rodolfo at rodsoft.org> wrote:
>
> I think there is... another proof:
>
> if(${CMAKE_CXX_FLAGS} STREQUAL " ")
>     MESSAGE("equal!")
> else(${CMAKE_CXX_FLAGS} STREQUAL " ")
>     MESSAGE("not equal!")
> endif(${CMAKE_CXX_FLAGS} STREQUAL " ")
>
> This returns "equal!" in my system...

If CMAKE_CXX_FLAGS is actually null, then your script should terminate
with an error.  Correct syntax is either plain CMAKE_CXX_FLAGS or
"${CMAKE_CXX_FLAGS}".  What you've written would work only if the
variable evaluates to a single variable name, or a single string
constant.

A cmake -P script has no cache.  On my Windows Vista machine, your
code gives me:

C:\devel\moz>cmake -P flags.cmake
CMake Error: Error in cmake code at
C:/devel/moz/flags.cmake:1:
if had incorrect arguments: ${CMAKE_CXX_FLAGS} STREQUAL " " (Unknown arguments s
pecified).
   Called from: [1]     C:/devel/moz/flags.cmake


Cheers,
Brandon Van Every


More information about the CMake mailing list