如果使用CMAKE作为构建系统,如何为mingw定义UNICODE [英] How to define UNICODE for mingw, if use CMAKE as building system
问题描述
早上好,我在Windows平台上使用Cmake构建系统构建了Qt项目,但是如果我在cmake文件中添加行:
Good day, i build my Qt project with Cmake build system on windows platform, but if i add line in cmake file:
add_definitions("-DUNICODE -D_UNICODE")
UNICODE的定义不起作用(MINGW),仅当我使用MSVC编译器构建项目时,此功能才能正常工作.一段时间后,我找到了解决方法
definition of UNICODE not working(MINGW), this work properly only if i build my project with MSVC compiler. After some times i found workaround How do I define a variable when I call CMake, so that qtcreator knows it is defined?, this solution work but if i use native WINAPI functions such as CreateFile i get the compile error, because compiler chose CreateFileA but i use w_char and i would like to use CreateFileW, this is because the definition of macro UNICODE appears before than i include my confugure file.How can i define UNICODE macro in cmakefile?
推荐答案
您是否尝试过(请注意没有引号):
Have you tried (note the lack of quotes):
add_definitions(-DUNICODE -D_UNICODE)
这篇关于如果使用CMAKE作为构建系统,如何为mingw定义UNICODE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!