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
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...
OK, things are becoming quite weird:
1) if I set -m32 in CMakeLists.txt it works:
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??
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...