I want to generate a visual studio project 2010 with cmake from a CMakeLists.txt. Basically this works fine. However, one detail lead to my following observation:
The default character set for the generated visual studio project is 'Multibyte Character'. I want to change it to Unicode. As far as I found out, I need to define either _UNICODE
or UNICODE
, but I also need to undefine _MBCS
. This works out, if I put it in the CMakeLists.txt, but I can't get it working, if I want to set these definitions by command line:
CMakeList.txt, works fine:
add_definitions ( -D_UNICODE )
remove_definitions ( -D_MBCS )
Command line, definitions are ignored by cmake, if I do it like this:
cmake -D_UNICODE="" -U_MBCS=""
Command line, definitions are ignored by cmake, if I do it like this:
cmake -DCMAKE_CXX_FLAGS_INIT="-D_UNICODE -U_MBCS"
I assumed that both ways are the same, but obviously the handling of the definitions from command line is different. I am doing something wrong or is it only possible by using add_definitions / remove_definitions ?
By the way, I'm using cmake 3.10.