From 8daca5b69ef63cb3d12f45719ed60ea8a253594e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Sun, 27 Sep 2020 20:29:49 +0200 Subject: [PATCH] Add better controls over MinGW jobs to CMake --- CMakeLists.txt | 14 ++++++++++++++ src/openrct2/CMakeLists.txt | 10 ++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d25a4d6b8..8ab7a83758 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,6 +67,9 @@ option(DISABLE_NETWORK "Disable multiplayer functionality. Mainly for testing.") option(DISABLE_TTF "Disable support for TTF provided by freetype2.") option(ENABLE_LIGHTFX "Enable lighting effects." 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.)") @@ -76,6 +79,13 @@ if (FORCE32) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${TARGET_M}") 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) set(CMAKE_INSTALL_LIBDIR "${CMAKE_INSTALL_BINDIR}") set(CMAKE_INSTALL_RPATH "$ORIGIN") @@ -279,6 +289,10 @@ if (CXX_WARN_SUGGEST_FINAL_METHODS) add_definitions(-D__WARN_SUGGEST_FINAL_METHODS__) endif () +if (MINGW) + add_definitions(-fstack-protector-strong) +endif () + # Include sub-projects include("${ROOT_DIR}/src/openrct2/CMakeLists.txt" NO_POLICY_SCOPE) include("${ROOT_DIR}/src/openrct2-cli/CMakeLists.txt" NO_POLICY_SCOPE) diff --git a/src/openrct2/CMakeLists.txt b/src/openrct2/CMakeLists.txt index 88e5e05dff..da65bbb93f 100644 --- a/src/openrct2/CMakeLists.txt +++ b/src/openrct2/CMakeLists.txt @@ -30,7 +30,7 @@ if (NOT MINGW AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" AND NOT ${CMAKE_SYS endif() if (NOT DISABLE_NETWORK OR NOT DISABLE_HTTP) - if (WIN32) + if (WIN32 AND NOT MINGW_TARGET_NT5_1) target_link_libraries(${PROJECT_NAME} bcrypt) else () if (APPLE) @@ -55,7 +55,7 @@ if (NOT DISABLE_NETWORK AND WIN32) endif () if (NOT DISABLE_HTTP) - if (WIN32) + if (WIN32 AND NOT MINGW_TARGET_NT5_1) target_link_libraries(${PROJECT_NAME} winhttp) else () PKG_CHECK_MODULES(LIBCURL REQUIRED libcurl) @@ -146,8 +146,10 @@ else () endif () if (MINGW) - # Hardcode libraries used by libzip on mingw - target_link_libraries(${PROJECT_NAME} crypto ws2_32) + # Hardcode libraries used on mingw + 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() if (UNIX AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "BSD")