diff --git a/CMakeLists.txt b/CMakeLists.txt index 6338c54611..5921bb3a18 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -167,13 +167,15 @@ function (ADD_CHECK_CXX_FLAG _CXXFLAGS _CACHE_VAR _FLAG) endfunction () if (MSVC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8 /permissive- /Zc:externConstexpr /WX") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8 /permissive- /Zc:externConstexpr /EHsc /WX") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4244") # C4244: 'conversion_type': conversion from 'type1' to 'type2', possible loss of data + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4068") # C4068: unknown pragma add_definitions(-D_CRT_SECURE_NO_WARNINGS) add_definitions(-D_SCL_SECURE_NO_WARNINGS) add_definitions(-D__SSE4_1__) add_definitions(-D__AVX2__) + add_definitions(-DNOMINMAX) else () ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_NULL_DEREFERENCE -Wnull-dereference) ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_SUGGEST_FINAL_TYPES -Wsuggest-final-types) diff --git a/src/openrct2-cli/CMakeLists.txt b/src/openrct2-cli/CMakeLists.txt index e2c444fdf9..8f06fcf33a 100644 --- a/src/openrct2-cli/CMakeLists.txt +++ b/src/openrct2-cli/CMakeLists.txt @@ -27,5 +27,9 @@ if (APPLE) target_link_libraries(${PROJECT} "-framework Cocoa") endif () +if (WIN32) + target_link_libraries(${PROJECT} gdi32) +endif () + # Includes target_include_directories(${PROJECT} PRIVATE "${CMAKE_CURRENT_LIST_DIR}/..") diff --git a/src/openrct2-ui/CMakeLists.txt b/src/openrct2-ui/CMakeLists.txt index 52bd7a62b9..a37b586bd4 100644 --- a/src/openrct2-ui/CMakeLists.txt +++ b/src/openrct2-ui/CMakeLists.txt @@ -10,14 +10,7 @@ option(DISABLE_OPENGL "Disable OpenGL support.") # Third party libraries if (MSVC) find_package(jansson REQUIRED) - - find_path(SDL2_INCLUDE_DIRS SDL2/SDL.h) - if (CMAKE_BUILD_TYPE STREQUAL "Debug") - find_library(SDL2_LDFLAGS sdl2d) - else () - find_library(SDL2_LDFLAGS sdl2) - endif () - + find_package(SDL2 REQUIRED) find_library(SPEEX_LDFLAGS libspeexdsp) else () PKG_CHECK_MODULES(SDL2 REQUIRED sdl2) @@ -80,6 +73,19 @@ if (WIN32) # mingw complains about "%zu" not being a valid format specifier for printf, unless we # tell it that it is set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__USE_MINGW_ANSI_STDIO=1") + target_link_libraries(${PROJECT} comdlg32) + if (MSVC) + target_link_libraries(${PROJECT} SDL2::SDL2-static) + target_include_directories(${PROJECT} SYSTEM PRIVATE SDL2::SDL2-static) + else () + # mingw does not provide proper CMake information like other configurations + find_path(SDL2_INCLUDE_DIRS SDL2/SDL.h) + if (CMAKE_BUILD_TYPE STREQUAL "Debug") + find_library(SDL2_LDFLAGS sdl2d) + else () + find_library(SDL2_LDFLAGS sdl2) + endif () + endif () endif () if (MSVC) # Add DPI-aware manifest diff --git a/src/openrct2/CMakeLists.txt b/src/openrct2/CMakeLists.txt index bccc763bd2..ee4a1f0231 100644 --- a/src/openrct2/CMakeLists.txt +++ b/src/openrct2/CMakeLists.txt @@ -105,7 +105,7 @@ endif () if (NOT DISABLE_NETWORK) if (WIN32) - target_link_libraries(${PROJECT} ws2_32 crypt32 wldap32 version winmm imm32) + target_link_libraries(${PROJECT} ws2_32 crypt32 wldap32 version winmm imm32 advapi32 shell32 ole32) endif () # our HTTP implementation requires use of threads