diff --git a/.gitignore b/.gitignore index 90ac0c6d9..2f548c4c3 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,11 @@ # Dependency makefiles *.d +# MSVC-specific +*.lib +EmulationStation.ilk +EmulationStation.pdb + # Compiled executable emulationstation EmulationStation diff --git a/CMakeLists.txt b/CMakeLists.txt index ff89b5236..31d88d213 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -111,14 +111,23 @@ elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") set(CMAKE_CXX_FLAGS "-mwindows ${CMAKE_CXX_FLAGS}") # set(CMAKE_CXX_FLAGS "-static-libstdc++ -static-libgcc ${CMAKE_CXX_FLAGS}") endif() +elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + message("-- Compiler is MSVC") + # If using the MSVC compiler on Windows, disable the built-in min() and max() macros. + add_definitions(-DNOMINMAX) endif() +message("-- Build type is ${CMAKE_BUILD_TYPE}") + # Set up compiler and linker flags for debug, profiling or release builds. if(CMAKE_BUILD_TYPE MATCHES Debug) # Enable the C++11 standard and disable optimizations as it's a debug build. - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O0") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -O0") - + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c11 /Od /DEBUG:FULL") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O0") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -O0") + endif() # If using Clang, then add additional debug data needed by GDB. # Comment this out if you're using LLDB for debugging as this flag makes the binary # much larger and the application much slower. On macoOS this setting is never enabled @@ -128,21 +137,29 @@ if(CMAKE_BUILD_TYPE MATCHES Debug) endif() elseif(CMAKE_BUILD_TYPE MATCHES Profiling) # For the profiling build, we enable optimizations and supply the required profiler flags. - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O2 -pg -g") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -O2 -pg") + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c11 /O2 /DEBUG:FULL") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O2 -pg -g") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -O2 -pg") + endif() else() # Enable the C++11 standard and enable optimizations as it's a release build. - # This will also disable all assert() macros. Strip the binary as well. - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O2 -DNDEBUG") - if(APPLE) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -O2") + # This will also disable all assert() macros. Strip the binary too. + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNDEBUG /std:c11 /O2 /DEBUG:NONE") else() - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -O2 -s") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O2 -DNDEBUG") + if(APPLE) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -O2") + else() + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -O2 -s") + endif() endif() endif() -# This removes half of the ranlib warnings on macOS regarding no symbols for files that -# are #ifdef'ed away. There must be a way to remove the other half as well? +# The following removes half of the ranlib warnings on macOS regarding no symbols for files +# that are #ifdef'ed away. There must be a way to remove the other half as well? if(APPLE) SET(CMAKE_C_ARCHIVE_FINISH " -no_warning_for_no_symbols -c ") SET(CMAKE_CXX_ARCHIVE_FINISH " -no_warning_for_no_symbols -c ") @@ -238,18 +255,32 @@ if(NOT WIN32) ${VLC_LIBRARIES} nanosvg) elseif(WIN32) - set(COMMON_LIBRARIES - "${PROJECT_SOURCE_DIR}/FreeImage.dll" - "${PROJECT_SOURCE_DIR}/glew32.dll" - "${PROJECT_SOURCE_DIR}/libcurl-x64.dll" - "${PROJECT_SOURCE_DIR}/libfreetype.dll" - "${PROJECT_SOURCE_DIR}/libpugixml.dll" - "${PROJECT_SOURCE_DIR}/libSDL2main.a" - "${PROJECT_SOURCE_DIR}/libvlc.dll" - "${PROJECT_SOURCE_DIR}/SDL2.dll" - "mingw32" - "nanosvg" - "Winmm.dll") + if(DEFINED MSVC) + set(COMMON_LIBRARIES + "${PROJECT_SOURCE_DIR}/FreeImage.lib" + "${PROJECT_SOURCE_DIR}/glew32.lib" + "${PROJECT_SOURCE_DIR}/libcurl-x64.lib" + "${PROJECT_SOURCE_DIR}/freetyped.lib" + "${PROJECT_SOURCE_DIR}/pugixml.lib" + "${PROJECT_SOURCE_DIR}/SDL2main.lib" + "${PROJECT_SOURCE_DIR}/libvlc.lib" + "${PROJECT_SOURCE_DIR}/SDL2.lib" + "nanosvg" + "Winmm.dll") + else() + set(COMMON_LIBRARIES + "${PROJECT_SOURCE_DIR}/FreeImage.dll" + "${PROJECT_SOURCE_DIR}/glew32.dll" + "${PROJECT_SOURCE_DIR}/libcurl-x64.dll" + "${PROJECT_SOURCE_DIR}/libfreetype.dll" + "${PROJECT_SOURCE_DIR}/libpugixml.dll" + "${PROJECT_SOURCE_DIR}/libSDL2main.a" + "${PROJECT_SOURCE_DIR}/libvlc.dll" + "${PROJECT_SOURCE_DIR}/SDL2.dll" + "mingw32" + "nanosvg" + "Winmm.dll") + endif() endif() if(APPLE) diff --git a/es-app/CMakeLists.txt b/es-app/CMakeLists.txt index cc5b889ba..7e764491a 100644 --- a/es-app/CMakeLists.txt +++ b/es-app/CMakeLists.txt @@ -115,10 +115,16 @@ endif() # Setup for installation and package generation. if(WIN32) install(TARGETS EmulationStation RUNTIME DESTINATION .) - install(FILES ../FreeImage.dll ../glew32.dll ../libcrypto-1_1-x64.dll ../libcurl-x64.dll - ../libfreetype.dll ../libgcc_s_seh-1.dll ../libpugixml.dll ../libssl-1_1-x64.dll - ../libstdc++-6.dll ../libvlc.dll ../libvlccore.dll ../libwinpthread-1.dll - ../SDL2.dll ../vcomp140.dll DESTINATION .) + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + install(FILES ../FreeImage.dll ../glew32.dll ../libcrypto-1_1-x64.dll ../libcurl-x64.dll + ../freetyped.dll ../pugixml.dll ../libssl-1_1-x64.dll ../libvlc.dll + ../libvlccore.dll ../SDL2.dll DESTINATION .) + else() + install(FILES ../FreeImage.dll ../glew32.dll ../libcrypto-1_1-x64.dll ../libcurl-x64.dll + ../libfreetype.dll ../libgcc_s_seh-1.dll ../libpugixml.dll ../libssl-1_1-x64.dll + ../libstdc++-6.dll ../libvlc.dll ../libvlccore.dll ../libwinpthread-1.dll + ../SDL2.dll ../vcomp140.dll DESTINATION .) + endif() install(DIRECTORY ${CMAKE_SOURCE_DIR}/plugins DESTINATION .) install(FILES ../LICENSE DESTINATION .) install(DIRECTORY ${CMAKE_SOURCE_DIR}/licenses DESTINATION .) diff --git a/es-app/src/VolumeControl.cpp b/es-app/src/VolumeControl.cpp index 05c70c69c..04355165e 100644 --- a/es-app/src/VolumeControl.cpp +++ b/es-app/src/VolumeControl.cpp @@ -15,6 +15,10 @@ #include "Settings.h" #endif +#if defined(_WIN64) +#include +#endif + // The ALSA Audio Card and Audio Device selection code is disabled at the moment. // As PulseAudio controls the sound devices for the desktop environment, it doesn't // make much sense to be able to select ALSA devices directly. Normally (always?) @@ -318,7 +322,7 @@ int VolumeControl::getVolume() const mixerControlDetails.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED); if (mixerGetControlDetails(reinterpret_cast(mixerHandle), &mixerControlDetails, MIXER_GETCONTROLDETAILSF_VALUE) == MMSYSERR_NOERROR) - volume = static_cast(Math::round((value.dwValue * 100) / 65535.0f)); + volume = static_cast(std::round((value.dwValue * 100) / 65535.0f)); else LOG(LogError) << "VolumeControl::getVolume() - Failed to get mixer volume!"; } @@ -326,7 +330,7 @@ int VolumeControl::getVolume() const // Windows Vista or above. use EndpointVolume API. float floatVolume = 0.0f; // 0-1 if (endpointVolume->GetMasterVolumeLevelScalar(&floatVolume) == S_OK) { - volume = static_cast(Math::round(floatVolume * 100.0f)); + volume = static_cast(std::round(floatVolume * 100.0f)); LOG(LogInfo) << "System audio volume is " << volume; } else { diff --git a/es-core/src/Platform.cpp b/es-core/src/Platform.cpp index bf018f429..697afb9d1 100644 --- a/es-core/src/Platform.cpp +++ b/es-core/src/Platform.cpp @@ -21,7 +21,9 @@ #include #endif +#if !defined(_WIN64) #include +#endif #include int runRebootCommand() diff --git a/es-core/src/components/MenuComponent.h b/es-core/src/components/MenuComponent.h index 6a6639cc4..91cdf96e8 100644 --- a/es-core/src/components/MenuComponent.h +++ b/es-core/src/components/MenuComponent.h @@ -15,6 +15,8 @@ #include "components/TextComponent.h" #include "utils/StringUtil.h" +#include + class ButtonComponent; class ImageComponent; diff --git a/es-core/src/resources/ResourceManager.h b/es-core/src/resources/ResourceManager.h index 76e2259a5..f589fd3ea 100644 --- a/es-core/src/resources/ResourceManager.h +++ b/es-core/src/resources/ResourceManager.h @@ -12,6 +12,7 @@ #include #include +#include // The ResourceManager exists to: // Allow loading resources embedded into the executable like an actual file. diff --git a/es-core/src/utils/FileSystemUtil.cpp b/es-core/src/utils/FileSystemUtil.cpp index 71f7f5679..08e4cd1dd 100644 --- a/es-core/src/utils/FileSystemUtil.cpp +++ b/es-core/src/utils/FileSystemUtil.cpp @@ -26,8 +26,11 @@ #if defined(_WIN64) #include #include -//#define S_ISREG(x) (((x) & S_IFMT) == S_IFREG) -//#define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR) +#if defined(_MSC_VER) // MSVC compiler. +#define stat64 _stat64 +#define S_ISREG(x) (((x) & S_IFMT) == S_IFREG) +#define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR) +#endif #else #include #include