Add better controls over MinGW jobs to CMake

This commit is contained in:
Michał Janiszewski 2020-09-27 20:29:49 +02:00
parent 92e7677e4b
commit 8daca5b69e
2 changed files with 20 additions and 4 deletions

View file

@ -67,6 +67,9 @@ option(DISABLE_NETWORK "Disable multiplayer functionality. Mainly for testing.")
option(DISABLE_TTF "Disable support for TTF provided by freetype2.") option(DISABLE_TTF "Disable support for TTF provided by freetype2.")
option(ENABLE_LIGHTFX "Enable lighting effects." ON) option(ENABLE_LIGHTFX "Enable lighting effects." ON)
option(ENABLE_SCRIPTING "Enable script / plugin support." ON) option(ENABLE_SCRIPTING "Enable script / plugin support." ON)
if (MINGW)
option(MINGW_TARGET_NT5_1 "Use only NT5.1 APIs and libraries." OFF)
endif ()
option(DISABLE_GUI "Don't build GUI. (Headless only.)") option(DISABLE_GUI "Don't build GUI. (Headless only.)")
@ -76,6 +79,13 @@ if (FORCE32)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${TARGET_M}") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${TARGET_M}")
endif () endif ()
if (MINGW_TARGET_NT5_1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_WIN32_WINNT=0x501")
if (STATIC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCURL_STATICLIB=1 -DZIP_STATIC=1 -static")
endif ()
endif ()
if (PORTABLE OR WIN32) if (PORTABLE OR WIN32)
set(CMAKE_INSTALL_LIBDIR "${CMAKE_INSTALL_BINDIR}") set(CMAKE_INSTALL_LIBDIR "${CMAKE_INSTALL_BINDIR}")
set(CMAKE_INSTALL_RPATH "$ORIGIN") set(CMAKE_INSTALL_RPATH "$ORIGIN")
@ -279,6 +289,10 @@ if (CXX_WARN_SUGGEST_FINAL_METHODS)
add_definitions(-D__WARN_SUGGEST_FINAL_METHODS__) add_definitions(-D__WARN_SUGGEST_FINAL_METHODS__)
endif () endif ()
if (MINGW)
add_definitions(-fstack-protector-strong)
endif ()
# Include sub-projects # Include sub-projects
include("${ROOT_DIR}/src/openrct2/CMakeLists.txt" NO_POLICY_SCOPE) include("${ROOT_DIR}/src/openrct2/CMakeLists.txt" NO_POLICY_SCOPE)
include("${ROOT_DIR}/src/openrct2-cli/CMakeLists.txt" NO_POLICY_SCOPE) include("${ROOT_DIR}/src/openrct2-cli/CMakeLists.txt" NO_POLICY_SCOPE)

View file

@ -30,7 +30,7 @@ if (NOT MINGW AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" AND NOT ${CMAKE_SYS
endif() endif()
if (NOT DISABLE_NETWORK OR NOT DISABLE_HTTP) if (NOT DISABLE_NETWORK OR NOT DISABLE_HTTP)
if (WIN32) if (WIN32 AND NOT MINGW_TARGET_NT5_1)
target_link_libraries(${PROJECT_NAME} bcrypt) target_link_libraries(${PROJECT_NAME} bcrypt)
else () else ()
if (APPLE) if (APPLE)
@ -55,7 +55,7 @@ if (NOT DISABLE_NETWORK AND WIN32)
endif () endif ()
if (NOT DISABLE_HTTP) if (NOT DISABLE_HTTP)
if (WIN32) if (WIN32 AND NOT MINGW_TARGET_NT5_1)
target_link_libraries(${PROJECT_NAME} winhttp) target_link_libraries(${PROJECT_NAME} winhttp)
else () else ()
PKG_CHECK_MODULES(LIBCURL REQUIRED libcurl) PKG_CHECK_MODULES(LIBCURL REQUIRED libcurl)
@ -146,8 +146,10 @@ else ()
endif () endif ()
if (MINGW) if (MINGW)
# Hardcode libraries used by libzip on mingw # Hardcode libraries used on mingw
target_link_libraries(${PROJECT_NAME} crypto ws2_32) target_link_libraries(${PROJECT_NAME} crypto ws2_32 tasn1 unistring iconv p11-kit hogweed gmp nettle)
# Link in libssp
target_link_libraries(${PROJECT_NAME} -fstack-protector-strong)
endif() endif()
if (UNIX AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "BSD") if (UNIX AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "BSD")