From 02ed1b36daebed5f3997bb676cf5e818c0db9d3c Mon Sep 17 00:00:00 2001 From: Kevin Funk Date: Fri, 29 Sep 2017 21:45:37 +0200 Subject: 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 --- mkspecs/features/ctest_testcase_common.prf | 2 +- .../features/data/cmake/Qt5BasicConfig.cmake.in | 21 ++------ src/corelib/Qt5Config.cmake.in | 4 +- src/corelib/Qt5CoreConfigExtras.cmake.in | 23 ++------- src/corelib/Qt5CoreMacros.cmake | 57 ---------------------- tests/auto/cmake/CMakeLists.txt | 23 ++------- .../cmake/test_use_modules_function/CMakeLists.txt | 18 ------- .../auto/cmake/test_use_modules_function/three.cpp | 45 ----------------- tests/auto/cmake/test_use_modules_function/two.cpp | 43 ---------------- 9 files changed, 15 insertions(+), 221 deletions(-) delete mode 100644 tests/auto/cmake/test_use_modules_function/CMakeLists.txt delete mode 100644 tests/auto/cmake/test_use_modules_function/three.cpp delete mode 100644 tests/auto/cmake/test_use_modules_function/two.cpp diff --git a/mkspecs/features/ctest_testcase_common.prf b/mkspecs/features/ctest_testcase_common.prf index 1e3f9d2c1c..0d5ff5f89c 100644 --- a/mkspecs/features/ctest_testcase_common.prf +++ b/mkspecs/features/ctest_testcase_common.prf @@ -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() } diff --git a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in index 55c74aad66..27f4c277d6 100644 --- a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in +++ b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in @@ -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\") -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\") +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() -!!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} diff --git a/src/corelib/Qt5Config.cmake.in b/src/corelib/Qt5Config.cmake.in index 75b53485b7..6b6544f932 100644 --- a/src/corelib/Qt5Config.cmake.in +++ b/src/corelib/Qt5Config.cmake.in @@ -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) diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in index 545b9a3d1e..e0652fdcf9 100644 --- a/src/corelib/Qt5CoreConfigExtras.cmake.in +++ b/src/corelib/Qt5CoreConfigExtras.cmake.in @@ -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 $,EXECUTABLE>) set(_isWin32 $>) set(_isNotExcluded $>>) diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake index 8d3dbe3ecf..1627de4002 100644 --- a/src/corelib/Qt5CoreMacros.cmake +++ b/src/corelib/Qt5CoreMacros.cmake @@ -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() diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt index 40c86132e9..f1d8657091 100644 --- a/tests/auto/cmake/CMakeLists.txt +++ b/tests/auto/cmake/CMakeLists.txt @@ -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() diff --git a/tests/auto/cmake/test_use_modules_function/CMakeLists.txt b/tests/auto/cmake/test_use_modules_function/CMakeLists.txt deleted file mode 100644 index be05c75054..0000000000 --- a/tests/auto/cmake/test_use_modules_function/CMakeLists.txt +++ /dev/null @@ -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) diff --git a/tests/auto/cmake/test_use_modules_function/three.cpp b/tests/auto/cmake/test_use_modules_function/three.cpp deleted file mode 100644 index 507cc8479d..0000000000 --- a/tests/auto/cmake/test_use_modules_function/three.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly -** 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 -#include - -class Three : public QObject -{ - Q_OBJECT -public: - Three(QObject *parent = 0) - { - QWindow *w = new QWindow; - w->show(); - } -}; - -QTEST_MAIN(Three) - -#include "three.moc" diff --git a/tests/auto/cmake/test_use_modules_function/two.cpp b/tests/auto/cmake/test_use_modules_function/two.cpp deleted file mode 100644 index 44eb7fe96e..0000000000 --- a/tests/auto/cmake/test_use_modules_function/two.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly -** 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 - -class Two : public QObject -{ - Q_OBJECT -public: - Two(QObject *parent = 0) - { - - } -}; - -QTEST_MAIN(Two) - -#include "two.moc" -- cgit v1.2.3