FindQt4: Set the INTERFACE_QT_MAJOR_VERSION for Qt4::QtCore
With a similar commit in Qt 5, this will error at CMake time if an attempt is made to use target_link_libraries(foo Qt4::QtCore Qt5::Core)
This commit is contained in:
parent
03b0ceebe5
commit
4aa10cd6d6
|
@ -1022,6 +1022,12 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION)
|
||||||
"${QT_MKSPECS_DIR}/default"
|
"${QT_MKSPECS_DIR}/default"
|
||||||
${QT_INCLUDE_DIR}
|
${QT_INCLUDE_DIR}
|
||||||
)
|
)
|
||||||
|
set_property(TARGET Qt4::QtCore PROPERTY
|
||||||
|
INTERFACE_QT_MAJOR_VERSION 4
|
||||||
|
)
|
||||||
|
set_property(TARGET Qt4::QtCore APPEND PROPERTY
|
||||||
|
COMPATIBLE_INTERFACE_STRING QT_MAJOR_VERSION
|
||||||
|
)
|
||||||
|
|
||||||
foreach(QT_MODULE ${QT_MODULES})
|
foreach(QT_MODULE ${QT_MODULES})
|
||||||
_QT4_ADJUST_LIB_VARS(${QT_MODULE})
|
_QT4_ADJUST_LIB_VARS(${QT_MODULE})
|
||||||
|
|
|
@ -75,6 +75,12 @@ add_RunCMake_test(include_directories)
|
||||||
add_RunCMake_test(list)
|
add_RunCMake_test(list)
|
||||||
add_RunCMake_test(CMP0004)
|
add_RunCMake_test(CMP0004)
|
||||||
|
|
||||||
|
find_package(Qt4 QUIET)
|
||||||
|
find_package(Qt5Core QUIET)
|
||||||
|
if (QT4_FOUND AND Qt5Core_FOUND AND Qt5Core_VERSION VERSION_GREATER 5.0.2)
|
||||||
|
add_RunCMake_test(IncompatibleQt)
|
||||||
|
endif()
|
||||||
|
|
||||||
if("${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio [^6]")
|
if("${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio [^6]")
|
||||||
add_RunCMake_test(include_external_msproject)
|
add_RunCMake_test(include_external_msproject)
|
||||||
add_RunCMake_test(SolutionGlobalSections)
|
add_RunCMake_test(SolutionGlobalSections)
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
cmake_minimum_required(VERSION 2.8)
|
||||||
|
project(${RunCMake_TEST} CXX)
|
||||||
|
include(${RunCMake_TEST}.cmake)
|
|
@ -0,0 +1 @@
|
||||||
|
1
|
|
@ -0,0 +1,3 @@
|
||||||
|
CMake Error: The INTERFACE_QT_MAJOR_VERSION property of "Qt5::Core" does
|
||||||
|
not agree with the value of QT_MAJOR_VERSION already determined
|
||||||
|
for "mainexe".
|
|
@ -0,0 +1,6 @@
|
||||||
|
|
||||||
|
find_package(Qt4 REQUIRED)
|
||||||
|
find_package(Qt5Core REQUIRED)
|
||||||
|
|
||||||
|
add_executable(mainexe main.cpp)
|
||||||
|
target_link_libraries(mainexe Qt4::QtCore Qt5::Core)
|
|
@ -0,0 +1,3 @@
|
||||||
|
include(RunCMake)
|
||||||
|
|
||||||
|
run_cmake(IncompatibleQt)
|
|
@ -0,0 +1,8 @@
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
QCoreApplication app(argc, argv);
|
||||||
|
return app.exec();
|
||||||
|
}
|
Loading…
Reference in New Issue