Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VS2017 support (with bonus CMake integration) #5037

Merged
merged 5 commits into from
Mar 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 12 additions & 2 deletions CMake/CheckAndAddFlag.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 1 addition & 1 deletion CMake/DolphinCompileDefinitions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
20 changes: 20 additions & 0 deletions CMakeSettings.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
5 changes: 4 additions & 1 deletion Source/Core/Common/MathUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

#include "Common/CommonTypes.h"

#ifdef _MSC_VER
#include <intrin.h>
#endif

namespace MathUtil
{
template <typename T>
Expand All @@ -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()
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/IOS/ES/ES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "Core/IOS/ES/ES.h"

#include <algorithm>
#include <cctype>
#include <cinttypes>
#include <cstdio>
#include <cstring>
Expand Down