Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. QtCreator CMake and compier defines

QtCreator CMake and compier defines

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
6 Posts 3 Posters 2.7k 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.
  • O Offline
    O Offline
    olejl77
    wrote on last edited by
    #1

    In CmakeLists.txt i set the following define:

    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTEST_DEFINE")
    

    In my source code I have the following:

    #ifdef TEST_DEFINE
      return 1;
    #else
      return 2;
    #endif
    

    In Qt Creator, the coloring indicates that TEST_DEFINE is not defined, but when compiling it is defined. What is the proper way to make Qt Creator aware of the defines set in CMakeLists.txt

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      After modifying your CMakeFile.txt did you re-run cmake ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      O 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        After modifying your CMakeFile.txt did you re-run cmake ?

        O Offline
        O Offline
        olejl77
        wrote on last edited by
        #3

        @SGaist Yes

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Which version of Qt Creator are you using ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mchinand
            wrote on last edited by
            #5

            Does it work correctly if you use add_definitions() instead?

            https://cmake.org/cmake/help/v3.0/command/add_definitions.html

            1 Reply Last reply
            2
            • O Offline
              O Offline
              olejl77
              wrote on last edited by
              #6

              @SGaist I'm using Qt Creator 4.0.3.

              @mchinand Yes it is working when using add_definitions() instead. Thanks

              1 Reply Last reply
              0

              • Login

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