Don't statically link libgcc, and don't use GCC/Clang flags on MSVC when cross-compiling for windows

This commit is contained in:
Username404 2021-08-18 20:32:56 +02:00
parent 66af9b9e2b
commit 4b0e58dd6a
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 4 additions and 3 deletions

View File

@ -33,11 +33,10 @@ set(MINIMAL_CLANG "13.0")
if (NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
set(CMAKE_CXX_FLAGS_RELEASE "-Os")
endif()
set(CMAKE_CXX_FLAGS_RELEASE "-Os")
if ((${CMAKE_CXX_COMPILER_ID} STREQUAL GNU) OR (${CMAKE_CXX_COMPILER_ID} STREQUAL Clang))
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc")
set(CMAKE_CXX_FLAGS "-flto ${CMAKE_CXX_FLAGS} -pipe -fstack-protector-strong -fstack-clash-protection -fexceptions")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffunction-sections -fdata-sections -fmerge-all-constants -ftree-vectorize")
include(CheckCXXCompilerFlag)
@ -151,7 +150,9 @@ elseif(MINGW OR MSVC)
set(CMAKE_INSTALL_PREFIX "C:\\progs\\${PROJECT_NAME}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CODENAME})
set(CPACK_NSIS_INSTALL_ROOT "${CMAKE_INSTALL_PREFIX}")
set(CMAKE_EXE_LINKER_FLAGS "-static -static-libstdc++ ${CMAKE_EXE_LINKER_FLAGS}")
if (MINGW)
set(CMAKE_EXE_LINKER_FLAGS "-static -static-libstdc++ -static-libgcc ${CMAKE_EXE_LINKER_FLAGS}")
endif()
set(CPACK_PACKAGE_FILE_NAME "${PNAME}_wpkg")
set(CPACK_NSIS_COMPRESSOR "/SOLID lzma")
set(CPACK_NSIS_MANIFEST_DPI_AWARE true)