Merge pull request #5037 from Orphis/vs2017

VS2017 support (with bonus CMake integration)
This commit is contained in:
Matthew Parlane 2017-03-08 20:21:42 +13:00 committed by GitHub
commit 8ff8c26f1a
6 changed files with 39 additions and 5 deletions

View File

@ -27,13 +27,23 @@ function(check_and_add_flag var flag)
message(FATAL_ERROR "check_and_add_flag called with incorrect arguments: ${ARGN}")
endif()
set(is_c "$<COMPILE_LANGUAGE:C>")
set(is_cxx "$<COMPILE_LANGUAGE:CXX>")
# The Visual Studio generators don't support COMPILE_LANGUAGE
# So we fail all the C flags and only actually test CXX ones
if(CMAKE_GENERATOR MATCHES "Visual Studio")
set(is_c "0")
set(is_cxx "1")
endif()
check_c_compiler_flag(${flag} FLAG_C_${var})
if(FLAG_C_${var})
add_compile_options("$<$<AND:$<COMPILE_LANGUAGE:C>,${genexp_config_test}>:${flag}>")
add_compile_options("$<$<AND:${is_c},${genexp_config_test}>:${flag}>")
endif()
check_cxx_compiler_flag(${flag} FLAG_CXX_${var})
if(FLAG_CXX_${var})
add_compile_options("$<$<AND:$<COMPILE_LANGUAGE:CXX>,${genexp_config_test}>:${flag}>")
add_compile_options("$<$<AND:${is_cxx},${genexp_config_test}>:${flag}>")
endif()
endfunction()

View File

@ -30,5 +30,5 @@ function(dolphin_compile_definitions)
endif()
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS
"$<${genexp_config_test}:${ARGN}>")
"$<${genexp_config_test}:${defs}>")
endfunction()

View File

@ -206,7 +206,7 @@ endif()
if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
check_and_add_flag(EXCEPTIONS /EHsc)
dolphin_compile_definitions(-D_DEBUG DEBUG_ONLY)
dolphin_compile_definitions(_DEBUG DEBUG_ONLY)
string(APPEND CMAKE_EXE_LINKER_FLAGS " /NXCOMPAT")
string(APPEND CMAKE_EXE_LINKER_FLAGS " /BASE:0x00400000")

20
CMakeSettings.json Normal file
View File

@ -0,0 +1,20 @@
{
"configurations": [
{
"name": "x64-Debug",
"generator": "Visual Studio 15 2017 Win64",
"configurationType": "Debug",
"buildRoot": "${env.LOCALAPPDATA}\\CMakeBuild\\${workspaceHash}\\build\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-m -p:PreferredToolArchitecture=x64"
},
{
"name": "x64-Release",
"generator": "Visual Studio 15 2017 Win64",
"configurationType": "Release",
"buildRoot": "${env.LOCALAPPDATA}\\CMakeBuild\\${workspaceHash}\\build\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-m -p:PreferredToolArchitecture=x64"
}
]
}

View File

@ -10,6 +10,10 @@
#include "Common/CommonTypes.h"
#ifdef _MSC_VER
#include <intrin.h>
#endif
namespace MathUtil
{
template <typename T>
@ -24,7 +28,6 @@ constexpr T SNANConstant()
// will use __builtin_nans, which is improperly handled by the compiler and generates
// a bad constant. Here we go back to the version MSVC used before the builtin.
// TODO: Remove this and use numeric_limits directly whenever this bug is fixed.
#include <intrin.h>
template <>
constexpr double SNANConstant()

View File

@ -5,6 +5,7 @@
#include "Core/IOS/ES/ES.h"
#include <algorithm>
#include <cctype>
#include <cinttypes>
#include <cstdio>
#include <cstring>