diff --git a/CMakeLists.txt b/CMakeLists.txt index d7fbe57ad1..a060d75a04 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -169,7 +169,9 @@ if(ENABLE_GENERIC) elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64") set(_M_X86 1) set(_M_X86_64 1) - add_definitions(-D_M_X86=1 -D_M_X86_64=1 -msse2) + add_definitions(-D_M_X86=1) + add_definitions(-D_M_X86_64=1) + check_and_add_flag(HAVE_SSE2 -msse2) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-pie") if(CMAKE_CXX_COMPILER_ID STREQUAL GNU) CHECK_C_COMPILER_FLAG("-no-pie" NO_PIE_UPSTREAM) @@ -184,8 +186,10 @@ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64") elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64") set(_M_ARM 1) set(_M_ARM_64 1) - add_definitions(-D_M_ARM=1 -D_M_ARM_64=1) - add_definitions(-march=armv8-a+crc) + add_definitions(-D_M_ARM=1) + add_definitions(-D_M_ARM_64=1) + # CRC instruction set is used in the CRC32 hash function + check_and_add_flag(HAVE_ARCH_ARMV8 -march=armv8-a+crc) else() message(FATAL_ERROR "You're building on an unsupported platform. Enable generic build if you really want a JIT-less binary.") endif() @@ -196,10 +200,9 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_L message(FATAL_ERROR "Dolphin requires at least GCC 5.0 (found ${CMAKE_CXX_COMPILER_VERSION})") endif() -# Enabling all warnings in MSVC spams too much if(NOT MSVC) - add_definitions(-Wall) add_definitions(-D_DEFAULT_SOURCE) + check_and_add_flag(HAVE_WALL -Wall) # TODO: would like these but they produce overwhelming amounts of warnings #check_and_add_flag(EXTRA -Wextra) #check_and_add_flag(MISSING_FIELD_INITIALIZERS -Wmissing-field-initializers) @@ -311,7 +314,7 @@ endif() if(UNIX) option(LINUX_LOCAL_DEV "Enable relocatable binary" OFF) if(LINUX_LOCAL_DEV) - add_definitions('-DLINUX_LOCAL_DEV') + add_definitions(-DLINUX_LOCAL_DEV) endif(LINUX_LOCAL_DEV) endif(UNIX) @@ -335,15 +338,19 @@ if(NOT CMAKE_BUILD_TYPE) endif(NOT CMAKE_BUILD_TYPE) -if(CMAKE_BUILD_TYPE STREQUAL Debug) - add_definitions(-D_DEBUG -ggdb) +if(CMAKE_BUILD_TYPE STREQUAL "Debug") + add_definitions(-D_DEBUG) + check_and_add_flag(GGDB -ggdb) option(ENABLE_GPROF "Enable gprof profiling (must be using Debug build)" OFF) if(ENABLE_GPROF) - add_definitions(-pg) + check_and_add_flag(HAVE_PG -pg) + if(NOT FLAG_C_HAVE_PG) + message(FATAL_ERROR "Compiler option -pg is not supported") + endif() set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg") endif() -endif(CMAKE_BUILD_TYPE STREQUAL Debug) +endif() if(FASTLOG) add_definitions(-DDEBUGFAST)