X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=cmake%2FQuasselCompileSettings.cmake;h=7d6f71a3322b9beb7d4e59b61f76bc3d9f3d6325;hp=f906de531b8b680f8b84547ec13b58400ef944bc;hb=a078e08390e41385a3145f22e83afbf622621c2f;hpb=12e650ff4be67680e3e3f31e2aa79653c429756b diff --git a/cmake/QuasselCompileSettings.cmake b/cmake/QuasselCompileSettings.cmake index f906de53..7d6f71a3 100644 --- a/cmake/QuasselCompileSettings.cmake +++ b/cmake/QuasselCompileSettings.cmake @@ -7,43 +7,18 @@ include(CheckCXXCompilerFlag) -if (CMAKE_CONFIGURATION_TYPES) - set(CMAKE_CONFIGURATION_TYPES Release RelWithDebInfo Debug Debugfull Profile) - set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "These are the configuration types we support" FORCE) -endif() - -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo Debug Debugfull Profile" FORCE) -endif() - -# Qt debug flags -set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG QT_DEBUG) -set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUGFULL QT_DEBUG) -set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE QT_NO_DEBUG NDEBUG) -set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO QT_NO_DEBUG NDEBUG) -set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_PROFILE QT_NO_DEBUG NDEBUG) -set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_MINSIZEREL QT_NO_DEBUG NDEBUG) - -if (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) - set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_DEBUG NDEBUG) -endif() - # Enable various flags on gcc if (CMAKE_COMPILER_IS_GNUCXX) - if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.7") - message(WARNING "Your compiler is too old; we expect at least GCC 4.7. Your build will likely fail.") + 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") + 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") - set(CMAKE_CXX_FLAGS_DEBUGFULL "-g3 -ggdb -fno-inline") - set(CMAKE_CXX_FLAGS_PROFILE "-g3 -ggdb -fno-inline -ftest-coverage -fprofile-arcs") - - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ansi -W -Wall -Wextra -Wnon-virtual-dtor -fno-strict-aliasing -Wundef -Wcast-align -Wpointer-arith -Wformat-security -fno-check-new -fno-common") check_cxx_compiler_flag(-Woverloaded-virtual CXX_W_OVERLOADED_VIRTUAL) if(CXX_W_OVERLOADED_VIRTUAL) @@ -54,26 +29,27 @@ if (CMAKE_COMPILER_IS_GNUCXX) 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.1") - message(WARNING "Your compiler is too old; we expect at least Clang 3.1. Your build will likely fail.") +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.") endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wnon-virtual-dtor -Wno-long-long -Wundef -Wcast-align -Wchar-subscripts -Wall -W -Wextra -Wpointer-arith -Wformat-security -Woverloaded-virtual -fno-common -Wno-deprecated-register") # set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG -DQT_NO_DEBUG") # Use CMake default # set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG -DQT_NO_DEBUG") # Use CMake default set(CMAKE_CXX_FLAGS_DEBUG "-g -O2 -fno-inline") - set(CMAKE_CXX_FLAGS_DEBUGFULL "-g3 -fno-inline") - set(CMAKE_CXX_FLAGS_PROFILE "-g3 -fno-inline -ftest-coverage -fprofile-arcs") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-function -Wno-undef -fno-strict-aliasing") -# For MSVC, at least do a version sanity check -elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC") - if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "18.0") - message(WARNING "Your compiler is too old; we expect at least Visual Studio Nov 2013 CTP (MSVC 18). Your build will likely fail.") +# For MSVC, at least do a version sanity check... +elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "19.0") + message(FATAL_ERROR "Your compiler is too old; you need at least Visual Studio 2015 (MSVC 19.0+), GCC 4.8+, Clang 3.3+, or any other compiler with full C++11 support.") endif() + # ... and enable exception handling (required for STL types) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") + # Unknown/unsupported compiler else() message(WARNING "Unknown or unsupported compiler. Make sure to enable C++11 support. Good luck.") @@ -82,6 +58,5 @@ endif() # Mac build stuff if (APPLE AND DEPLOY) set(CMAKE_OSX_ARCHITECTURES "x86_64") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.8") - set(CMAKE_OSX_SYSROOT "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.9 -stdlib=libc++") endif()