mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-09 23:59:27 +01:00
Merge pull request #10620 from phire/cmake_win_fixes
Various fixes for msvc/cmake builds
This commit is contained in:
commit
0e948f3e21
18
CMake/DolphinDisableWarningsMSVC.cmake
Normal file
18
CMake/DolphinDisableWarningsMSVC.cmake
Normal file
@ -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()
|
16
CMake/RemoveCompileFlag.cmake
Normal file
16
CMake/RemoveCompileFlag.cmake
Normal file
@ -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()
|
@ -3,6 +3,14 @@
|
|||||||
#
|
#
|
||||||
cmake_minimum_required(VERSION 3.10)
|
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.
|
# Minimum OS X version.
|
||||||
# This is inserted into the Info.plist as well.
|
# This is inserted into the Info.plist as well.
|
||||||
|
|
||||||
@ -18,6 +26,18 @@ set(CMAKE_USER_MAKE_RULES_OVERRIDE "CMake/FlagsOverride.cmake")
|
|||||||
|
|
||||||
project(dolphin-emu)
|
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,
|
# Name of the Dolphin distributor. If you redistribute Dolphin builds (forks,
|
||||||
# unofficial builds) please consider identifying your distribution with a
|
# unofficial builds) please consider identifying your distribution with a
|
||||||
# unique name here.
|
# unique name here.
|
||||||
@ -108,6 +128,8 @@ include(CheckAndAddFlag)
|
|||||||
include(CheckCCompilerFlag)
|
include(CheckCCompilerFlag)
|
||||||
include(CheckVendoringApproved)
|
include(CheckVendoringApproved)
|
||||||
include(DolphinCompileDefinitions)
|
include(DolphinCompileDefinitions)
|
||||||
|
include(DolphinDisableWarningsMSVC)
|
||||||
|
include(RemoveCompileFlag)
|
||||||
|
|
||||||
# Enable folders for IDE
|
# Enable folders for IDE
|
||||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||||
@ -244,16 +266,60 @@ elseif(CMAKE_GENERATOR MATCHES "Visual Studio")
|
|||||||
add_compile_options("/MP")
|
add_compile_options("/MP")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
|
if(MSVC)
|
||||||
check_and_add_flag(EXCEPTIONS /EHsc)
|
check_and_add_flag(EXCEPTIONS /EHsc)
|
||||||
dolphin_compile_definitions(_DEBUG DEBUG_ONLY)
|
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
|
# Enable function-level linking
|
||||||
add_compile_options(/Gy)
|
add_compile_options(/Gy)
|
||||||
# Generate intrinsic functions
|
# Generate intrinsic functions
|
||||||
add_compile_options(/Oi)
|
add_compile_options(/Oi)
|
||||||
# Disable buffer security check
|
# Enable buffer security check on Debug, disable otherwise
|
||||||
add_compile_options(/GS-)
|
add_compile_options($<IF:$<CONFIG:Debug>,/GS,/GS->)
|
||||||
# Enforce C++ standard conforming conversion rules to catch possible bugs
|
# Enforce C++ standard conforming conversion rules to catch possible bugs
|
||||||
add_compile_options(/permissive-)
|
add_compile_options(/permissive-)
|
||||||
# Remove unreferenced inline functions/data to reduce link time and catch bugs
|
# 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
|
/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")
|
string(APPEND CMAKE_EXE_LINKER_FLAGS " /NXCOMPAT")
|
||||||
# Generate debug data
|
# Generate debug data
|
||||||
string(APPEND CMAKE_EXE_LINKER_FLAGS " /DEBUG")
|
string(APPEND CMAKE_EXE_LINKER_FLAGS " /DEBUG")
|
||||||
@ -502,6 +571,12 @@ if(ENCODE_FRAMEDUMPS)
|
|||||||
endif()
|
endif()
|
||||||
message(STATUS "libav/ffmpeg found, enabling AVI frame dumps")
|
message(STATUS "libav/ffmpeg found, enabling AVI frame dumps")
|
||||||
add_definitions(-DHAVE_FFMPEG)
|
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()
|
else()
|
||||||
message(STATUS "libav/ffmpeg not found, disabling AVI frame dumps")
|
message(STATUS "libav/ffmpeg not found, disabling AVI frame dumps")
|
||||||
endif()
|
endif()
|
||||||
|
@ -10,8 +10,8 @@
|
|||||||
"cmakeCommandArgs": "",
|
"cmakeCommandArgs": "",
|
||||||
"variables": [
|
"variables": [
|
||||||
{
|
{
|
||||||
"name": "QT_DIR",
|
"name": "CMAKE_PREFIX_PATH",
|
||||||
"value": "${workspaceRoot}\\Externals\\Qt\\Qt6.3.0\\x64\\lib\\cmake\\Qt6"
|
"value": "${workspaceRoot}\\Externals\\Qt\\Qt6.3.0\\x64"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -25,8 +25,8 @@
|
|||||||
"cmakeCommandArgs": "",
|
"cmakeCommandArgs": "",
|
||||||
"variables": [
|
"variables": [
|
||||||
{
|
{
|
||||||
"name": "QT_DIR",
|
"name": "CMAKE_PREFIX_PATH",
|
||||||
"value": "${workspaceRoot}\\Externals\\Qt\\Qt6.3.0\\x64\\lib\\cmake\\Qt6"
|
"value": "${workspaceRoot}\\Externals\\Qt\\Qt6.3.0\\x64"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -40,8 +40,8 @@
|
|||||||
"cmakeCommandArgs": "",
|
"cmakeCommandArgs": "",
|
||||||
"variables": [
|
"variables": [
|
||||||
{
|
{
|
||||||
"name": "QT_DIR",
|
"name": "CMAKE_PREFIX_PATH",
|
||||||
"value": "${workspaceRoot}\\Externals\\Qt\\Qt6.3.0\\ARM64\\lib\\cmake\\Qt6"
|
"value": "${workspaceRoot}\\Externals\\Qt\\Qt6.3.0\\ARM64"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "CMAKE_SYSTEM_NAME",
|
"name": "CMAKE_SYSTEM_NAME",
|
||||||
@ -63,8 +63,8 @@
|
|||||||
"cmakeCommandArgs": "",
|
"cmakeCommandArgs": "",
|
||||||
"variables": [
|
"variables": [
|
||||||
{
|
{
|
||||||
"name": "QT_DIR",
|
"name": "CMAKE_PREFIX_PATH",
|
||||||
"value": "${workspaceRoot}\\Externals\\Qt\\Qt6.3.0\\ARM64\\lib\\cmake\\Qt6"
|
"value": "${workspaceRoot}\\Externals\\Qt\\Qt6.3.0\\ARM64"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "CMAKE_SYSTEM_NAME",
|
"name": "CMAKE_SYSTEM_NAME",
|
||||||
|
1
Externals/Bochs_disasm/CMakeLists.txt
vendored
1
Externals/Bochs_disasm/CMakeLists.txt
vendored
@ -4,6 +4,7 @@ add_library(bdisasm STATIC
|
|||||||
resolve.cc
|
resolve.cc
|
||||||
syntax.cc
|
syntax.cc
|
||||||
)
|
)
|
||||||
|
dolphin_disable_warnings_msvc(bdisasm)
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
target_sources(bdisasm
|
target_sources(bdisasm
|
||||||
|
9
Externals/FreeSurround/CMakeLists.txt
vendored
9
Externals/FreeSurround/CMakeLists.txt
vendored
@ -1,6 +1,8 @@
|
|||||||
set(CMAKE_CXX_STANDARD 14)
|
if (NOT MSVC)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
set(SRCS
|
set(SRCS
|
||||||
source/ChannelMaps.cpp
|
source/ChannelMaps.cpp
|
||||||
@ -10,5 +12,6 @@ set(SRCS
|
|||||||
)
|
)
|
||||||
|
|
||||||
add_library(FreeSurround STATIC ${SRCS})
|
add_library(FreeSurround STATIC ${SRCS})
|
||||||
|
dolphin_disable_warnings_msvc(FreeSurround)
|
||||||
target_include_directories(FreeSurround PUBLIC include)
|
target_include_directories(FreeSurround PUBLIC include)
|
||||||
target_compile_options(FreeSurround PRIVATE -w)
|
target_compile_options(FreeSurround PRIVATE -w)
|
||||||
|
1
Externals/LZO/CMakeLists.txt
vendored
1
Externals/LZO/CMakeLists.txt
vendored
@ -1,6 +1,7 @@
|
|||||||
add_library(lzo2 STATIC
|
add_library(lzo2 STATIC
|
||||||
minilzo.c
|
minilzo.c
|
||||||
)
|
)
|
||||||
|
dolphin_disable_warnings_msvc(lzo2)
|
||||||
|
|
||||||
target_include_directories(lzo2
|
target_include_directories(lzo2
|
||||||
PUBLIC
|
PUBLIC
|
||||||
|
2
Externals/Qt
vendored
2
Externals/Qt
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 9498dbe9421a80da674212fee0bf745883464992
|
Subproject commit 376baafde6cce2f8892c34c17ed397afa6c46d08
|
2
Externals/SFML/CMakeLists.txt
vendored
2
Externals/SFML/CMakeLists.txt
vendored
@ -25,3 +25,5 @@ set(SRC_SYSTEM
|
|||||||
|
|
||||||
add_library(sfml-network ${SRC_NETWORK})
|
add_library(sfml-network ${SRC_NETWORK})
|
||||||
add_library(sfml-system ${SRC_SYSTEM})
|
add_library(sfml-system ${SRC_SYSTEM})
|
||||||
|
dolphin_disable_warnings_msvc(sfml-network)
|
||||||
|
dolphin_disable_warnings_msvc(sfml-system)
|
||||||
|
4
Externals/WIL/tests/cpplatest/CMakeLists.txt
vendored
4
Externals/WIL/tests/cpplatest/CMakeLists.txt
vendored
@ -1,7 +1,9 @@
|
|||||||
|
|
||||||
# Compilers often don't use the latest C++ standard as the default. Periodically update this value (possibly conditioned
|
# 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
|
# 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)
|
project(witest.cpplatest)
|
||||||
add_executable(witest.cpplatest)
|
add_executable(witest.cpplatest)
|
||||||
|
1
Externals/bzip2/CMakeLists.txt
vendored
1
Externals/bzip2/CMakeLists.txt
vendored
@ -70,6 +70,7 @@ set(BZIP2_SRCS
|
|||||||
|
|
||||||
add_library(bzip2 STATIC ${BZIP2_SRCS} ${BZIP2_PUBLIC_HDRS} ${BZIP2_PRIVATE_HDRS})
|
add_library(bzip2 STATIC ${BZIP2_SRCS} ${BZIP2_PUBLIC_HDRS} ${BZIP2_PRIVATE_HDRS})
|
||||||
add_library(BZip2::BZip2 ALIAS bzip2)
|
add_library(BZip2::BZip2 ALIAS bzip2)
|
||||||
|
dolphin_disable_warnings_msvc(bzip2)
|
||||||
|
|
||||||
target_include_directories(bzip2
|
target_include_directories(bzip2
|
||||||
PUBLIC
|
PUBLIC
|
||||||
|
1
Externals/cpp-optparse/CMakeLists.txt
vendored
1
Externals/cpp-optparse/CMakeLists.txt
vendored
@ -3,4 +3,5 @@ check_and_add_flag(CXX11 -std=c++11)
|
|||||||
set(SRCS OptionParser.cpp OptionParser.h)
|
set(SRCS OptionParser.cpp OptionParser.h)
|
||||||
|
|
||||||
add_library(cpp-optparse STATIC ${SRCS})
|
add_library(cpp-optparse STATIC ${SRCS})
|
||||||
|
dolphin_disable_warnings_msvc(cpp-optparse)
|
||||||
target_include_directories(cpp-optparse PUBLIC .)
|
target_include_directories(cpp-optparse PUBLIC .)
|
||||||
|
11
Externals/cubeb/CMakeLists.txt
vendored
11
Externals/cubeb/CMakeLists.txt
vendored
@ -15,9 +15,12 @@ endif()
|
|||||||
if(POLICY CMP0063)
|
if(POLICY CMP0063)
|
||||||
cmake_policy(SET CMP0063 NEW)
|
cmake_policy(SET CMP0063 NEW)
|
||||||
endif()
|
endif()
|
||||||
set(CMAKE_C_STANDARD 99)
|
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
if (NOT MSVC)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_C_STANDARD 99)
|
||||||
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(NOT COMMAND add_sanitizers)
|
if(NOT COMMAND add_sanitizers)
|
||||||
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/sanitizers-cmake/cmake")
|
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_log.cpp
|
||||||
src/cubeb_strings.c
|
src/cubeb_strings.c
|
||||||
$<TARGET_OBJECTS:speex>)
|
$<TARGET_OBJECTS:speex>)
|
||||||
|
dolphin_disable_warnings_msvc(cubeb)
|
||||||
target_include_directories(cubeb
|
target_include_directories(cubeb
|
||||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>
|
||||||
)
|
)
|
||||||
@ -97,6 +101,7 @@ install(
|
|||||||
|
|
||||||
add_library(speex OBJECT
|
add_library(speex OBJECT
|
||||||
src/speex/resample.c)
|
src/speex/resample.c)
|
||||||
|
dolphin_disable_warnings_msvc(speex)
|
||||||
set_target_properties(speex PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
|
set_target_properties(speex PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
|
||||||
target_compile_definitions(speex PRIVATE OUTSIDE_SPEEX)
|
target_compile_definitions(speex PRIVATE OUTSIDE_SPEEX)
|
||||||
target_compile_definitions(speex PRIVATE FLOATING_POINT)
|
target_compile_definitions(speex PRIVATE FLOATING_POINT)
|
||||||
|
1
Externals/curl/lib/CMakeLists.txt
vendored
1
Externals/curl/lib/CMakeLists.txt
vendored
@ -12,6 +12,7 @@ add_library(
|
|||||||
STATIC
|
STATIC
|
||||||
${SRCS}
|
${SRCS}
|
||||||
)
|
)
|
||||||
|
dolphin_disable_warnings_msvc(curl)
|
||||||
|
|
||||||
target_link_libraries(curl ${MBEDTLS_LIBRARIES} z)
|
target_link_libraries(curl ${MBEDTLS_LIBRARIES} z)
|
||||||
target_compile_definitions(curl PUBLIC CURL_STATICLIB PRIVATE CURL_DISABLE_LDAP)
|
target_compile_definitions(curl PUBLIC CURL_STATICLIB PRIVATE CURL_DISABLE_LDAP)
|
||||||
|
5
Externals/discord-rpc/src/CMakeLists.txt
vendored
5
Externals/discord-rpc/src/CMakeLists.txt
vendored
@ -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(USE_STATIC_CRT "Use /MT[d] for dynamic library" OFF)
|
||||||
option(WARNINGS_AS_ERRORS "When enabled, compiles with `-Werror` (on *nix platforms)." 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
|
set(BASE_RPC_SRC
|
||||||
${PROJECT_SOURCE_DIR}/include/discord_rpc.h
|
${PROJECT_SOURCE_DIR}/include/discord_rpc.h
|
||||||
@ -29,6 +31,7 @@ if(WIN32)
|
|||||||
add_definitions(-DDISCORD_WINDOWS)
|
add_definitions(-DDISCORD_WINDOWS)
|
||||||
set(BASE_RPC_SRC ${BASE_RPC_SRC} connection_win.cpp discord_register_win.cpp)
|
set(BASE_RPC_SRC ${BASE_RPC_SRC} connection_win.cpp discord_register_win.cpp)
|
||||||
add_library(discord-rpc ${BASE_RPC_SRC})
|
add_library(discord-rpc ${BASE_RPC_SRC})
|
||||||
|
dolphin_disable_warnings_msvc(discord-rpc)
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
if(USE_STATIC_CRT)
|
if(USE_STATIC_CRT)
|
||||||
foreach(CompilerFlag
|
foreach(CompilerFlag
|
||||||
|
1
Externals/ed25519/CMakeLists.txt
vendored
1
Externals/ed25519/CMakeLists.txt
vendored
@ -11,3 +11,4 @@ add_library(ed25519
|
|||||||
sc.c
|
sc.c
|
||||||
sha512.c
|
sha512.c
|
||||||
verify.c)
|
verify.c)
|
||||||
|
dolphin_disable_warnings_msvc(ed25519)
|
||||||
|
1
Externals/enet/CMakeLists.txt
vendored
1
Externals/enet/CMakeLists.txt
vendored
@ -72,6 +72,7 @@ add_library(enet STATIC
|
|||||||
unix.c
|
unix.c
|
||||||
win32.c
|
win32.c
|
||||||
)
|
)
|
||||||
|
dolphin_disable_warnings_msvc(enet)
|
||||||
if(HAIKU)
|
if(HAIKU)
|
||||||
target_link_libraries(enet network)
|
target_link_libraries(enet network)
|
||||||
endif(HAIKU)
|
endif(HAIKU)
|
||||||
|
1
Externals/fmt/CMakeLists.txt
vendored
1
Externals/fmt/CMakeLists.txt
vendored
@ -229,6 +229,7 @@ else()
|
|||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
add_library(fmt ${FMT_SOURCES} ${FMT_HEADERS} README.rst ChangeLog.rst)
|
add_library(fmt ${FMT_SOURCES} ${FMT_HEADERS} README.rst ChangeLog.rst)
|
||||||
|
dolphin_disable_warnings_msvc(fmt)
|
||||||
add_library(fmt::fmt ALIAS fmt)
|
add_library(fmt::fmt ALIAS fmt)
|
||||||
|
|
||||||
if (FMT_WERROR)
|
if (FMT_WERROR)
|
||||||
|
1
Externals/glslang/CMakeLists.txt
vendored
1
Externals/glslang/CMakeLists.txt
vendored
@ -73,6 +73,7 @@ endif()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(glslang STATIC ${SRCS})
|
add_library(glslang STATIC ${SRCS})
|
||||||
|
dolphin_disable_warnings_msvc(glslang)
|
||||||
|
|
||||||
target_include_directories(glslang
|
target_include_directories(glslang
|
||||||
PRIVATE
|
PRIVATE
|
||||||
|
1
Externals/hidapi/CMakeLists.txt
vendored
1
Externals/hidapi/CMakeLists.txt
vendored
@ -1,6 +1,7 @@
|
|||||||
project(hidapi)
|
project(hidapi)
|
||||||
|
|
||||||
add_library(hidapi STATIC hidapi/hidapi.h)
|
add_library(hidapi STATIC hidapi/hidapi.h)
|
||||||
|
dolphin_disable_warnings_msvc(hidapi)
|
||||||
target_include_directories(hidapi PUBLIC hidapi)
|
target_include_directories(hidapi PUBLIC hidapi)
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
|
10
Externals/imgui/CMakeLists.txt
vendored
10
Externals/imgui/CMakeLists.txt
vendored
@ -1,6 +1,8 @@
|
|||||||
set(CMAKE_CXX_STANDARD 17)
|
if (NOT MSVC)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
set(SRCS
|
set(SRCS
|
||||||
imgui.cpp
|
imgui.cpp
|
||||||
@ -10,10 +12,10 @@ set(SRCS
|
|||||||
)
|
)
|
||||||
|
|
||||||
add_library(imgui STATIC ${SRCS})
|
add_library(imgui STATIC ${SRCS})
|
||||||
|
dolphin_disable_warnings_msvc(imgui)
|
||||||
target_include_directories(imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
|
target_include_directories(imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
|
|
||||||
target_link_libraries(imgui
|
target_link_libraries(imgui
|
||||||
PRIVATE
|
PRIVATE
|
||||||
common
|
|
||||||
fmt::fmt
|
fmt::fmt
|
||||||
)
|
)
|
||||||
|
1
Externals/libiconv-1.14/CMakeLists.txt
vendored
1
Externals/libiconv-1.14/CMakeLists.txt
vendored
@ -7,3 +7,4 @@ set(SRCS lib/iconv.c
|
|||||||
)
|
)
|
||||||
|
|
||||||
add_library(iconv STATIC ${SRCS})
|
add_library(iconv STATIC ${SRCS})
|
||||||
|
dolphin_disable_warnings_msvc(iconv)
|
||||||
|
1
Externals/liblzma/CMakeLists.txt
vendored
1
Externals/liblzma/CMakeLists.txt
vendored
@ -207,6 +207,7 @@ set(LZMA_SRCS
|
|||||||
|
|
||||||
add_library(lzma STATIC ${LZMA_SRCS} ${LZMA_PUBLIC_HDRS})
|
add_library(lzma STATIC ${LZMA_SRCS} ${LZMA_PUBLIC_HDRS})
|
||||||
add_library(LibLZMA::LibLZMA ALIAS lzma)
|
add_library(LibLZMA::LibLZMA ALIAS lzma)
|
||||||
|
dolphin_disable_warnings_msvc(lzma)
|
||||||
|
|
||||||
target_compile_definitions(lzma PUBLIC LZMA_API_STATIC)
|
target_compile_definitions(lzma PUBLIC LZMA_API_STATIC)
|
||||||
|
|
||||||
|
2
Externals/libpng/CMakeLists.txt
vendored
2
Externals/libpng/CMakeLists.txt
vendored
@ -39,6 +39,8 @@ add_library(png STATIC
|
|||||||
pngwutil.c
|
pngwutil.c
|
||||||
)
|
)
|
||||||
|
|
||||||
|
dolphin_disable_warnings_msvc(png)
|
||||||
|
|
||||||
option(PNG_HARDWARE_OPTIMIZATIONS "Enable hardware optimizations for libpng" OFF)
|
option(PNG_HARDWARE_OPTIMIZATIONS "Enable hardware optimizations for libpng" OFF)
|
||||||
|
|
||||||
if(PNG_HARDWARE_OPTIMIZATIONS)
|
if(PNG_HARDWARE_OPTIMIZATIONS)
|
||||||
|
3
Externals/libusb/CMakeLists.txt
vendored
3
Externals/libusb/CMakeLists.txt
vendored
@ -6,6 +6,8 @@ add_library(usb STATIC EXCLUDE_FROM_ALL
|
|||||||
libusb/libusb/strerror.c
|
libusb/libusb/strerror.c
|
||||||
libusb/libusb/sync.c
|
libusb/libusb/sync.c
|
||||||
)
|
)
|
||||||
|
dolphin_disable_warnings_msvc(usb)
|
||||||
|
|
||||||
set_target_properties(usb PROPERTIES VERSION 1.0.26)
|
set_target_properties(usb PROPERTIES VERSION 1.0.26)
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
target_include_directories(usb BEFORE PUBLIC libusb/libusb PRIVATE libusb/msvc)
|
target_include_directories(usb BEFORE PUBLIC libusb/libusb PRIVATE libusb/msvc)
|
||||||
@ -26,6 +28,7 @@ if(WIN32 OR CYGWIN)
|
|||||||
libusb/libusb/os/windows_common.c
|
libusb/libusb/os/windows_common.c
|
||||||
libusb/libusb/os/windows_usbdk.c
|
libusb/libusb/os/windows_usbdk.c
|
||||||
libusb/libusb/os/windows_winusb.c
|
libusb/libusb/os/windows_winusb.c
|
||||||
|
libusb/libusb/os/events_windows.c
|
||||||
)
|
)
|
||||||
set(PLATFORM_WINDOWS TRUE)
|
set(PLATFORM_WINDOWS TRUE)
|
||||||
elseif(APPLE)
|
elseif(APPLE)
|
||||||
|
1
Externals/mGBA/CMakeLists.txt
vendored
1
Externals/mGBA/CMakeLists.txt
vendored
@ -1,6 +1,7 @@
|
|||||||
set(LIBMGBA_ONLY ON)
|
set(LIBMGBA_ONLY ON)
|
||||||
set(USE_LZMA ON)
|
set(USE_LZMA ON)
|
||||||
add_subdirectory(mgba EXCLUDE_FROM_ALL)
|
add_subdirectory(mgba EXCLUDE_FROM_ALL)
|
||||||
|
dolphin_disable_warnings_msvc(mgba)
|
||||||
|
|
||||||
if(NOT MSVC)
|
if(NOT MSVC)
|
||||||
target_compile_options(mgba PRIVATE -Wno-unused-parameter -Wno-unused-result -Wno-unused-variable)
|
target_compile_options(mgba PRIVATE -Wno-unused-parameter -Wno-unused-result -Wno-unused-variable)
|
||||||
|
6
Externals/mbedtls/library/CMakeLists.txt
vendored
6
Externals/mbedtls/library/CMakeLists.txt
vendored
@ -189,28 +189,34 @@ endif()
|
|||||||
|
|
||||||
if(USE_STATIC_MBEDTLS_LIBRARY)
|
if(USE_STATIC_MBEDTLS_LIBRARY)
|
||||||
add_library(${mbedcrypto_static_target} STATIC ${src_crypto})
|
add_library(${mbedcrypto_static_target} STATIC ${src_crypto})
|
||||||
|
dolphin_disable_warnings_msvc(${mbedcrypto_static_target})
|
||||||
set_target_properties(${mbedcrypto_static_target} PROPERTIES OUTPUT_NAME mbedcrypto)
|
set_target_properties(${mbedcrypto_static_target} PROPERTIES OUTPUT_NAME mbedcrypto)
|
||||||
target_link_libraries(${mbedcrypto_static_target} PUBLIC ${libs})
|
target_link_libraries(${mbedcrypto_static_target} PUBLIC ${libs})
|
||||||
|
|
||||||
add_library(${mbedx509_static_target} STATIC ${src_x509})
|
add_library(${mbedx509_static_target} STATIC ${src_x509})
|
||||||
|
dolphin_disable_warnings_msvc(${mbedx509_static_target})
|
||||||
set_target_properties(${mbedx509_static_target} PROPERTIES OUTPUT_NAME mbedx509)
|
set_target_properties(${mbedx509_static_target} PROPERTIES OUTPUT_NAME mbedx509)
|
||||||
target_link_libraries(${mbedx509_static_target} PUBLIC ${libs} ${mbedcrypto_static_target})
|
target_link_libraries(${mbedx509_static_target} PUBLIC ${libs} ${mbedcrypto_static_target})
|
||||||
|
|
||||||
add_library(${mbedtls_static_target} STATIC ${src_tls})
|
add_library(${mbedtls_static_target} STATIC ${src_tls})
|
||||||
|
dolphin_disable_warnings_msvc(${mbedtls_static_target})
|
||||||
set_target_properties(${mbedtls_static_target} PROPERTIES OUTPUT_NAME mbedtls)
|
set_target_properties(${mbedtls_static_target} PROPERTIES OUTPUT_NAME mbedtls)
|
||||||
target_link_libraries(${mbedtls_static_target} PUBLIC ${libs} ${mbedx509_static_target})
|
target_link_libraries(${mbedtls_static_target} PUBLIC ${libs} ${mbedx509_static_target})
|
||||||
endif(USE_STATIC_MBEDTLS_LIBRARY)
|
endif(USE_STATIC_MBEDTLS_LIBRARY)
|
||||||
|
|
||||||
if(USE_SHARED_MBEDTLS_LIBRARY)
|
if(USE_SHARED_MBEDTLS_LIBRARY)
|
||||||
add_library(${mbedcrypto_target} SHARED ${src_crypto})
|
add_library(${mbedcrypto_target} SHARED ${src_crypto})
|
||||||
|
dolphin_disable_warnings_msvc(${mbedcrypto_target})
|
||||||
set_target_properties(${mbedcrypto_target} PROPERTIES VERSION 2.28.0 SOVERSION 7)
|
set_target_properties(${mbedcrypto_target} PROPERTIES VERSION 2.28.0 SOVERSION 7)
|
||||||
target_link_libraries(${mbedcrypto_target} PUBLIC ${libs})
|
target_link_libraries(${mbedcrypto_target} PUBLIC ${libs})
|
||||||
|
|
||||||
add_library(${mbedx509_target} SHARED ${src_x509})
|
add_library(${mbedx509_target} SHARED ${src_x509})
|
||||||
|
dolphin_disable_warnings_msvc(${mbedx509_target})
|
||||||
set_target_properties(${mbedx509_target} PROPERTIES VERSION 2.28.0 SOVERSION 1)
|
set_target_properties(${mbedx509_target} PROPERTIES VERSION 2.28.0 SOVERSION 1)
|
||||||
target_link_libraries(${mbedx509_target} PUBLIC ${libs} ${mbedcrypto_target})
|
target_link_libraries(${mbedx509_target} PUBLIC ${libs} ${mbedcrypto_target})
|
||||||
|
|
||||||
add_library(${mbedtls_target} SHARED ${src_tls})
|
add_library(${mbedtls_target} SHARED ${src_tls})
|
||||||
|
dolphin_disable_warnings_msvc(${mbedtls_target})
|
||||||
set_target_properties(${mbedtls_target} PROPERTIES VERSION 2.28.0 SOVERSION 14)
|
set_target_properties(${mbedtls_target} PROPERTIES VERSION 2.28.0 SOVERSION 14)
|
||||||
target_link_libraries(${mbedtls_target} PUBLIC ${libs} ${mbedx509_target})
|
target_link_libraries(${mbedtls_target} PUBLIC ${libs} ${mbedx509_target})
|
||||||
endif(USE_SHARED_MBEDTLS_LIBRARY)
|
endif(USE_SHARED_MBEDTLS_LIBRARY)
|
||||||
|
1
Externals/miniupnpc/CMakeLists.txt
vendored
1
Externals/miniupnpc/CMakeLists.txt
vendored
@ -33,6 +33,7 @@ set(SRCS src/igd_desc_parse.c
|
|||||||
src/receivedata.c)
|
src/receivedata.c)
|
||||||
|
|
||||||
add_library(miniupnpc STATIC ${SRCS})
|
add_library(miniupnpc STATIC ${SRCS})
|
||||||
|
dolphin_disable_warnings_msvc(miniupnpc)
|
||||||
target_include_directories(miniupnpc PUBLIC src)
|
target_include_directories(miniupnpc PUBLIC src)
|
||||||
|
|
||||||
add_library(Miniupnpc::miniupnpc ALIAS miniupnpc)
|
add_library(Miniupnpc::miniupnpc ALIAS miniupnpc)
|
||||||
|
1
Externals/minizip/CMakeLists.txt
vendored
1
Externals/minizip/CMakeLists.txt
vendored
@ -26,6 +26,7 @@ add_library(minizip STATIC
|
|||||||
unzip.h
|
unzip.h
|
||||||
zip.h
|
zip.h
|
||||||
)
|
)
|
||||||
|
dolphin_disable_warnings_msvc(minizip)
|
||||||
|
|
||||||
if (UNIX)
|
if (UNIX)
|
||||||
target_sources(minizip PRIVATE
|
target_sources(minizip PRIVATE
|
||||||
|
1
Externals/pugixml/CMakeLists.txt
vendored
1
Externals/pugixml/CMakeLists.txt
vendored
@ -35,6 +35,7 @@ if(BUILD_SHARED_LIBS)
|
|||||||
else()
|
else()
|
||||||
add_library(pugixml STATIC ${SOURCES})
|
add_library(pugixml STATIC ${SOURCES})
|
||||||
endif()
|
endif()
|
||||||
|
dolphin_disable_warnings_msvc(pugixml)
|
||||||
|
|
||||||
set_target_properties(pugixml PROPERTIES VERSION 1.8 SOVERSION 1)
|
set_target_properties(pugixml PROPERTIES VERSION 1.8 SOVERSION 1)
|
||||||
get_target_property(PUGIXML_VERSION_STRING pugixml VERSION)
|
get_target_property(PUGIXML_VERSION_STRING pugixml VERSION)
|
||||||
|
1
Externals/soundtouch/CMakeLists.txt
vendored
1
Externals/soundtouch/CMakeLists.txt
vendored
@ -16,4 +16,5 @@ set(SRCS
|
|||||||
)
|
)
|
||||||
|
|
||||||
add_library(SoundTouch STATIC ${SRCS})
|
add_library(SoundTouch STATIC ${SRCS})
|
||||||
|
dolphin_disable_warnings_msvc(SoundTouch)
|
||||||
add_definitions(-w)
|
add_definitions(-w)
|
||||||
|
1
Externals/xxhash/CMakeLists.txt
vendored
1
Externals/xxhash/CMakeLists.txt
vendored
@ -1,6 +1,7 @@
|
|||||||
project(xxhash C)
|
project(xxhash C)
|
||||||
|
|
||||||
add_library(xxhash STATIC xxhash.c)
|
add_library(xxhash STATIC xxhash.c)
|
||||||
|
dolphin_disable_warnings_msvc(xxhash)
|
||||||
target_include_directories(xxhash
|
target_include_directories(xxhash
|
||||||
PUBLIC
|
PUBLIC
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
1
Externals/zlib/CMakeLists.txt
vendored
1
Externals/zlib/CMakeLists.txt
vendored
@ -86,6 +86,7 @@ set(ZLIB_SRCS
|
|||||||
)
|
)
|
||||||
|
|
||||||
add_library(z STATIC ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
|
add_library(z STATIC ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
|
||||||
|
dolphin_disable_warnings_msvc(z)
|
||||||
add_library(ZLIB::ZLIB ALIAS z)
|
add_library(ZLIB::ZLIB ALIAS z)
|
||||||
|
|
||||||
target_include_directories(z
|
target_include_directories(z
|
||||||
|
1
Externals/zstd/CMakeLists.txt
vendored
1
Externals/zstd/CMakeLists.txt
vendored
@ -115,6 +115,7 @@ set(ZSTD_SRCS
|
|||||||
)
|
)
|
||||||
|
|
||||||
add_library(zstd STATIC ${ZSTD_SRCS} ${ZSTD_PUBLIC_HDRS} ${ZSTD_PRIVATE_HDRS})
|
add_library(zstd STATIC ${ZSTD_SRCS} ${ZSTD_PUBLIC_HDRS} ${ZSTD_PRIVATE_HDRS})
|
||||||
|
dolphin_disable_warnings_msvc(zstd)
|
||||||
add_library(zstd::zstd ALIAS zstd)
|
add_library(zstd::zstd ALIAS zstd)
|
||||||
|
|
||||||
target_include_directories(zstd
|
target_include_directories(zstd
|
||||||
|
@ -18,62 +18,17 @@ if(CMAKE_SYSTEM_NAME MATCHES "Windows")
|
|||||||
add_definitions(-D_SILENCE_CXX20_OLD_SHARED_PTR_ATOMIC_SUPPORT_DEPRECATION_WARNING)
|
add_definitions(-D_SILENCE_CXX20_OLD_SHARED_PTR_ATOMIC_SUPPORT_DEPRECATION_WARNING)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (MSVC)
|
if (NOT MSVC)
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
|
||||||
set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std:c++latest")
|
|
||||||
else()
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
# TODO: Use https://cmake.org/cmake/help/latest/policy/CMP0092.html instead (once we can require CMake >= 3.15)
|
# Compile PCH
|
||||||
# Taken from http://www.cmake.org/Wiki/CMake_FAQ#Dynamic_Replace.
|
|
||||||
foreach(flag_var
|
|
||||||
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
|
|
||||||
MAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
|
||||||
# Replaces /W3 with /W4 in defaults (add_compile_options would cause very annoying warnings here)
|
|
||||||
string(REPLACE "/W3" "/W4" ${flag_var} "${${flag_var}}")
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
# 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
|
|
||||||
)
|
|
||||||
|
|
||||||
# Treat all warnings as errors
|
|
||||||
add_compile_options(/WX)
|
|
||||||
|
|
||||||
# All files are encoded as UTF-8
|
|
||||||
add_compile_options(/utf-8)
|
|
||||||
|
|
||||||
# Use PCH
|
|
||||||
add_subdirectory(PCH)
|
add_subdirectory(PCH)
|
||||||
add_definitions(/I${PCH_DIRECTORY})
|
|
||||||
add_definitions(/Yu${PCH_PATH})
|
|
||||||
|
|
||||||
# Don't include timestamps in binaries
|
|
||||||
add_link_options(/Brepro)
|
|
||||||
else()
|
else()
|
||||||
check_and_add_flag(HAVE_WALL -Wall)
|
check_and_add_flag(HAVE_WALL -Wall)
|
||||||
# TODO: would like these but they produce overwhelming amounts of warnings
|
# TODO: would like these but they produce overwhelming amounts of warnings
|
||||||
|
@ -83,3 +83,8 @@ PRIVATE
|
|||||||
cubeb
|
cubeb
|
||||||
SoundTouch
|
SoundTouch
|
||||||
FreeSurround)
|
FreeSurround)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
# Add precompiled header
|
||||||
|
target_link_libraries(audiocommon PRIVATE use_pch)
|
||||||
|
endif()
|
||||||
|
@ -287,7 +287,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||||
target_sources(common PUBLIC HRWrap.h HRWrap.cpp)
|
target_sources(common PRIVATE HRWrap.h HRWrap.cpp)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(USE_UPNP)
|
if(USE_UPNP)
|
||||||
@ -308,3 +308,13 @@ if(UNIX)
|
|||||||
elseif(WIN32)
|
elseif(WIN32)
|
||||||
target_link_libraries(common PRIVATE "-INCLUDE:enableCompatPatches")
|
target_link_libraries(common PRIVATE "-INCLUDE:enableCompatPatches")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
# Add precompiled header
|
||||||
|
target_link_libraries(common PRIVATE use_pch)
|
||||||
|
|
||||||
|
# We need to disable PCH for this one file, because it's C and our PCH is C++
|
||||||
|
set_source_files_properties(
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/ImageC.c
|
||||||
|
PROPERTIES COMPILE_FLAGS "/Y- /I${CMAKE_SOURCE_DIR}/Source/PCH/nopch")
|
||||||
|
endif()
|
||||||
|
@ -702,3 +702,8 @@ if(UNIX)
|
|||||||
MemoryWatcher.h
|
MemoryWatcher.h
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
# Add precompiled header
|
||||||
|
target_link_libraries(core PRIVATE use_pch)
|
||||||
|
endif()
|
||||||
|
@ -77,3 +77,8 @@ PRIVATE
|
|||||||
pugixml
|
pugixml
|
||||||
ZLIB::ZLIB
|
ZLIB::ZLIB
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
# Add precompiled header
|
||||||
|
target_link_libraries(discio PRIVATE use_pch)
|
||||||
|
endif()
|
||||||
|
@ -26,6 +26,11 @@ PRIVATE
|
|||||||
cpp-optparse
|
cpp-optparse
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
# Add precompiled header
|
||||||
|
target_link_libraries(dolphin-nogui PRIVATE use_pch)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(USE_DISCORD_PRESENCE)
|
if(USE_DISCORD_PRESENCE)
|
||||||
target_compile_definitions(dolphin-nogui PRIVATE -DUSE_DISCORD_PRESENCE)
|
target_compile_definitions(dolphin-nogui PRIVATE -DUSE_DISCORD_PRESENCE)
|
||||||
endif()
|
endif()
|
||||||
|
@ -382,9 +382,6 @@ if (WIN32)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
# Don't propogate warnings in qt headers to Dolphin
|
|
||||||
target_compile_options(dolphin-emu PRIVATE /experimental:external)
|
|
||||||
target_compile_options(dolphin-emu PRIVATE /external:W0)
|
|
||||||
set(qtGui "")
|
set(qtGui "")
|
||||||
set(qtGuiPriv "")
|
set(qtGuiPriv "")
|
||||||
set(qtWidgetsPriv "")
|
set(qtWidgetsPriv "")
|
||||||
@ -394,6 +391,15 @@ if (MSVC)
|
|||||||
target_compile_options(dolphin-emu PRIVATE "${qtGui}")
|
target_compile_options(dolphin-emu PRIVATE "${qtGui}")
|
||||||
target_compile_options(dolphin-emu PRIVATE "${qtGuiPriv}")
|
target_compile_options(dolphin-emu PRIVATE "${qtGuiPriv}")
|
||||||
target_compile_options(dolphin-emu PRIVATE "${qtWidgets}")
|
target_compile_options(dolphin-emu PRIVATE "${qtWidgets}")
|
||||||
|
|
||||||
|
if ("${QT_VERSION_MAJOR}" GREATER_EQUAL 6)
|
||||||
|
# Qt6 requires RTTI
|
||||||
|
remove_cxx_flag_from_target(dolphin-emu "/GR-")
|
||||||
|
target_compile_options(dolphin-emu PRIVATE "/GR")
|
||||||
|
else()
|
||||||
|
# Add precompiled header
|
||||||
|
target_link_libraries(audiocommon PRIVATE use_pch)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
@ -430,6 +436,13 @@ if(WIN32)
|
|||||||
get_filename_component(QT_BINARY_DIRECTORY "${MOC_EXECUTABLE_LOCATION}" DIRECTORY)
|
get_filename_component(QT_BINARY_DIRECTORY "${MOC_EXECUTABLE_LOCATION}" DIRECTORY)
|
||||||
find_program(WINDEPLOYQT_EXE windeployqt HINTS "${QT_BINARY_DIRECTORY}")
|
find_program(WINDEPLOYQT_EXE windeployqt HINTS "${QT_BINARY_DIRECTORY}")
|
||||||
|
|
||||||
|
if ("${QT_VERSION_MAJOR}" LESS 6)
|
||||||
|
set(NO_ANGLE_PARAM "--no-angle")
|
||||||
|
else()
|
||||||
|
# parameter no longer exists in Qt6
|
||||||
|
set(NO_ANGLE_PARAM "")
|
||||||
|
endif()
|
||||||
|
|
||||||
# Note: We set the PATH for the duration of this command so that the
|
# Note: We set the PATH for the duration of this command so that the
|
||||||
# deployment application is able to locate the Qt libraries to copy.
|
# deployment application is able to locate the Qt libraries to copy.
|
||||||
# if the necessary paths aren't already set beforehand.
|
# if the necessary paths aren't already set beforehand.
|
||||||
@ -452,7 +465,7 @@ if(WIN32)
|
|||||||
--no-translations
|
--no-translations
|
||||||
--no-compiler-runtime
|
--no-compiler-runtime
|
||||||
--no-system-d3d-compiler
|
--no-system-d3d-compiler
|
||||||
--no-angle
|
"${NO_ANGLE_PARAM}"
|
||||||
--no-opengl-sw
|
--no-opengl-sw
|
||||||
"$<TARGET_FILE:dolphin-emu>"
|
"$<TARGET_FILE:dolphin-emu>"
|
||||||
)
|
)
|
||||||
|
@ -19,5 +19,10 @@ PRIVATE
|
|||||||
cpp-optparse
|
cpp-optparse
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
# Add precompiled header
|
||||||
|
target_link_libraries(dolphin-tool PRIVATE use_pch)
|
||||||
|
endif()
|
||||||
|
|
||||||
set(CPACK_PACKAGE_EXECUTABLES ${CPACK_PACKAGE_EXECUTABLES} dolphin-tool)
|
set(CPACK_PACKAGE_EXECUTABLES ${CPACK_PACKAGE_EXECUTABLES} dolphin-tool)
|
||||||
install(TARGETS dolphin-tool RUNTIME DESTINATION ${bindir})
|
install(TARGETS dolphin-tool RUNTIME DESTINATION ${bindir})
|
||||||
|
@ -205,3 +205,8 @@ if(ENABLE_SDL)
|
|||||||
message(STATUS "SDL NOT found, disabling SDL input")
|
message(STATUS "SDL NOT found, disabling SDL input")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
# Add precompiled header
|
||||||
|
target_link_libraries(inputcommon PRIVATE use_pch)
|
||||||
|
endif()
|
||||||
|
@ -68,3 +68,8 @@ if(USE_DISCORD_PRESENCE)
|
|||||||
target_compile_definitions(uicommon PRIVATE -DUSE_DISCORD_PRESENCE)
|
target_compile_definitions(uicommon PRIVATE -DUSE_DISCORD_PRESENCE)
|
||||||
target_link_libraries(uicommon PRIVATE discord-rpc)
|
target_link_libraries(uicommon PRIVATE discord-rpc)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
# Add precompiled header
|
||||||
|
target_link_libraries(uicommon PRIVATE use_pch)
|
||||||
|
endif()
|
||||||
|
@ -11,3 +11,8 @@ target_link_libraries(updatercommon PRIVATE
|
|||||||
ed25519
|
ed25519
|
||||||
cpp-optparse
|
cpp-optparse
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
# Add precompiled header
|
||||||
|
target_link_libraries(updatercommon PRIVATE use_pch)
|
||||||
|
endif()
|
||||||
|
@ -29,3 +29,8 @@ PUBLIC
|
|||||||
videocommon
|
videocommon
|
||||||
videod3dcommon
|
videod3dcommon
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
# Add precompiled header
|
||||||
|
target_link_libraries(videod3d PRIVATE use_pch)
|
||||||
|
endif()
|
||||||
|
@ -35,3 +35,8 @@ PUBLIC
|
|||||||
videocommon
|
videocommon
|
||||||
videod3dcommon
|
videod3dcommon
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
# Add precompiled header
|
||||||
|
target_link_libraries(videod3d12 PRIVATE use_pch)
|
||||||
|
endif()
|
||||||
|
@ -12,3 +12,8 @@ PUBLIC
|
|||||||
common
|
common
|
||||||
videocommon
|
videocommon
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
# Add precompiled header
|
||||||
|
target_link_libraries(videod3dcommon PRIVATE use_pch)
|
||||||
|
endif()
|
||||||
|
@ -17,3 +17,8 @@ PUBLIC
|
|||||||
common
|
common
|
||||||
videocommon
|
videocommon
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
# Add precompiled header
|
||||||
|
target_link_libraries(videonull PRIVATE use_pch)
|
||||||
|
endif()
|
||||||
|
@ -33,3 +33,8 @@ PUBLIC
|
|||||||
PRIVATE
|
PRIVATE
|
||||||
${X11_LIBRARIES}
|
${X11_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
# Add precompiled header
|
||||||
|
target_link_libraries(videoogl PRIVATE use_pch)
|
||||||
|
endif()
|
||||||
|
@ -41,3 +41,8 @@ PUBLIC
|
|||||||
common
|
common
|
||||||
videocommon
|
videocommon
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
# Add precompiled header
|
||||||
|
target_link_libraries(videosoftware PRIVATE use_pch)
|
||||||
|
endif()
|
||||||
|
@ -62,3 +62,8 @@ SYSTEM PRIVATE
|
|||||||
${CMAKE_SOURCE_DIR}/Externals/glslang/SPIRV
|
${CMAKE_SOURCE_DIR}/Externals/glslang/SPIRV
|
||||||
${CMAKE_SOURCE_DIR}/Externals/glslang
|
${CMAKE_SOURCE_DIR}/Externals/glslang
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
# Add precompiled header
|
||||||
|
target_link_libraries(videovulkan PRIVATE use_pch)
|
||||||
|
endif()
|
||||||
|
@ -180,3 +180,8 @@ if(FFmpeg_FOUND)
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
# Add precompiled header
|
||||||
|
target_link_libraries(videocommon PRIVATE use_pch)
|
||||||
|
endif()
|
||||||
|
@ -12,3 +12,8 @@ target_link_libraries(winupdater PRIVATE
|
|||||||
)
|
)
|
||||||
|
|
||||||
set_target_properties(winupdater PROPERTIES OUTPUT_NAME "Updater")
|
set_target_properties(winupdater PROPERTIES OUTPUT_NAME "Updater")
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
# Add precompiled header
|
||||||
|
target_link_libraries(winupdater PRIVATE use_pch)
|
||||||
|
endif()
|
||||||
|
@ -1,6 +1,43 @@
|
|||||||
add_library(pch pch.h pch.cpp)
|
# The PCH that dolphin uses for MSVC is non-standard;
|
||||||
set(PCH_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
# Instead of having one PCH per module, dolphin has one PCH shared between all modules.
|
||||||
set(PCH_NAME ${PCH.pch})
|
# So we need to implement PCH manually, rather than using the PCH support built into cmake
|
||||||
target_compile_options(pch PUBLIC /Ycpch.h /Fp${PCH_DIRECTORY}/${PCH_NAME})
|
|
||||||
|
add_library(build_pch pch.h pch.cpp)
|
||||||
|
|
||||||
# fmt/format.h is included in the PCH
|
# fmt/format.h is included in the PCH
|
||||||
target_link_libraries(pch PUBLIC fmt::fmt)
|
target_link_libraries(build_pch PUBLIC fmt::fmt)
|
||||||
|
|
||||||
|
# pch.cpp should be compiled with the /Yc command, which creates the precompiled header
|
||||||
|
target_compile_options(build_pch PRIVATE /Ycpch.h)
|
||||||
|
|
||||||
|
# /Fp sets the location of the PCH. By forcing it to a fixed location, all modules
|
||||||
|
# will share this one PCH. We give it a fixed name so we can depend on it later
|
||||||
|
target_compile_options(build_pch PUBLIC /Fp$<TARGET_FILE_DIR:build_pch>/dolphin.pch )
|
||||||
|
|
||||||
|
# Sharing a PCH breaks pdb files. So we use the /Z7 option to inline the pdb into
|
||||||
|
# the binary. That also requires us to disable minimal rebuilds.
|
||||||
|
target_compile_options(build_pch PUBLIC /Z7 /Gm-)
|
||||||
|
|
||||||
|
# To get this working with ninja, we need to tell it that compiling pch.cpp generates an extra output
|
||||||
|
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/pch.cpp PROPERTIES
|
||||||
|
OBJECT_OUTPUTS $<TARGET_FILE_DIR:build_pch>/dolphin.pch
|
||||||
|
)
|
||||||
|
|
||||||
|
# and then create a custom target that depends on the pch output
|
||||||
|
# so that ninja won't start building anything that depends on this
|
||||||
|
# target before the pch is built
|
||||||
|
add_custom_target(force_build_pch
|
||||||
|
DEPENDS $<TARGET_FILE_DIR:build_pch>/dolphin.pch
|
||||||
|
)
|
||||||
|
|
||||||
|
# linking against this interface libary will cause targets to enable PCH
|
||||||
|
add_library(use_pch INTERFACE)
|
||||||
|
target_link_libraries(use_pch INTERFACE build_pch)
|
||||||
|
|
||||||
|
# targets which use the pch need these compile options
|
||||||
|
# /Yu - Use precompiled header named "pch.h"
|
||||||
|
# /FI - Force include "pch.h" at top of every source file
|
||||||
|
target_compile_options(use_pch INTERFACE /Yupch.h /FIpch.h)
|
||||||
|
|
||||||
|
# For ninja, we need to depend on force_build_pch
|
||||||
|
add_dependencies(use_pch force_build_pch)
|
||||||
|
4
Source/PCH/nopch/pch.h
Normal file
4
Source/PCH/nopch/pch.h
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
// dummy include to help with disabling pch for a single file
|
||||||
|
// cmake doesn't provide a clean way to disable MSVC's force include option
|
||||||
|
|
||||||
|
// So we can just point it at an empty file instead.
|
Loading…
x
Reference in New Issue
Block a user