mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
Merge pull request #10620 from phire/cmake_win_fixes
Various fixes for msvc/cmake builds
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
include(RemoveCompileFlag)
|
||||
|
||||
macro(dolphin_disable_warnings_msvc _target)
|
||||
if (MSVC)
|
||||
get_target_property(_target_cxx_flags ${_target} COMPILE_OPTIONS)
|
||||
if (_target_cxx_flags)
|
||||
set(new_flags "")
|
||||
foreach(flag IN LISTS _target_cxx_flags)
|
||||
# all warning flags start with "/W" or "/w" or "-W" or "-w"
|
||||
if (NOT "${flag}" MATCHES "^[-/][Ww]")
|
||||
list(APPEND new_flags "${flag}")
|
||||
endif()
|
||||
endforeach()
|
||||
set_target_properties(${_target} PROPERTIES COMPILE_OPTIONS "${new_flags}")
|
||||
endif()
|
||||
target_compile_options(${_target} PRIVATE "/W0")
|
||||
endif()
|
||||
endmacro()
|
||||
@@ -0,0 +1,16 @@
|
||||
# from https://stackoverflow.com/a/49216539
|
||||
# The linked answer does some weird preconfiguring by manually splitting the CMAKE_CXX_FLAGS variable and applying it to a target,
|
||||
# but as far as I can tell none of that is necessary, this works just fine as-is.
|
||||
|
||||
#
|
||||
# Removes the specified compile flag from the specified target.
|
||||
# _target - The target to remove the compile flag from
|
||||
# _flag - The compile flag to remove
|
||||
#
|
||||
macro(remove_cxx_flag_from_target _target _flag)
|
||||
get_target_property(_target_cxx_flags ${_target} COMPILE_OPTIONS)
|
||||
if(_target_cxx_flags)
|
||||
list(REMOVE_ITEM _target_cxx_flags ${_flag})
|
||||
set_target_properties(${_target} PROPERTIES COMPILE_OPTIONS "${_target_cxx_flags}")
|
||||
endif()
|
||||
endmacro()
|
||||
+81
-6
@@ -3,13 +3,21 @@
|
||||
#
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
# Weird chicken-and-egg problem: We can't check the compiler before the project() call, but we have to set the policies before it.
|
||||
# So we do this in two steps: Set the policies if they exist, then error out afterwards if we end up being MSVC and they don't exist.
|
||||
if (POLICY CMP0117)
|
||||
cmake_policy(SET CMP0091 NEW) # MSVC runtime library flags are selected by an abstraction.
|
||||
cmake_policy(SET CMP0092 NEW) # MSVC warning flags are not in CMAKE_{C,CXX}_FLAGS by default.
|
||||
cmake_policy(SET CMP0117 NEW) # MSVC RTTI flag will not be added by default.
|
||||
endif()
|
||||
|
||||
# Minimum OS X version.
|
||||
# This is inserted into the Info.plist as well.
|
||||
|
||||
# MacOS prior to 10.14 did not support aligned alloc which is used to implement
|
||||
# std::unique_ptr in the arm64 C++ standard library. x86_64 builds can override
|
||||
# this to 10.13.0 using -DCMAKE_OSX_DEPLOYMENT_TARGET="10.13.0" without issue.
|
||||
# This is done in the universal binary building script to build a binary that
|
||||
# This is done in the universal binary building script to build a binary that
|
||||
# runs on 10.13 on x86_64 computers, while still containing an arm64 slice.
|
||||
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14.0" CACHE STRING "")
|
||||
@@ -18,6 +26,18 @@ set(CMAKE_USER_MAKE_RULES_OVERRIDE "CMake/FlagsOverride.cmake")
|
||||
|
||||
project(dolphin-emu)
|
||||
|
||||
if (MSVC)
|
||||
if (POLICY CMP0117)
|
||||
# cmake is a weird language. You can't do if(not POLICY)
|
||||
else()
|
||||
message(FATAL_ERROR "Please update to CMake 3.20 or higher.")
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
endif()
|
||||
|
||||
# Name of the Dolphin distributor. If you redistribute Dolphin builds (forks,
|
||||
# unofficial builds) please consider identifying your distribution with a
|
||||
# unique name here.
|
||||
@@ -78,7 +98,7 @@ endif()
|
||||
|
||||
if(APPLE)
|
||||
option(MACOS_USE_DEFAULT_SEARCH_PATH "Don't prioritize system library paths" OFF)
|
||||
option(SKIP_POSTPROCESS_BUNDLE "Skip postprocessing bundle for redistributability" OFF)
|
||||
option(SKIP_POSTPROCESS_BUNDLE "Skip postprocessing bundle for redistributability" OFF)
|
||||
# Enable adhoc code signing by default (otherwise makefile builds on ARM will not work)
|
||||
option(MACOS_CODE_SIGNING "Enable codesigning" ON)
|
||||
set(MACOS_CODE_SIGNING_IDENTITY "-" CACHE STRING "The identity used for codesigning.")
|
||||
@@ -108,6 +128,8 @@ include(CheckAndAddFlag)
|
||||
include(CheckCCompilerFlag)
|
||||
include(CheckVendoringApproved)
|
||||
include(DolphinCompileDefinitions)
|
||||
include(DolphinDisableWarningsMSVC)
|
||||
include(RemoveCompileFlag)
|
||||
|
||||
# Enable folders for IDE
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
@@ -244,16 +266,60 @@ elseif(CMAKE_GENERATOR MATCHES "Visual Studio")
|
||||
add_compile_options("/MP")
|
||||
endif()
|
||||
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
|
||||
if(MSVC)
|
||||
check_and_add_flag(EXCEPTIONS /EHsc)
|
||||
dolphin_compile_definitions(_DEBUG DEBUG_ONLY)
|
||||
|
||||
# Disable RTTI
|
||||
add_compile_options(/GR-)
|
||||
|
||||
# Set warning level 4 (the highest)
|
||||
add_compile_options(/W4)
|
||||
|
||||
# Treat all warnings as errors
|
||||
add_compile_options(/WX)
|
||||
|
||||
# Disable some warnings
|
||||
add_compile_options(
|
||||
/wd4201 # nonstandard extension used : nameless struct/union
|
||||
/wd4127 # conditional expression is constant
|
||||
/wd4100 # 'identifier' : unreferenced formal parameter
|
||||
/wd4200 # InputCommon fix temp.
|
||||
/wd4244 # 'conversion' conversion from 'type1' to 'type2', possible loss of data
|
||||
/wd4121 # 'symbol' : alignment of a member was sensitive to packing
|
||||
/wd4324 # Padding was added at the end of a structure because you specified a __declspec(align) value.
|
||||
/wd4714 # function 'function' marked as __forceinline not inlined
|
||||
/wd4351 # new behavior: elements of array 'array' will be default initialized
|
||||
# TODO: Enable this warning once possible
|
||||
/wd4245 # conversion from 'type1' to 'type2', signed/unsigned mismatch
|
||||
# Currently jits use some annoying code patterns which makes this common
|
||||
)
|
||||
|
||||
# Additional warnings
|
||||
add_compile_options(
|
||||
/w44263 # Non-virtual member function hides base class virtual function
|
||||
/w44265 # Class has virtual functions, but destructor is not virtual
|
||||
/w44946 # Reinterpret cast between related types
|
||||
)
|
||||
|
||||
# All files are encoded as UTF-8
|
||||
add_compile_options(/utf-8)
|
||||
|
||||
# Ignore warnings in external headers
|
||||
add_compile_options(/external:anglebrackets)
|
||||
add_compile_options(/external:W0)
|
||||
add_compile_options(/external:templates-)
|
||||
|
||||
# Request deterministic builds
|
||||
add_compile_options(/experimental:deterministic)
|
||||
add_link_options(/experimental:deterministic)
|
||||
|
||||
# Enable function-level linking
|
||||
add_compile_options(/Gy)
|
||||
# Generate intrinsic functions
|
||||
add_compile_options(/Oi)
|
||||
# Disable buffer security check
|
||||
add_compile_options(/GS-)
|
||||
# Enable buffer security check on Debug, disable otherwise
|
||||
add_compile_options($<IF:$<CONFIG:Debug>,/GS,/GS->)
|
||||
# Enforce C++ standard conforming conversion rules to catch possible bugs
|
||||
add_compile_options(/permissive-)
|
||||
# Remove unreferenced inline functions/data to reduce link time and catch bugs
|
||||
@@ -272,6 +338,9 @@ if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
|
||||
/wd5105 # macro expansion producing 'defined' has undefined behavior
|
||||
)
|
||||
|
||||
# Use 'precise' floating point model
|
||||
add_compile_options(/fp:precise)
|
||||
|
||||
string(APPEND CMAKE_EXE_LINKER_FLAGS " /NXCOMPAT")
|
||||
# Generate debug data
|
||||
string(APPEND CMAKE_EXE_LINKER_FLAGS " /DEBUG")
|
||||
@@ -494,7 +563,7 @@ if(ENCODE_FRAMEDUMPS)
|
||||
endif()
|
||||
find_package(FFmpeg COMPONENTS avcodec avformat avutil swresample swscale)
|
||||
if(FFmpeg_FOUND)
|
||||
if(APPLE)
|
||||
if(APPLE)
|
||||
find_library(COREMEDIA_LIBRARY CoreMedia)
|
||||
find_library(VIDEOTOOLBOX_LIBRARY VideoToolbox)
|
||||
find_library(COREVIDEO_LIBRARY CoreVideo)
|
||||
@@ -502,6 +571,12 @@ if(ENCODE_FRAMEDUMPS)
|
||||
endif()
|
||||
message(STATUS "libav/ffmpeg found, enabling AVI frame dumps")
|
||||
add_definitions(-DHAVE_FFMPEG)
|
||||
if(WIN32)
|
||||
# Our prebuilt binaries depend on Bcrypt
|
||||
set_property(TARGET FFmpeg::avutil APPEND PROPERTY
|
||||
INTERFACE_LINK_LIBRARIES "Bcrypt.lib"
|
||||
)
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "libav/ffmpeg not found, disabling AVI frame dumps")
|
||||
endif()
|
||||
|
||||
+8
-8
@@ -10,8 +10,8 @@
|
||||
"cmakeCommandArgs": "",
|
||||
"variables": [
|
||||
{
|
||||
"name": "QT_DIR",
|
||||
"value": "${workspaceRoot}\\Externals\\Qt\\Qt6.3.0\\x64\\lib\\cmake\\Qt6"
|
||||
"name": "CMAKE_PREFIX_PATH",
|
||||
"value": "${workspaceRoot}\\Externals\\Qt\\Qt6.3.0\\x64"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -25,8 +25,8 @@
|
||||
"cmakeCommandArgs": "",
|
||||
"variables": [
|
||||
{
|
||||
"name": "QT_DIR",
|
||||
"value": "${workspaceRoot}\\Externals\\Qt\\Qt6.3.0\\x64\\lib\\cmake\\Qt6"
|
||||
"name": "CMAKE_PREFIX_PATH",
|
||||
"value": "${workspaceRoot}\\Externals\\Qt\\Qt6.3.0\\x64"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -40,8 +40,8 @@
|
||||
"cmakeCommandArgs": "",
|
||||
"variables": [
|
||||
{
|
||||
"name": "QT_DIR",
|
||||
"value": "${workspaceRoot}\\Externals\\Qt\\Qt6.3.0\\ARM64\\lib\\cmake\\Qt6"
|
||||
"name": "CMAKE_PREFIX_PATH",
|
||||
"value": "${workspaceRoot}\\Externals\\Qt\\Qt6.3.0\\ARM64"
|
||||
},
|
||||
{
|
||||
"name": "CMAKE_SYSTEM_NAME",
|
||||
@@ -63,8 +63,8 @@
|
||||
"cmakeCommandArgs": "",
|
||||
"variables": [
|
||||
{
|
||||
"name": "QT_DIR",
|
||||
"value": "${workspaceRoot}\\Externals\\Qt\\Qt6.3.0\\ARM64\\lib\\cmake\\Qt6"
|
||||
"name": "CMAKE_PREFIX_PATH",
|
||||
"value": "${workspaceRoot}\\Externals\\Qt\\Qt6.3.0\\ARM64"
|
||||
},
|
||||
{
|
||||
"name": "CMAKE_SYSTEM_NAME",
|
||||
|
||||
+1
@@ -4,6 +4,7 @@ add_library(bdisasm STATIC
|
||||
resolve.cc
|
||||
syntax.cc
|
||||
)
|
||||
dolphin_disable_warnings_msvc(bdisasm)
|
||||
|
||||
if (WIN32)
|
||||
target_sources(bdisasm
|
||||
|
||||
+6
-3
@@ -1,6 +1,8 @@
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
if (NOT MSVC)
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
endif()
|
||||
|
||||
set(SRCS
|
||||
source/ChannelMaps.cpp
|
||||
@@ -10,5 +12,6 @@ set(SRCS
|
||||
)
|
||||
|
||||
add_library(FreeSurround STATIC ${SRCS})
|
||||
dolphin_disable_warnings_msvc(FreeSurround)
|
||||
target_include_directories(FreeSurround PUBLIC include)
|
||||
target_compile_options(FreeSurround PRIVATE -w)
|
||||
|
||||
Vendored
+1
@@ -1,6 +1,7 @@
|
||||
add_library(lzo2 STATIC
|
||||
minilzo.c
|
||||
)
|
||||
dolphin_disable_warnings_msvc(lzo2)
|
||||
|
||||
target_include_directories(lzo2
|
||||
PUBLIC
|
||||
|
||||
Vendored
+1
-1
Submodule Externals/Qt updated: 9498dbe942...376baafde6
Vendored
+2
@@ -25,3 +25,5 @@ set(SRC_SYSTEM
|
||||
|
||||
add_library(sfml-network ${SRC_NETWORK})
|
||||
add_library(sfml-system ${SRC_SYSTEM})
|
||||
dolphin_disable_warnings_msvc(sfml-network)
|
||||
dolphin_disable_warnings_msvc(sfml-system)
|
||||
|
||||
+3
-1
@@ -1,7 +1,9 @@
|
||||
|
||||
# Compilers often don't use the latest C++ standard as the default. Periodically update this value (possibly conditioned
|
||||
# on compiler) as new standards are ratified/support is available
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
if (NOT MSVC)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
endif()
|
||||
|
||||
project(witest.cpplatest)
|
||||
add_executable(witest.cpplatest)
|
||||
|
||||
Vendored
+1
@@ -70,6 +70,7 @@ set(BZIP2_SRCS
|
||||
|
||||
add_library(bzip2 STATIC ${BZIP2_SRCS} ${BZIP2_PUBLIC_HDRS} ${BZIP2_PRIVATE_HDRS})
|
||||
add_library(BZip2::BZip2 ALIAS bzip2)
|
||||
dolphin_disable_warnings_msvc(bzip2)
|
||||
|
||||
target_include_directories(bzip2
|
||||
PUBLIC
|
||||
|
||||
+1
@@ -3,4 +3,5 @@ check_and_add_flag(CXX11 -std=c++11)
|
||||
set(SRCS OptionParser.cpp OptionParser.h)
|
||||
|
||||
add_library(cpp-optparse STATIC ${SRCS})
|
||||
dolphin_disable_warnings_msvc(cpp-optparse)
|
||||
target_include_directories(cpp-optparse PUBLIC .)
|
||||
|
||||
Vendored
+8
-3
@@ -15,9 +15,12 @@ endif()
|
||||
if(POLICY CMP0063)
|
||||
cmake_policy(SET CMP0063 NEW)
|
||||
endif()
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
if (NOT MSVC)
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
endif()
|
||||
|
||||
if(NOT COMMAND add_sanitizers)
|
||||
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/sanitizers-cmake/cmake")
|
||||
@@ -45,6 +48,7 @@ add_library(cubeb
|
||||
src/cubeb_log.cpp
|
||||
src/cubeb_strings.c
|
||||
$<TARGET_OBJECTS:speex>)
|
||||
dolphin_disable_warnings_msvc(cubeb)
|
||||
target_include_directories(cubeb
|
||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>
|
||||
)
|
||||
@@ -97,6 +101,7 @@ install(
|
||||
|
||||
add_library(speex OBJECT
|
||||
src/speex/resample.c)
|
||||
dolphin_disable_warnings_msvc(speex)
|
||||
set_target_properties(speex PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
|
||||
target_compile_definitions(speex PRIVATE OUTSIDE_SPEEX)
|
||||
target_compile_definitions(speex PRIVATE FLOATING_POINT)
|
||||
|
||||
Vendored
+1
@@ -12,6 +12,7 @@ add_library(
|
||||
STATIC
|
||||
${SRCS}
|
||||
)
|
||||
dolphin_disable_warnings_msvc(curl)
|
||||
|
||||
target_link_libraries(curl ${MBEDTLS_LIBRARIES} z)
|
||||
target_compile_definitions(curl PUBLIC CURL_STATICLIB PRIVATE CURL_DISABLE_LDAP)
|
||||
|
||||
+4
-1
@@ -4,7 +4,9 @@ option(ENABLE_IO_THREAD "Start up a separate I/O thread, otherwise I'd need to c
|
||||
option(USE_STATIC_CRT "Use /MT[d] for dynamic library" OFF)
|
||||
option(WARNINGS_AS_ERRORS "When enabled, compiles with `-Werror` (on *nix platforms)." OFF)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
if (NOT MSVC)
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
endif()
|
||||
|
||||
set(BASE_RPC_SRC
|
||||
${PROJECT_SOURCE_DIR}/include/discord_rpc.h
|
||||
@@ -29,6 +31,7 @@ if(WIN32)
|
||||
add_definitions(-DDISCORD_WINDOWS)
|
||||
set(BASE_RPC_SRC ${BASE_RPC_SRC} connection_win.cpp discord_register_win.cpp)
|
||||
add_library(discord-rpc ${BASE_RPC_SRC})
|
||||
dolphin_disable_warnings_msvc(discord-rpc)
|
||||
if (MSVC)
|
||||
if(USE_STATIC_CRT)
|
||||
foreach(CompilerFlag
|
||||
|
||||
Vendored
+1
@@ -11,3 +11,4 @@ add_library(ed25519
|
||||
sc.c
|
||||
sha512.c
|
||||
verify.c)
|
||||
dolphin_disable_warnings_msvc(ed25519)
|
||||
|
||||
Vendored
+1
@@ -72,6 +72,7 @@ add_library(enet STATIC
|
||||
unix.c
|
||||
win32.c
|
||||
)
|
||||
dolphin_disable_warnings_msvc(enet)
|
||||
if(HAIKU)
|
||||
target_link_libraries(enet network)
|
||||
endif(HAIKU)
|
||||
|
||||
Vendored
+1
@@ -229,6 +229,7 @@ else()
|
||||
endif ()
|
||||
|
||||
add_library(fmt ${FMT_SOURCES} ${FMT_HEADERS} README.rst ChangeLog.rst)
|
||||
dolphin_disable_warnings_msvc(fmt)
|
||||
add_library(fmt::fmt ALIAS fmt)
|
||||
|
||||
if (FMT_WERROR)
|
||||
|
||||
Vendored
+1
@@ -73,6 +73,7 @@ endif()
|
||||
endif()
|
||||
|
||||
add_library(glslang STATIC ${SRCS})
|
||||
dolphin_disable_warnings_msvc(glslang)
|
||||
|
||||
target_include_directories(glslang
|
||||
PRIVATE
|
||||
|
||||
Vendored
+1
@@ -1,6 +1,7 @@
|
||||
project(hidapi)
|
||||
|
||||
add_library(hidapi STATIC hidapi/hidapi.h)
|
||||
dolphin_disable_warnings_msvc(hidapi)
|
||||
target_include_directories(hidapi PUBLIC hidapi)
|
||||
|
||||
if(APPLE)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user