From e2f83c74f4d25e7850f333723e6279a98cfd18c7 Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Tue, 2 May 2023 15:38:45 +0200 Subject: [PATCH] Revert "CMakePM: Fix compile for gcc 7" This reverts commit ca04d9afcdea1f22580d2999ca4e6657d60979d8. GCC 9 or later is the minimum required version nowadays, so this piece of code can be more readable. Change-Id: I939ee6cd62572d23d5b1de8d113472136752a590 Reviewed-by: Orgad Shaneh Reviewed-by: Qt CI Bot --- .../cmakeprojectimporter.cpp | 59 +++++++++---------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp index dc752f0a9f9..03cd3c6b0eb 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp @@ -284,36 +284,35 @@ static FilePath qmakeFromCMakeCache(const CMakeConfig &config) if (!cmakeListTxt.open(QIODevice::WriteOnly)) { return FilePath(); } - // FIXME replace by raw string when gcc 8+ is minimum - cmakeListTxt.write(QByteArray( -"cmake_minimum_required(VERSION 3.15)\n" -"\n" -"project(qmake-probe LANGUAGES NONE)\n" -"\n" -"# Bypass Qt6's usage of find_dependency, which would require compiler\n" -"# and source code probing, which slows things unnecessarily\n" -"file(WRITE \"${CMAKE_SOURCE_DIR}/CMakeFindDependencyMacro.cmake\"\n" -"[=[" -" macro(find_dependency dep)\n" -" endmacro()\n" -"]=])\n" -"set(CMAKE_MODULE_PATH \"${CMAKE_SOURCE_DIR}\")\n" -"\n" -"find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)\n" -"find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)\n" -"\n" -"if (CMAKE_CROSSCOMPILING)\n" -" find_program(qmake_binary\n" -" NAMES qmake qmake.bat\n" -" PATHS \"${Qt${QT_VERSION_MAJOR}_DIR}/../../../bin\"\n" -" NO_DEFAULT_PATH)\n" -" file(WRITE \"${CMAKE_SOURCE_DIR}/qmake-location.txt\" \"${qmake_binary}\")\n" -"else()\n" -" file(GENERATE\n" -" OUTPUT \"${CMAKE_SOURCE_DIR}/qmake-location.txt\"\n" -" CONTENT \"$\")\n" -"endif()\n" -)); + cmakeListTxt.write(QByteArray(R"( + cmake_minimum_required(VERSION 3.15) + + project(qmake-probe LANGUAGES NONE) + + # Bypass Qt6's usage of find_dependency, which would require compiler + # and source code probing, which slows things unnecessarily + file(WRITE "${CMAKE_SOURCE_DIR}/CMakeFindDependencyMacro.cmake" + [=[ + macro(find_dependency dep) + endmacro() + ]=]) + set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}") + + find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED) + find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED) + + if (CMAKE_CROSSCOMPILING) + find_program(qmake_binary + NAMES qmake qmake.bat + PATHS "${Qt${QT_VERSION_MAJOR}_DIR}/../../../bin" + NO_DEFAULT_PATH) + file(WRITE "${CMAKE_SOURCE_DIR}/qmake-location.txt" "${qmake_binary}") + else() + file(GENERATE + OUTPUT "${CMAKE_SOURCE_DIR}/qmake-location.txt" + CONTENT "$") + endif() + )")); cmakeListTxt.close(); QtcProcess cmake;