1 # This file contains compile flags and general build configuration for Quassel
3 # (C) 2014-2018 by the Quassel Project <devel@quassel-irc.org>
5 # Redistribution and use is allowed according to the terms of the BSD license.
6 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
8 # Helper function to check for linker flag support
9 include(CheckCXXCompilerFlag)
10 function(check_and_set_linker_flag flag name outvar)
11 cmake_push_check_state(RESET)
12 set(CMAKE_REQUIRED_FLAGS "${flag}")
13 check_cxx_compiler_flag("" LINKER_SUPPORTS_${name})
14 if (LINKER_SUPPORTS_${name})
15 set(${outvar} "${${outvar}} ${flag}" PARENT_SCOPE)
17 cmake_pop_check_state()
20 # General compile settings
21 set(CMAKE_CXX_STANDARD 14)
22 set(CMAKE_CXX_STANDARD_REQUIRED OFF) # Rely on compile features if standard is not supported
23 set(CMAKE_CXX_EXTENSIONS OFF) # We like to be standard conform
25 set(CMAKE_CXX_VISIBILITY_PRESET hidden)
26 set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
27 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
29 # For GCC and Clang, enable a whole bunch of warnings
30 if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
41 -fstack-protector-strong
42 "$<$<NOT:$<CONFIG:Debug>>:-U_FORTIFY_SOURCE;-D_FORTIFY_SOURCE=2>"
45 # Check for and set linker flags
46 check_and_set_linker_flag("-Wl,-z,relro" RELRO LINKER_FLAGS)
47 check_and_set_linker_flag("-Wl,-z,now" NOW LINKER_FLAGS)
48 check_and_set_linker_flag("-Wl,--as-needed" AS_NEEDED LINKER_FLAGS)
50 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LINKER_FLAGS}")
51 set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${LINKER_FLAGS}")
52 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${LINKER_FLAGS}")
54 # For other compilers, we rely on default settings (unless someone provides a good set of options; patches welcome!)
59 set(CMAKE_OSX_ARCHITECTURES "x86_64")
61 -mmacosx-version-min=10.9