fa55751f83
In Qt 5.1, Qt5::Core has a INTERFACE_QT_MAJOR_VERSION property of '5', and since CMake 2.8.11, Qt4::QtCore has an INTERFACE_QT_MAJOR_VERSION of '4'. This was introduced in commit 4aa10cd6 (FindQt4: Set the INTERFACE_QT_MAJOR_VERSION for Qt4::QtCore, 2013-03-16), to produce an error if Qt 4 and Qt 5 are erroneously used by the same target. This can also be used however to determine the Qt major version, and therefore the particular moc executable to use during automoc steps. This means that targets in a single buildsystem can use a selection of Qt 4 and Qt 5, and still take advantage of the CMAKE_AUTOMOC feature without conflicting.
14 lines
300 B
CMake
14 lines
300 B
CMake
|
|
project(Qt4And5Automoc)
|
|
|
|
find_package(Qt4 REQUIRED)
|
|
find_package(Qt5Core REQUIRED)
|
|
|
|
set(CMAKE_AUTOMOC ON)
|
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|
|
|
add_executable(qt4_exe main_qt4.cpp)
|
|
target_link_libraries(qt4_exe Qt4::QtCore)
|
|
add_executable(qt5_exe main_qt5.cpp)
|
|
target_link_libraries(qt5_exe Qt5::Core)
|