diff --git a/CMakeLists.txt b/CMakeLists.txt index 80f326432..8d50e3bf4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -214,7 +214,9 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/common/scm_rev.cpp.in" "${CMAKE_ message("end git things, remote: ${GIT_REMOTE_NAME}, branch: ${GIT_BRANCH}") -include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/findQt.cmake") +if(WIN32 AND ENABLE_QT_GUI AND NOT CMAKE_PREFIX_PATH) + include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/DetectQtInstallation.cmake") +endif () list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") find_package(Boost 1.84.0 CONFIG) diff --git a/CMakePresets.json b/CMakePresets.json index 454b4e767..2aeb0f064 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -6,6 +6,22 @@ "patch": 0 }, "configurePresets": [ + { + "name": "x64-Clang-Base", + "hidden": true, + "generator": "Ninja", + "binaryDir": "${sourceDir}/Build/${presetName}", + "cacheVariables": { + "CMAKE_C_COMPILER": "clang-cl", + "CMAKE_CXX_COMPILER": "clang-cl", + "CMAKE_INSTALL_PREFIX": "${sourceDir}/Build/${presetName}" + }, + "vendor": { + "microsoft.com/VisualStudioSettings/CMake/1.0": { + "intelliSenseMode": "windows-clang-x64" + } + } + }, { "name": "x64-Clang-Debug", "displayName": "Clang x64 Debug", @@ -26,89 +42,44 @@ { "name": "x64-Clang-Debug-Qt", "displayName": "Clang x64 Debug with Qt", - "generator": "Ninja", - "binaryDir": "${sourceDir}/Build/x64-Clang-Debug-Qt", + "inherits": ["x64-Clang-Base"], "cacheVariables": { - "CMAKE_C_COMPILER": "clang-cl", - "CMAKE_CXX_COMPILER": "clang-cl", "CMAKE_BUILD_TYPE": "Debug", - "CMAKE_INSTALL_PREFIX": "${sourceDir}/Install/x64-Clang-Debug-Qt", "ENABLE_QT_GUI": "ON" - }, - "vendor": { - "microsoft.com/VisualStudioSettings/CMake/1.0": { - "intelliSenseMode": "windows-clang-x64" - } } }, { "name": "x64-Clang-Release", "displayName": "Clang x64 Release", - "generator": "Ninja", - "binaryDir": "${sourceDir}/Build/x64-Clang-Release", + "inherits": ["x64-Clang-Base"], "cacheVariables": { - "CMAKE_C_COMPILER": "clang-cl", - "CMAKE_CXX_COMPILER": "clang-cl", - "CMAKE_BUILD_TYPE": "Release", - "CMAKE_INSTALL_PREFIX": "${sourceDir}/Install/x64-Clang-Release" - }, - "vendor": { - "microsoft.com/VisualStudioSettings/CMake/1.0": { - "intelliSenseMode": "windows-clang-x64" - } + "CMAKE_BUILD_TYPE": "Release" } }, { "name": "x64-Clang-Release-Qt", "displayName": "Clang x64 Release with Qt", - "generator": "Ninja", - "binaryDir": "${sourceDir}/Build/x64-Clang-Release-Qt", + "inherits": ["x64-Clang-Base"], "cacheVariables": { - "CMAKE_C_COMPILER": "clang-cl", - "CMAKE_CXX_COMPILER": "clang-cl", "CMAKE_BUILD_TYPE": "Release", - "CMAKE_INSTALL_PREFIX": "${sourceDir}/Install/x64-Clang-Release-Qt", "ENABLE_QT_GUI": "ON" - }, - "vendor": { - "microsoft.com/VisualStudioSettings/CMake/1.0": { - "intelliSenseMode": "windows-clang-x64" - } } }, { "name": "x64-Clang-RelWithDebInfo", "displayName": "Clang x64 RelWithDebInfo", - "generator": "Ninja", - "binaryDir": "${sourceDir}/Build/x64-Clang-RelWithDebInfo", + "inherits": ["x64-Clang-Base"], "cacheVariables": { - "CMAKE_C_COMPILER": "clang-cl", - "CMAKE_CXX_COMPILER": "clang-cl", - "CMAKE_BUILD_TYPE": "RelWithDebInfo", - "CMAKE_INSTALL_PREFIX": "${sourceDir}/Install/x64-Clang-RelWithDebInfo" - }, - "vendor": { - "microsoft.com/VisualStudioSettings/CMake/1.0": { - "intelliSenseMode": "windows-clang-x64" - } + "CMAKE_BUILD_TYPE": "RelWithDebInfo" } }, { "name": "x64-Clang-RelWithDebInfo-Qt", "displayName": "Clang x64 RelWithDebInfo with Qt", - "generator": "Ninja", - "binaryDir": "${sourceDir}/Build/x64-Clang-RelWithDebInfo-Qt", + "inherits": ["x64-Clang-Base"], "cacheVariables": { - "CMAKE_C_COMPILER": "clang-cl", - "CMAKE_CXX_COMPILER": "clang-cl", "CMAKE_BUILD_TYPE": "RelWithDebInfo", - "CMAKE_INSTALL_PREFIX": "${sourceDir}/Install/x64-Clang-RelWithDebInfo-Qt", "ENABLE_QT_GUI": "ON" - }, - "vendor": { - "microsoft.com/VisualStudioSettings/CMake/1.0": { - "intelliSenseMode": "windows-clang-x64" - } } } ] diff --git a/cmake/DetectQtInstallation.cmake b/cmake/DetectQtInstallation.cmake new file mode 100644 index 000000000..0f1dd6a8b --- /dev/null +++ b/cmake/DetectQtInstallation.cmake @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +# SPDX-License-Identifier: GPL-2.0-or-later + +file(GLOB QT_KITS LIST_DIRECTORIES true "C:/Qt/*/msvc*") +list(SORT QT_KITS COMPARE NATURAL) +list(REVERSE QT_KITS) +list(GET QT_KITS 0 QT_PREFIX) +if(QT_PREFIX) + set(CMAKE_PREFIX_PATH "${QT_PREFIX}" CACHE PATH "Qt prefix auto‑detected" FORCE) + message(STATUS "Auto-detected Qt prefix: ${QT_PREFIX}") +else() + message(WARNING "findQt.cmake: no Qt‑Directory found in C:/Qt – please set CMAKE_PREFIX_PATH manually") +endif() + diff --git a/cmake/FindQt.cmake b/cmake/FindQt.cmake deleted file mode 100644 index d568c55ad..000000000 --- a/cmake/FindQt.cmake +++ /dev/null @@ -1,15 +0,0 @@ -# SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project -# SPDX-License-Identifier: GPL-2.0-or-later - -if(WIN32 AND NOT CMAKE_PREFIX_PATH) - file(GLOB QT_KITS LIST_DIRECTORIES true "C:/Qt/*/msvc*") - list(SORT QT_KITS COMPARE NATURAL) - list(REVERSE QT_KITS) - list(GET QT_KITS 0 QT_PREFIX) - if(QT_PREFIX) - set(CMAKE_PREFIX_PATH "${QT_PREFIX}" CACHE PATH "Qt prefix auto‑detected" FORCE) - message(STATUS "Auto-detected Qt prefix: ${QT_PREFIX}") - else() - message(WARNING "findQt.cmake: no Qt‑Directory found in C:/Qt – please set CMAKE_PREFIX_PATH manually") - endif() -endif()