Reputation: 63
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?
Upvotes: 0
Views: 1640
Reputation: 25340
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)
Upvotes: 1