2016-07-10 10:15:56 +02:00
|
|
|
# Check and configure compiler options for RPCS3
|
|
|
|
|
2019-06-22 22:54:42 -07:00
|
|
|
if(MSVC)
|
2021-04-18 23:06:58 +03:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:throwingNew- /constexpr:steps16777216 /D _CRT_SECURE_NO_DEPRECATE=1 /D _CRT_NON_CONFORMING_SWPRINTFS=1 /D _SCL_SECURE_NO_WARNINGS=1")
|
2021-09-12 05:55:53 +08:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D NOMINMAX /D _ENABLE_EXTENDED_ALIGNED_STORAGE=1 /D _HAS_EXCEPTIONS=0")
|
2019-06-22 22:54:42 -07:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS /DYNAMICBASE:NO /BASE:0x10000 /FIXED")
|
2016-07-10 10:15:56 +02:00
|
|
|
|
2019-06-28 12:01:32 +03:00
|
|
|
#TODO: Some of these could be cleaned up
|
|
|
|
add_compile_options(/wd4805) # Comparing boolean and int
|
|
|
|
add_compile_options(/wd4804) # Using integer operators with booleans
|
2019-10-25 13:32:21 +03:00
|
|
|
add_compile_options(/wd4200) # Zero-sized array in struct/union
|
|
|
|
add_link_options(/ignore:4281) # Undesirable base address 0x10000
|
2019-06-28 12:01:32 +03:00
|
|
|
|
|
|
|
# MSVC 2017 uses iterator as base class internally, causing a lot of warning spam
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D _SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING=1")
|
|
|
|
|
2019-06-22 22:54:42 -07:00
|
|
|
# Increase stack limit to 8 MB
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:8388608,1048576")
|
|
|
|
else()
|
|
|
|
# Some distros have the compilers set to use PIE by default, but RPCS3 doesn't work with PIE, so we need to disable it.
|
|
|
|
CHECK_CXX_COMPILER_FLAG("-no-pie" HAS_NO_PIE)
|
|
|
|
CHECK_CXX_COMPILER_FLAG("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE)
|
2021-12-30 19:39:18 +03:00
|
|
|
CHECK_CXX_COMPILER_FLAG("-msse -msse2 -mcx16" COMPILER_X86)
|
2022-04-04 12:36:13 -07:00
|
|
|
if (APPLE)
|
|
|
|
CHECK_CXX_COMPILER_FLAG("-march=armv8.4-a" COMPILER_ARM)
|
|
|
|
else()
|
|
|
|
CHECK_CXX_COMPILER_FLAG("-march=armv8.1-a" COMPILER_ARM)
|
|
|
|
endif()
|
2016-07-10 10:15:56 +02:00
|
|
|
|
2019-05-10 20:24:14 +03:00
|
|
|
add_compile_options(-Wall)
|
2020-03-09 19:18:39 +03:00
|
|
|
add_compile_options(-fno-exceptions)
|
2021-02-08 18:47:03 +03:00
|
|
|
add_compile_options(-fstack-protector)
|
2021-12-30 19:39:18 +03:00
|
|
|
|
|
|
|
if (COMPILER_X86)
|
|
|
|
add_compile_options(-msse -msse2 -mcx16)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (COMPILER_ARM)
|
2022-04-04 12:36:13 -07:00
|
|
|
if (APPLE)
|
|
|
|
add_compile_options(-march=armv8.4-a)
|
|
|
|
else()
|
|
|
|
add_compile_options(-march=armv8.1-a)
|
|
|
|
endif()
|
2021-12-30 19:39:18 +03:00
|
|
|
endif()
|
2017-10-06 20:52:08 +02:00
|
|
|
|
2019-12-04 23:56:19 +03:00
|
|
|
add_compile_options(-Werror=old-style-cast)
|
2020-02-19 20:03:59 +03:00
|
|
|
add_compile_options(-Werror=sign-compare)
|
2020-02-21 15:20:10 +03:00
|
|
|
add_compile_options(-Werror=reorder)
|
2021-01-06 23:33:09 +03:00
|
|
|
add_compile_options(-Werror=return-type)
|
2021-02-15 15:34:10 +03:00
|
|
|
add_compile_options(-Werror=overloaded-virtual)
|
2021-04-08 00:52:18 +03:00
|
|
|
add_compile_options(-Werror=missing-noreturn)
|
2021-03-05 22:05:37 +03:00
|
|
|
add_compile_options(-Wunused-parameter)
|
2021-03-07 18:49:42 +03:00
|
|
|
add_compile_options(-Wignored-qualifiers)
|
2021-03-21 18:02:21 +03:00
|
|
|
add_compile_options(-Wredundant-move)
|
|
|
|
add_compile_options(-Wcast-qual)
|
2021-03-29 16:20:10 +03:00
|
|
|
add_compile_options(-Wdeprecated-copy)
|
2021-03-13 23:01:37 +03:00
|
|
|
add_compile_options(-Wtautological-compare)
|
2021-03-08 23:41:23 +03:00
|
|
|
#add_compile_options(-Wshadow)
|
|
|
|
#add_compile_options(-Wconversion)
|
|
|
|
#add_compile_options(-Wpadded)
|
2021-03-07 19:47:29 +03:00
|
|
|
add_compile_options(-Wempty-body)
|
2021-03-23 22:32:50 +03:00
|
|
|
add_compile_options(-Wredundant-decls)
|
2021-04-19 11:11:24 +03:00
|
|
|
#add_compile_options(-Weffc++)
|
2020-12-28 17:07:41 -08:00
|
|
|
|
2021-03-08 23:41:23 +03:00
|
|
|
add_compile_options(-Wstrict-aliasing=1)
|
2021-03-01 15:03:00 +03:00
|
|
|
#add_compile_options(-Wnull-dereference)
|
2021-03-08 23:41:23 +03:00
|
|
|
|
2021-02-15 18:45:54 +03:00
|
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|
|
|
add_compile_options(-Werror=inconsistent-missing-override)
|
2021-04-17 14:40:24 +01:00
|
|
|
elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
|
2021-02-15 18:45:54 +03:00
|
|
|
add_compile_options(-Werror=suggest-override)
|
2021-03-07 19:47:29 +03:00
|
|
|
add_compile_options(-Wclobbered)
|
|
|
|
add_compile_options(-Wcast-function-type)
|
2021-03-13 18:03:08 +03:00
|
|
|
add_compile_options(-Wduplicated-branches)
|
2021-03-13 18:46:59 +03:00
|
|
|
add_compile_options(-Wduplicated-cond)
|
2021-02-15 18:45:54 +03:00
|
|
|
endif()
|
|
|
|
|
2019-06-22 22:54:42 -07:00
|
|
|
#TODO Clean the code so these are removed
|
|
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
2020-03-24 13:09:52 +03:00
|
|
|
add_compile_options(-fconstexpr-steps=16777216)
|
2019-06-22 22:54:42 -07:00
|
|
|
add_compile_options(-Wno-unused-lambda-capture)
|
|
|
|
add_compile_options(-Wno-unused-private-field)
|
|
|
|
add_compile_options(-Wno-delete-non-virtual-dtor)
|
|
|
|
add_compile_options(-Wno-unused-command-line-argument)
|
2021-04-17 14:40:24 +01:00
|
|
|
elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
|
2019-06-22 22:54:42 -07:00
|
|
|
add_compile_options(-Wno-class-memaccess)
|
2016-07-10 10:15:56 +02:00
|
|
|
endif()
|
2018-09-18 13:07:33 +03:00
|
|
|
|
2019-06-22 22:54:42 -07:00
|
|
|
if(USE_NATIVE_INSTRUCTIONS AND COMPILER_SUPPORTS_MARCH_NATIVE)
|
|
|
|
add_compile_options(-march=native)
|
2018-09-18 13:07:33 +03:00
|
|
|
endif()
|
|
|
|
|
2019-06-22 22:54:42 -07:00
|
|
|
if(NOT APPLE AND NOT WIN32)
|
|
|
|
# This hides our LLVM from mesa's LLVM, otherwise we get some unresolvable conflicts.
|
2018-09-18 13:07:33 +03:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--exclude-libs,ALL")
|
|
|
|
|
2019-06-22 22:54:42 -07:00
|
|
|
if(HAS_NO_PIE)
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -no-pie")
|
|
|
|
endif()
|
|
|
|
elseif(APPLE)
|
2021-12-12 21:35:56 +01:00
|
|
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
|
|
|
add_compile_options(-stdlib=libc++)
|
|
|
|
endif()
|
2022-04-04 12:36:13 -07:00
|
|
|
|
|
|
|
if (CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-image_base,0x10000 -Wl,-pagezero_size,0x10000")
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-no_pie")
|
|
|
|
endif()
|
2019-06-22 22:54:42 -07:00
|
|
|
elseif(WIN32)
|
2018-09-18 13:07:33 +03:00
|
|
|
set(CMAKE_RC_COMPILER_INIT windres)
|
|
|
|
enable_language(RC)
|
|
|
|
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
|
|
|
|
|
2019-06-22 22:54:42 -07:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_FORMAT_MACROS=1")
|
|
|
|
|
2018-09-18 13:07:33 +03:00
|
|
|
# Workaround for mingw64 (MSYS2)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--allow-multiple-definition")
|
|
|
|
|
2019-04-14 15:11:07 +03:00
|
|
|
# Increase stack limit to 8 MB
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--stack -Wl,8388608")
|
2018-09-18 13:07:33 +03:00
|
|
|
endif()
|
|
|
|
endif()
|