diff --git a/CMakeLists.txt b/CMakeLists.txt index 5bd5ad7b9d45..0ed0f2f0912f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,6 +107,14 @@ endif() # as defined above. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Binaries) +if (MSVC) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + +endif() + # setup CCache include(CCache) @@ -361,6 +369,11 @@ if(ENABLE_VTUNE) ) endif() +if(WIN32) + message(STATUS "Building for Windows, disabling NoGUI frontend.") + set(ENABLE_NOGUI OFF) +endif() + if(ANDROID) message(STATUS "Building for Android") if(NOT ENABLE_HEADLESS) @@ -594,7 +607,7 @@ endif() message(STATUS "Using static FreeSurround from Externals") add_subdirectory(Externals/FreeSurround) -if (APPLE) +if (APPLE OR WIN32) message(STATUS "Using ed25519 from Externals") add_subdirectory(Externals/ed25519) endif() diff --git a/CMakeSettings.json b/CMakeSettings.json index e6f3349a3a8e..49676259a310 100644 --- a/CMakeSettings.json +++ b/CMakeSettings.json @@ -1,20 +1,38 @@ -{ +{ "configurations": [ { - "name": "x64-Debug", - "generator": "Visual Studio 15 2017 Win64", - "configurationType": "Debug", - "buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}", + "name": "Release", + "configurationType": "Release", + "generator": "Visual Studio 16 2019 Win64", + "inheritEnvironments": [ "msvc_x64_x64" ], + "buildCommandArgs": "-m -p:PreferredToolArchitecture=x64", + "buildRoot": "${workspaceRoot}\\build", "cmakeCommandArgs": "", - "buildCommandArgs": "-m -p:PreferredToolArchitecture=x64" + "variables": [ + { + "name": "Qt5_DIR", + "value": "${workspaceRoot}\\Externals\\Qt\\Qt5.11.1\\5.11.1\\msvc2017_64\\lib\\cmake\\Qt5" + } + ] }, { - "name": "x64-Release", - "generator": "Visual Studio 15 2017 Win64", - "configurationType": "Release", - "buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}", + "name": "Debug", + "generator": "Visual Studio 16 2019 Win64", + "configurationType": "Debug", + "inheritEnvironments": [ "msvc_x64_x64" ], + "buildCommandArgs": "-m -p:PreferredToolArchitecture=x64", + "buildRoot": "${workspaceRoot}\\build", "cmakeCommandArgs": "", - "buildCommandArgs": "-m -p:PreferredToolArchitecture=x64" + "variables": [ + { + "name": "CMAKE_BUILD_TYPE", + "value": "Debug" + }, + { + "name": "Qt5_DIR", + "value": "${workspaceRoot}\\Externals\\Qt\\Qt5.11.1\\5.11.1\\msvc2017_64\\lib\\cmake\\Qt5" + } + ] } ] -} +} \ No newline at end of file diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 7d435e1ca2ac..2563a618c1fa 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -13,6 +13,39 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) +if (MSVC) + # Set warning level to 4 + add_compile_options(/W4) + + # 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) + + add_definitions(/D _CRT_NONSTDC_NO_WARNINGS) + add_definitions(/utf-8) +endif() + # These aren't actually needed for C11/C++11 # but some dependencies require them (LLVM, libav). add_definitions(-D__STDC_LIMIT_MACROS)