mirror of
https://github.com/OpenRCT2/OpenRCT2.git
synced 2025-01-22 10:21:57 -05:00
Improve cmake for MSVC (#8581)
* Improve cmake for MSVC * Fix mingw builds
This commit is contained in:
parent
8a395e3706
commit
4192ffe57e
4 changed files with 22 additions and 10 deletions
|
@ -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)
|
||||
|
|
|
@ -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}/..")
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue