You are not logged in.

#1 2013-03-10 10:54:38

snack
Member
From: Italy
Registered: 2009-01-13
Posts: 861

CMake ignores CMAKE_CXX_FLAGS from cli

I need to set the -m32 flag for my project from command line when invoking cmake. What I actually do is:

$ cmake -DCMAKE_CXX_FLAGS=-m32 /path/to/myproject

Looking at cached values with cmake -i, it seems that the flag has been correctly set:

Variable Name: CMAKE_CXX_FLAGS
Description: Flags used by the compiler during all build types.
Current Value: -m32
New Value (Enter to keep current value):

However, when I launch make the -m32 flag is ignored. I really can't figure out why, does someone have a hint? Thanks

Offline

#2 2013-03-11 09:58:48

snack
Member
From: Italy
Registered: 2009-01-13
Posts: 861

Re: CMake ignores CMAKE_CXX_FLAGS from cli

Today I tried to set also linker flags with:

cmake -DCMAKE_CXX_FLAGS=-m32 -DCMAKE_SHARED_LINKER_FLAGS=-m32 /path/to/myproject

Linker flag -m32 is correctlty handled and passed to ld, but obviously build fails since -m32 is not passed to compiler...

Offline

#3 2013-03-11 10:25:33

snack
Member
From: Italy
Registered: 2009-01-13
Posts: 861

Re: CMake ignores CMAKE_CXX_FLAGS from cli

OK, things are becoming quite weird:

1) if I set -m32 in CMakeLists.txt it works:

set(CMAKE_CXX_FLAGS -m32)

but the cached entry for CMAKE_CXX_FLAGS is empty.

2) If I try to cache the entry with

set(CMAKE_CXX_FLAGS -m32 CACHE STRING docstring)

the resulting cache entry is still empty.

Is it a bug or am I missing the difference between cached/uncached variables and between command-line and in-code defined variables??

Offline

#4 2013-03-26 08:26:18

snack
Member
From: Italy
Registered: 2009-01-13
Posts: 861

Re: CMake ignores CMAKE_CXX_FLAGS from cli

Is this really so difficult to achieve that nobody knows how to do it? Is CMake missing such a basic functionality like command-line configuration for build variables?? I thought that one could be able to set the value of a cached variable from command line, but evidently my ideas about CMAke variables are badly confused...

Offline

Board footer

Powered by FluxBB