0

CMake have special variable ${QT_DEFINITIONS} for Qt4 which contains qt defines such as QT_NO_DEBUG and QT_DEBUG. There is no such option for Qt5.

How can I add standard Qt5 defines in cmake?

1 Answer 1

1

Please check <component>_DEFINITIONS / <component>_COMPILE_DEFINITIONS.

There's an example using Qt Widgets and CMake here. The two essential parts:

# Find the QtWidgets library find_package(Qt5Widgets) # Add the include directories for the Qt 5 Widgets module to # the compile lines. include_directories(${Qt5Widgets_INCLUDE_DIRS}) 

Calling find_package() will set those variables for you:

  • Qt5Widgets_VERSION_STRING
  • Qt5Widgets_LIBRARIES List of libraries for use with the target_link_libraries command, for example.
  • Qt5Widgets_INCLUDE_DIRS List of libraries for use with the include_directories command, for example.
  • Qt5Widgets_DEFINITIONS List of definitions for use with add_definitions, for example.
  • Qt5Widgets_COMPILE_DEFINITIONS List of definitions for use with the COMPILE_DEFINITIONS target property.
  • Qt5Widgets_FOUND Boolean describing whether the module was found successfully.
  • Qt5Widgets_EXECUTABLE_COMPILE_FLAGS String of flags to be used when building executables.

(Quoted from link above; the name depends on what you search in your find_package() call)

Sign up to request clarification or add additional context in comments.

3 Comments

Unfortunately none of these variables have QT_NO_DEBUG. As a workaround I will add QT_NO_DEUBG, QT_DEBUG manually. These defies are required to make proper QtDesigner plugin.
What version of CMake are you using? 2.8+? (if not, please test this version).
Thx for pointing me out on CMake bugtracker. I was using 2.8.11 and it looks like they have just released new version.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.