[CMake] Remove _MBCS

Niels Dekker - address until 2014 niels_dekker_address_until_2014 at xs4all.nl
Wed Feb 20 09:36:21 EST 2013


On 2013-02-18 10:00, YanmingZou wrote:
> I am developing an application on windows with VS2012 and CMake
> (2.8.10.2). I want to use unicode in my program, so I add UNICODE and
> _UNICODE with ADD_DEFINITIONS. However, there is always a _MBCS marco in
> the generated project file. The project can be compiled, but I am not
> happy with that. Could someone can tell me how to remove the _MBCS?

On 2013-02-20 14:35, Patrick Johnmeyer wrote:
> Did you try remove_definitions?


Still I'm surprised that in your case, add_definitions(-D_UNICODE) does 
not automatically remove the definition of _MBCS. Do you even have _MBCS 
for a simple CMakeLists.txt as follows?

   ############################################################
   # CMakeLists.txt
   project( MyCMakeMfcUnicodeApp )
   cmake_minimum_required(VERSION 2.8)
   set(CMAKE_MFC_FLAG 2)
   add_definitions(-D_UNICODE)
   add_executable(${PROJECT_NAME} MySourceFile.cpp)
   ############################################################

Having the following "MySourceFile.cpp":

   ////////////////////////////////////////////////////////////
   // MySourceFile.cpp
   #ifdef _MBCS
   #  error "_MBCS should not be defined!"
   #endif
   ////////////////////////////////////////////////////////////


Kind regards,

  Niels
-- 
Niels Dekker
http://www.xs4all.nl/~nd/dekkerware
Scientific programmer at LKEB, Leiden University Medical Center


More information about the CMake mailing list