Remove CMake code for CMake < 3.1

This removes the following functions from Qt5CoreMacros:
- qt5_use_modules(...)

Task-number: QTBUG-63519
Change-Id: I59769060a3a93686bf319b558c0ede55755fdb70
Reviewed-by: David Faure <david.faure@kdab.com>
This commit is contained in:
Kevin Funk 2017-09-29 21:45:37 +02:00
parent 927db42882
commit 02ed1b36da
9 changed files with 15 additions and 221 deletions

View File

@ -20,7 +20,7 @@ isEmpty(CTEST_VERSION) {
return()
}
!versionAtLeast(CMAKE_VERSION, 2.8.3) {
!versionAtLeast(CMAKE_VERSION, 3.1.0) {
message("cmake $$CMAKE_VERSION is too old for this test.")
return()
}

View File

@ -1,13 +1,7 @@
!!IF !equals(TEMPLATE, aux)
if (CMAKE_VERSION VERSION_LESS 2.8.3)
message(FATAL_ERROR \"Qt 5 requires at least CMake version 2.8.3\")
if (CMAKE_VERSION VERSION_LESS 3.1.0)
message(FATAL_ERROR \"Qt 5 $${CMAKE_MODULE_NAME} module requires at least CMake version 3.1.0\")
endif()
!!ELSE
if (CMAKE_VERSION VERSION_LESS 3.0.0)
message(FATAL_ERROR \"Qt 5 $${CMAKE_MODULE_NAME} module requires at least CMake version 3.0.0\")
endif()
!!ENDIF
!!IF !isEmpty(CMAKE_USR_MOVE_WORKAROUND)
!!IF !isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
@ -161,9 +155,7 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
set(_Qt5$${CMAKE_MODULE_NAME}_MODULE_DEPENDENCIES \"$${CMAKE_MODULE_DEPS}\")
!!IF !isEmpty(CMAKE_INTERFACE_MODULE_DEPS)
if (NOT CMAKE_VERSION VERSION_LESS 3.0.0)
list(APPEND _Qt5$${CMAKE_MODULE_NAME}_MODULE_DEPENDENCIES \"$${CMAKE_INTERFACE_MODULE_DEPS}\")
endif()
list(APPEND _Qt5$${CMAKE_MODULE_NAME}_MODULE_DEPENDENCIES \"$${CMAKE_INTERFACE_MODULE_DEPS}\")
!!ENDIF
set(Qt5$${CMAKE_MODULE_NAME}_OWN_PRIVATE_INCLUDE_DIRS ${Qt5$${CMAKE_MODULE_NAME}_PRIVATE_INCLUDE_DIRS})
@ -219,9 +211,7 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
set(_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES \"$${CMAKE_QT5_MODULE_DEPS}\")
!!IF !isEmpty(CMAKE_INTERFACE_QT5_MODULE_DEPS)
if (NOT CMAKE_VERSION VERSION_LESS 3.0.0)
list(APPEND _Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES \"$${CMAKE_INTERFACE_QT5_MODULE_DEPS}\")
endif()
list(APPEND _Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES \"$${CMAKE_INTERFACE_QT5_MODULE_DEPS}\")
!!ENDIF
!!IF !isEmpty(CMAKE_STATIC_TYPE)
@ -252,8 +242,7 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
endif()
endforeach()
if (_Qt5$${CMAKE_MODULE_NAME}_PRIVATE_DIRS_EXIST
AND NOT CMAKE_VERSION VERSION_LESS 3.0.0 )
if (_Qt5$${CMAKE_MODULE_NAME}_PRIVATE_DIRS_EXIST)
add_library(Qt5::$${CMAKE_MODULE_NAME}Private INTERFACE IMPORTED)
set_property(TARGET Qt5::$${CMAKE_MODULE_NAME}Private PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${Qt5$${CMAKE_MODULE_NAME}_OWN_PRIVATE_INCLUDE_DIRS}

View File

@ -1,6 +1,6 @@
if (CMAKE_VERSION VERSION_LESS 2.8.9)
message(FATAL_ERROR \"Qt5 requires at least CMake version 2.8.9\")
if (CMAKE_VERSION VERSION_LESS 3.1.0)
message(FATAL_ERROR \"Qt5 requires at least CMake version 3.1.0\")
endif()
if (NOT Qt5_FIND_COMPONENTS)

View File

@ -78,27 +78,10 @@ set(Qt5_POSITION_INDEPENDENT_CODE True)
# Applications now need to be compiled with the -fPIC option if the Qt option
# \"reduce relocations\" is active. For backward compatibility only, Qt accepts
# the use of -fPIE for GCC 4.x versions.
if (CMAKE_VERSION VERSION_LESS 2.8.12
AND (NOT CMAKE_CXX_COMPILER_ID STREQUAL \"GNU\"
OR CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0))
set_property(TARGET Qt5::Core APPEND PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE \"ON\")
else()
set_property(TARGET Qt5::Core APPEND PROPERTY INTERFACE_COMPILE_OPTIONS $$QMAKE_CXXFLAGS_APP)
endif()
set_property(TARGET Qt5::Core APPEND PROPERTY INTERFACE_COMPILE_OPTIONS $$QMAKE_CXXFLAGS_APP)
# Applications using qmake or cmake >= 2.8.12 as their build system will
# adapt automatically. Applications using an older release of cmake in
# combination with GCC 5.x need to change their CMakeLists.txt to add
# Qt5Core_EXECUTABLE_COMPILE_FLAGS to CMAKE_CXX_FLAGS. In particular,
# applications using cmake >= 2.8.9 and < 2.8.11 will continue to build
# with the -fPIE option and invoke the special compatibility mode if using
# GCC 4.x.
# TODO Qt6: Remove
set(Qt5Core_EXECUTABLE_COMPILE_FLAGS \"\")
if (CMAKE_VERSION VERSION_LESS 2.8.12
AND (CMAKE_CXX_COMPILER_ID STREQUAL \"GNU\"
AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0))
set(Qt5Core_EXECUTABLE_COMPILE_FLAGS \"-fPIC\")
endif()
!!IF !isEmpty(QT_NAMESPACE)
list(APPEND Qt5Core_DEFINITIONS -DQT_NAMESPACE=$$QT_NAMESPACE)
@ -157,7 +140,7 @@ if (NOT TARGET Qt5::WinMain)
)
!!ENDIF
if (NOT CMAKE_VERSION VERSION_LESS 2.8.11 AND NOT Qt5_NO_LINK_QTMAIN)
if (NOT Qt5_NO_LINK_QTMAIN)
set(_isExe $<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>)
set(_isWin32 $<BOOL:$<TARGET_PROPERTY:WIN32_EXECUTABLE>>)
set(_isNotExcluded $<NOT:$<BOOL:$<TARGET_PROPERTY:Qt5_NO_LINK_QTMAIN>>>)

View File

@ -152,9 +152,6 @@ function(QT5_GENERATE_MOC infile outfile )
set(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${outfile}")
endif()
if ("x${ARGV2}" STREQUAL "xTARGET")
if (CMAKE_VERSION VERSION_LESS 2.8.12)
message(FATAL_ERROR "The TARGET parameter to qt5_generate_moc is only available when using CMake 2.8.12 or later.")
endif()
set(moc_target ${ARGV3})
endif()
qt5_create_moc_command(${abs_infile} ${_outfile} "${moc_flags}" "" "${moc_target}" "")
@ -178,9 +175,6 @@ function(QT5_WRAP_CPP outfiles )
set(moc_target ${_WRAP_CPP_TARGET})
set(moc_depends ${_WRAP_CPP_DEPENDS})
if (moc_target AND CMAKE_VERSION VERSION_LESS 2.8.12)
message(FATAL_ERROR "The TARGET parameter to qt5_wrap_cpp is only available when using CMake 2.8.12 or later.")
endif()
foreach(it ${moc_files})
get_filename_component(it ${it} ABSOLUTE)
qt5_make_output_file(${it} moc_ cpp outfile)
@ -300,54 +294,3 @@ function(QT5_ADD_RESOURCES outfiles )
endfunction()
set(_Qt5_COMPONENT_PATH "${CMAKE_CURRENT_LIST_DIR}/..")
if (NOT CMAKE_VERSION VERSION_LESS 2.8.9)
macro(qt5_use_modules _target _link_type)
if(NOT CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.11)
if(CMAKE_WARN_DEPRECATED)
set(messageType WARNING)
endif()
if(CMAKE_ERROR_DEPRECATED)
set(messageType FATAL_ERROR)
endif()
if(messageType)
message(${messageType} "The qt5_use_modules macro is obsolete. Use target_link_libraries with IMPORTED targets instead.")
endif()
endif()
if (NOT TARGET ${_target})
message(FATAL_ERROR "The first argument to qt5_use_modules must be an existing target.")
endif()
if ("${_link_type}" STREQUAL "LINK_PUBLIC" OR "${_link_type}" STREQUAL "LINK_PRIVATE" )
set(_qt5_modules ${ARGN})
set(_qt5_link_type ${_link_type})
else()
set(_qt5_modules ${_link_type} ${ARGN})
endif()
if ("${_qt5_modules}" STREQUAL "")
message(FATAL_ERROR "qt5_use_modules requires at least one Qt module to use.")
endif()
foreach(_module ${_qt5_modules})
if (NOT Qt5${_module}_FOUND)
find_package(Qt5${_module} PATHS "${_Qt5_COMPONENT_PATH}" NO_DEFAULT_PATH)
if (NOT Qt5${_module}_FOUND)
message(FATAL_ERROR "Can not use \"${_module}\" module which has not yet been found.")
endif()
endif()
target_link_libraries(${_target} ${_qt5_link_type} ${Qt5${_module}_LIBRARIES})
set_property(TARGET ${_target} APPEND PROPERTY INCLUDE_DIRECTORIES ${Qt5${_module}_INCLUDE_DIRS})
set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS ${Qt5${_module}_COMPILE_DEFINITIONS})
set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE QT_NO_DEBUG)
set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO QT_NO_DEBUG)
set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_MINSIZEREL QT_NO_DEBUG)
if (Qt5_POSITION_INDEPENDENT_CODE
AND (CMAKE_VERSION VERSION_LESS 2.8.12
AND (NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
OR CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)))
set_property(TARGET ${_target} PROPERTY POSITION_INDEPENDENT_CODE ${Qt5_POSITION_INDEPENDENT_CODE})
endif()
endforeach()
endmacro()
endif()

View File

@ -47,17 +47,7 @@ find_package(Qt5Core REQUIRED)
include("${_Qt5CTestMacros}")
if(NOT ${CMAKE_VERSION} VERSION_LESS 2.8.9)
# Requires INCLUDE_DIRECTORIES target property in CMake 2.8.8
# and POSITION_INDEPENDENT_CODE target property in 2.8.9
if (NOT NO_GUI)
expect_pass(test_use_modules_function)
endif()
expect_pass(test_umbrella_config)
else()
message("CMake version older than 2.8.9 (Found ${CMAKE_VERSION}). Not running test \"test_use_modules_function\" or \"test_umbrella_config\"")
endif()
expect_pass(test_umbrella_config)
expect_pass(test_wrap_cpp_and_resources)
if (NOT NO_WIDGETS)
expect_pass(test_dependent_modules)
@ -90,12 +80,8 @@ if (NOT NO_DBUS)
expect_pass(test_dbus_module)
endif()
expect_pass(test_multiple_find_package)
if (NOT WIN32 OR (WIN32 AND NOT CMAKE_VERSION VERSION_LESS 2.8.11))
# Broken on windows on earlier CMake versions.
# http://public.kitware.com/Bug/view.php?id=13392
expect_pass(test_add_resources_delayed_file)
expect_pass(test_add_binary_resources_delayed_file BINARY test_add_binary_resources_delayed_file)
endif()
expect_pass(test_add_resources_delayed_file)
expect_pass(test_add_binary_resources_delayed_file BINARY test_add_binary_resources_delayed_file)
expect_pass(test_private_includes)
expect_pass(test_private_targets)
expect_pass(test_testlib_definitions)
@ -153,7 +139,7 @@ if (QT_WITH_ANGLE OR (NOT WIN32 AND NOT APPLE AND NOT NO_EGL))
endif()
expect_pass(test_opengl_lib)
if (NOT CMAKE_VERSION VERSION_LESS 2.8.11 AND NOT NO_WIDGETS)
if (NOT NO_WIDGETS)
expect_pass(test_interface)
endif()
@ -166,4 +152,3 @@ if (NOT CMAKE_VERSION VERSION_LESS 3.8)
# /usr/bin/ld: CMakeFiles/mywidget.dir/moc_mywidget.cpp.o: previous definition here
# Reason: SKIP_* properties were added in CMake 3.8 only
expect_pass(test_QTBUG-63422)
endif()

View File

@ -1,18 +0,0 @@
cmake_minimum_required(VERSION 2.8)
project(test_use_modules_function)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_executable(two two.cpp)
add_executable(three three.cpp)
find_package(Qt5Core)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}")
qt5_use_modules(two Test)
qt5_use_modules(three Gui Test)

View File

@ -1,45 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QtTest>
#include <QWindow>
class Three : public QObject
{
Q_OBJECT
public:
Three(QObject *parent = 0)
{
QWindow *w = new QWindow;
w->show();
}
};
QTEST_MAIN(Three)
#include "three.moc"

View File

@ -1,43 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QtTest>
class Two : public QObject
{
Q_OBJECT
public:
Two(QObject *parent = 0)
{
}
};
QTEST_MAIN(Two)
#include "two.moc"