CMake: Drop Win32/MSVC specific paths. Use MSBuild.

This was never supported, and hasn't been updated in a while anyway.
This commit is contained in:
Stenzek
2026-05-23 11:57:11 +10:00
parent 77ecf99398
commit 2307ad9b0f
21 changed files with 177 additions and 341 deletions
+10 -4
View File
@@ -1,8 +1,14 @@
# SPDX-FileCopyrightText: 2019-2026 Connor McLaughlin <stenzek@gmail.com>
# SPDX-License-Identifier: CC-BY-NC-ND-4.0 + Packaging Restriction
#
# NOTE: In addition to the terms of CC-BY-NC-ND-4.0, you may not use this file to create
# packages or build recipes without explicit permission from the copyright holder.
include(CheckCXXCompilerFlag)
function(check_cxx_flag flag var)
CHECK_CXX_COMPILER_FLAG("-Werror ${flag}" ${var})
if(${var})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}" PARENT_SCOPE)
endif()
CHECK_CXX_COMPILER_FLAG("-Werror ${flag}" ${var})
if(${var})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}" PARENT_SCOPE)
endif()
endfunction()
+6
View File
@@ -1,3 +1,9 @@
# SPDX-FileCopyrightText: 2019-2026 Connor McLaughlin <stenzek@gmail.com>
# SPDX-License-Identifier: CC-BY-NC-ND-4.0 + Packaging Restriction
#
# NOTE: In addition to the terms of CC-BY-NC-ND-4.0, you may not use this file to create
# packages or build recipes without explicit permission from the copyright holder.
function(copy_base_translations target)
get_target_property(MOC_EXECUTABLE_LOCATION Qt6::moc IMPORTED_LOCATION)
get_filename_component(QT_BINARY_DIRECTORY "${MOC_EXECUTABLE_LOCATION}" DIRECTORY)
@@ -1,3 +1,9 @@
# SPDX-FileCopyrightText: 2019-2026 Connor McLaughlin <stenzek@gmail.com>
# SPDX-License-Identifier: CC-BY-NC-ND-4.0 + Packaging Restriction
#
# NOTE: In addition to the terms of CC-BY-NC-ND-4.0, you may not use this file to create
# packages or build recipes without explicit permission from the copyright holder.
# Renderer options.
option(ENABLE_OPENGL "Build with OpenGL renderer" ON)
option(ENABLE_VULKAN "Build with Vulkan renderer" ON)
+6 -9
View File
@@ -1,3 +1,9 @@
# SPDX-FileCopyrightText: 2019-2026 Connor McLaughlin <stenzek@gmail.com>
# SPDX-License-Identifier: CC-BY-NC-ND-4.0 + Packaging Restriction
#
# NOTE: In addition to the terms of CC-BY-NC-ND-4.0, you may not use this file to create
# packages or build recipes without explicit permission from the copyright holder.
message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}")
string(TOUPPER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_UPPER)
message(STATUS "C Flags: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}")
@@ -59,15 +65,6 @@ No support will be provided, continue at your own risk.
*********************************************************")
endif()
if(WIN32)
message(WARNING "*************** UNSUPPORTED CONFIGURATION ***************
You are compiling DuckStation with CMake on Windows.
It may not even build successfully.
DuckStation only supports MSBuild on Windows.
No support will be provided, continue at your own risk.
*********************************************************")
endif()
if(CPU_ARCH_X64 AND DISABLE_SSE4)
message(WARNING "*********************** WARNING ***********************
SSE4 instructions are disabled. This will result in
@@ -1,3 +1,9 @@
# SPDX-FileCopyrightText: 2019-2026 Connor McLaughlin <stenzek@gmail.com>
# SPDX-License-Identifier: CC-BY-NC-ND-4.0 + Packaging Restriction
#
# NOTE: In addition to the terms of CC-BY-NC-ND-4.0, you may not use this file to create
# packages or build recipes without explicit permission from the copyright holder.
# Use C++20.
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
+30 -48
View File
@@ -1,16 +1,11 @@
# SPDX-FileCopyrightText: 2019-2026 Connor McLaughlin <stenzek@gmail.com>
# SPDX-License-Identifier: CC-BY-NC-ND-4.0 + Packaging Restriction
#
# NOTE: In addition to the terms of CC-BY-NC-ND-4.0, you may not use this file to create
# packages or build recipes without explicit permission from the copyright holder.
# Get prebuilt dependencies for the current platform and architecture.
if(WIN32)
if (CPU_ARCH_X64)
set(DEPS_PATH "${CMAKE_SOURCE_DIR}/dep/prebuilt/windows-x64")
elseif(CPU_ARCH_ARM64)
set(DEPS_PATH "${CMAKE_SOURCE_DIR}/dep/prebuilt/windows-arm64")
else()
message(FATAL_ERROR "Unsupported architecture")
endif()
elseif(APPLE)
if(APPLE)
set(DEPS_PATH "${CMAKE_SOURCE_DIR}/dep/prebuilt/macos-universal")
elseif(LINUX)
if(CMAKE_CROSSCOMPILING)
@@ -43,7 +38,7 @@ set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
# pkg-config gets pulled transitively on some platforms.
if(NOT WIN32 AND NOT APPLE)
if(NOT APPLE)
find_package(PkgConfig REQUIRED)
find_package(Libbacktrace REQUIRED)
endif()
@@ -86,19 +81,8 @@ find_package(spirv_cross_c_shared REQUIRED
find_package(SDL3 3.4.4 REQUIRED
NO_DEFAULT_PATH PATHS "${DEPS_PATH}/lib/cmake/SDL3")
# Verify dependency paths.
foreach(dep zstd WebP PNG libjpeg-turbo freetype harfbuzz plutosvg cpuinfo
DiscordRPC SoundTouch libzip Shaderc spirv_cross_c_shared SDL3)
if((${dep}_LIBRARY AND NOT "${${dep}_LIBRARY}" MATCHES "^${DEPS_PATH}") OR
(${dep}_DIR AND NOT "${${dep}_DIR}" MATCHES "^${DEPS_PATH}"))
message(FATAL_ERROR "Using incorrect ${dep} library. Check your dependencies.")
endif()
endforeach()
# All our builds include Qt, so this is not a problem.
set(QT_NO_PRIVATE_MODULE_WARNING ON)
# Should be prebuilt.
if(LINUX)
find_package(Qt6 6.11.1 REQUIRED
NO_DEFAULT_PATH PATHS "${DEPS_PATH}/lib/cmake/Qt6"
@@ -109,40 +93,38 @@ else()
COMPONENTS Core Gui GuiPrivate Widgets LinguistTools)
endif()
# Have to verify it down here, don't want users using unpatched Qt.
if(NOT Qt6_DIR MATCHES "^${DEPS_PATH}")
message(FATAL_ERROR "Using incorrect Qt library. Check your dependencies.")
endif()
# Verify dependency paths.
foreach(dep zstd WebP PNG libjpeg-turbo freetype harfbuzz plutosvg cpuinfo
DiscordRPC SoundTouch libzip Shaderc spirv_cross_c_shared SDL3 Qt6)
if((${dep}_LIBRARY AND NOT "${${dep}_LIBRARY}" MATCHES "^${DEPS_PATH}") OR
(${dep}_DIR AND NOT "${${dep}_DIR}" MATCHES "^${DEPS_PATH}"))
message(FATAL_ERROR "Using incorrect ${dep} library. Check your dependencies.")
endif()
endforeach()
# Libraries that are pulled in from host.
if(NOT WIN32)
find_package(CURL REQUIRED)
if(LINUX)
find_package(UDEV REQUIRED)
find_package(CURL REQUIRED)
if(LINUX)
find_package(UDEV REQUIRED)
endif()
if(NOT APPLE)
if(ENABLE_X11)
find_package(X11 REQUIRED)
if (NOT X11_xcb_FOUND)
message(FATAL_ERROR "XCB is required")
endif()
endif()
if(NOT APPLE)
if(ENABLE_X11)
find_package(X11 REQUIRED)
if (NOT X11_xcb_FOUND)
message(FATAL_ERROR "XCB is required")
endif()
endif()
if(ENABLE_WAYLAND)
find_package(ECM REQUIRED NO_MODULE)
list(APPEND CMAKE_MODULE_PATH "${ECM_MODULE_PATH}")
find_package(Wayland REQUIRED Egl)
endif()
if(ENABLE_WAYLAND)
find_package(ECM REQUIRED NO_MODULE)
list(APPEND CMAKE_MODULE_PATH "${ECM_MODULE_PATH}")
find_package(Wayland REQUIRED Egl)
endif()
endif()
if(NOT WIN32)
find_package(FFMPEG 8.1.1 COMPONENTS avcodec avformat avutil swresample swscale)
if(NOT FFMPEG_FOUND)
message(WARNING "FFmpeg not found, using bundled headers.")
endif()
endif()
find_package(FFMPEG 8.1.1 COMPONENTS avcodec avformat avutil swresample swscale)
if(NOT FFMPEG_FOUND)
message(WARNING "FFmpeg not found, using bundled headers.")
set(FFMPEG_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/dep/ffmpeg/include")
endif()
+39 -47
View File
@@ -1,56 +1,52 @@
# SPDX-FileCopyrightText: 2019-2026 Connor McLaughlin <stenzek@gmail.com>
# SPDX-License-Identifier: CC-BY-NC-ND-4.0 + Packaging Restriction
#
# NOTE: In addition to the terms of CC-BY-NC-ND-4.0, you may not use this file to create
# packages or build recipes without explicit permission from the copyright holder.
include(CheckSourceCompiles)
function(disable_compiler_warnings_for_target target)
if(MSVC)
target_compile_options(${target} PRIVATE "/W0")
else()
target_compile_options(${target} PRIVATE "-w")
endif()
target_compile_options(${target} PRIVATE "-w")
endfunction()
function(detect_operating_system)
message(STATUS "CMake Version: ${CMAKE_VERSION}")
message(STATUS "CMake System Name: ${CMAKE_SYSTEM_NAME}")
message(STATUS "CMake Version: ${CMAKE_VERSION}")
message(STATUS "CMake System Name: ${CMAKE_SYSTEM_NAME}")
# LINUX wasn't added until CMake 3.25.
if (CMAKE_VERSION VERSION_LESS 3.25.0 AND CMAKE_SYSTEM_NAME MATCHES "Linux")
# Have to make it visible in this scope as well for below.
set(LINUX TRUE PARENT_SCOPE)
set(LINUX TRUE)
endif()
# LINUX wasn't added until CMake 3.25.
if (CMAKE_VERSION VERSION_LESS 3.25.0 AND CMAKE_SYSTEM_NAME MATCHES "Linux")
# Have to make it visible in this scope as well for below.
set(LINUX TRUE PARENT_SCOPE)
set(LINUX TRUE)
endif()
if(WIN32)
message(STATUS "Building for Windows.")
elseif(APPLE AND NOT IOS)
message(STATUS "Building for MacOS.")
elseif(LINUX)
message(STATUS "Building for Linux.")
elseif(BSD)
message(STATUS "Building for *BSD.")
else()
message(FATAL_ERROR "Unsupported platform.")
endif()
if(WIN32)
message(FATAL_ERROR "Building for Windows with CMake is not supported. "
"Open the solution file with Visual Studio.")
elseif(APPLE AND NOT IOS)
message(STATUS "Building for MacOS.")
elseif(LINUX)
message(STATUS "Building for Linux.")
elseif(BSD)
message(STATUS "Building for *BSD.")
else()
message(FATAL_ERROR "Unsupported platform.")
endif()
endfunction()
function(detect_compiler)
if(MSVC AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(COMPILER_CLANG_CL TRUE PARENT_SCOPE)
set(IS_SUPPORTED_COMPILER TRUE PARENT_SCOPE)
message(STATUS "Building with Clang-CL.")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
set(COMPILER_CLANG TRUE PARENT_SCOPE)
set(IS_SUPPORTED_COMPILER TRUE PARENT_SCOPE)
message(STATUS "Building with Clang/LLVM.")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(COMPILER_GCC TRUE PARENT_SCOPE)
set(IS_SUPPORTED_COMPILER FALSE PARENT_SCOPE)
message(STATUS "Building with GNU GCC.")
elseif(MSVC)
set(IS_SUPPORTED_COMPILER TRUE PARENT_SCOPE)
message(STATUS "Building with MSVC.")
else()
message(FATAL_ERROR "Unknown compiler: ${CMAKE_CXX_COMPILER_ID}")
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
set(COMPILER_CLANG TRUE PARENT_SCOPE)
set(IS_SUPPORTED_COMPILER TRUE PARENT_SCOPE)
message(STATUS "Building with Clang/LLVM.")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(COMPILER_GCC TRUE PARENT_SCOPE)
set(IS_SUPPORTED_COMPILER FALSE PARENT_SCOPE)
message(STATUS "Building with GNU GCC.")
else()
message(FATAL_ERROR "Unknown compiler: ${CMAKE_CXX_COMPILER_ID}")
endif()
endfunction()
function(detect_architecture)
@@ -71,13 +67,9 @@ function(detect_architecture)
CMAKE_SIZEOF_VOID_P EQUAL 8)
message(STATUS "Building x86_64 binaries.")
set(CPU_ARCH_X64 TRUE PARENT_SCOPE)
if(NOT MSVC OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT DISABLE_SSE4)
if(NOT DISABLE_SSE4)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1" PARENT_SCOPE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1" PARENT_SCOPE)
elseif(MSVC AND NOT DISABLE_SSE4)
# Clang defines these macros, MSVC does not.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D__SSE3__ /D__SSE4_1__" PARENT_SCOPE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D__SSE3__ /D__SSE4_1__" PARENT_SCOPE)
endif()
elseif(("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64" OR "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm64") AND
CMAKE_SIZEOF_VOID_P EQUAL 8) # Might have an A64 kernel, e.g. Raspbian.