-
-# Enable various flags on gcc
-if (CMAKE_COMPILER_IS_GNUCXX)
- if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8")
- message(FATAL_ERROR "Your compiler is too old; you need GCC 4.8+, Clang 3.3+, MSVC 19.0+, or any other compiler with full C++11 support.")
- endif()
-
- # Let's just hope that all gccs support these options and skip the tests...
- # -fno-strict-aliasing is needed apparently for Qt < 4.6
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -Wnon-virtual-dtor -fno-strict-aliasing -Wundef -Wcast-align -Wpointer-arith -Wformat-security -fno-check-new -fno-common")
- # set(CMAKE_CXX_FLAGS_RELEASE "-O2") # use CMake default
- # set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O2") # use CMake default
- set(CMAKE_CXX_FLAGS_DEBUG "-g -ggdb -O2 -fno-reorder-blocks -fno-schedule-insns -fno-inline")
-
- check_cxx_compiler_flag(-Woverloaded-virtual CXX_W_OVERLOADED_VIRTUAL)
- if(CXX_W_OVERLOADED_VIRTUAL)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual")
- endif()
-
- # Just for miniz
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-function -Wno-undef -fno-strict-aliasing")
-
-# ... and for Clang
-elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
- if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.3")
- message(FATAL_ERROR "Your compiler is too old; you need Clang 3.3+, GCC 4.8+, MSVC 19.0+, or any other compiler with full C++11 support.")
+function(check_and_set_linker_flag flag name outvar)
+ cmake_push_check_state(RESET)
+ set(CMAKE_REQUIRED_FLAGS "${flag}")
+ check_cxx_compiler_flag("" LINKER_SUPPORTS_${name})
+ if (LINKER_SUPPORTS_${name})
+ set(${outvar} "${${outvar}} ${flag}" PARENT_SCOPE)