How to define UNICODE for mingw if you use CMAKE as a building system

Good afternoon, I create my Qt project using the Cmake build system on a Windows platform, but if I add a line to the cmake file:

  add_definitions ("- DUNICODE -D_UNICODE") 
UNICODE definition does not work (MINGW), this work only works correctly if I create my project using the MSVC compiler. After a few times, I found a workaround. How to define a variable when calling CMake, so qtcreator knows that this is defined? , this solution works, but if I use my own WINAPI functions such as CreateFile, I get a compilation error because the compiler chose CreateFileA, but I use w_char and I would like to use CreateFileW, this is because the UNICODE macro definition appears earlier than I am including a confugure file. How to define a UNICODE macro in cmakefile
+4
source share
1 answer

Have you tried (note the lack of quotes):

add_definitions(-DUNICODE -D_UNICODE) 
+6
source

All Articles