Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Migrating from QMake to CMake UNICODE definition issue

Migrating from QMake to CMake UNICODE definition issue

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 430 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    alex.olha
    wrote on last edited by
    #1

    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 with

    DEFINES -= 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?

    1 Reply Last reply
    0
    • JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by JoeCFD
      #2

      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)

      1 Reply Last reply
      0
      • Christian EhrlicherC Online
        Christian EhrlicherC Online
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #3

        -DUNICODE for sure comes from Qt as it was compiled with this switch.
        Fix your header to not rely on this.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        A 1 Reply Last reply
        0
        • Christian EhrlicherC Christian Ehrlicher

          -DUNICODE for sure comes from Qt as it was compiled with this switch.
          Fix your header to not rely on this.

          A Offline
          A Offline
          alex.olha
          wrote on last edited by
          #4

          @JoeCFD Thanks a lot, your solution works!
          @Christian-Ehrlicher thank you too!

          Problem solved.

          1 Reply Last reply
          0
          • A alex.olha has marked this topic as solved on
          • A alex.olha has marked this topic as solved on

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved