Migrating from QMake to CMake UNICODE definition issue
-
Hello everyone!
I have the following problem: I cannot turn off UNICODE definition when using CMake to build my library.
Library was build successfully when I used QMake withDEFINES -= UNICODE
I switched to CMake and added the line to turn off unicode:
remove_definitions(-DUNICODE -D_UNICODE)
But I had no success and I still have unicode flags in arguments:
C:\Qt\Tools\mingw1120_64\bin\g++.exe -DCLIENTCORELIB_LIBRARY -DClientCoreLib_EXPORTS -DMINGW_HAS_SECURE_API=1 -DQT_CORE_LIB -DQT_NETWORK_LIB -DUNICODE -DWIN32 -DWIN64 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -D_MBCS -D_UNICODE -D_WIN64
and errors in compile output.
Could you guys please give me advise or solution to deal with this issue? -
When using remove_definitions(-DUNICODE -D_UNICODE) in CMake, it only removes definitions that were previously added by add_definitions or similar commands earlier in the same CMakeLists.txt file or included files. However, if UNICODE or _UNICODE is being defined elsewhere (e.g., by a parent project, a toolchain, or a system-level configuration), remove_definitions may not work as expected because it doesn't affect definitions set outside of CMake's explicit add_definitions.
Can you try:
add_compile_options(-UUNICODE -U_UNICODE) -
-DUNICODE for sure comes from Qt as it was compiled with this switch.
Fix your header to not rely on this. -
-DUNICODE for sure comes from Qt as it was compiled with this switch.
Fix your header to not rely on this. -
-