1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
# CMake common compiler options module
include_guard(GLOBAL)
# Set C and C++ language standards to C17 and C++17
set(CMAKE_C_STANDARD 17)
set(CMAKE_C_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
# Set symbols to be hidden by default for C and C++
set(CMAKE_C_VISIBILITY_PRESET hidden)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN TRUE)
# clang options for C, C++, ObjC, and ObjC++
set(
_obs_clang_common_options
-fno-strict-aliasing
-Wno-trigraphs
-Wno-missing-field-initializers
-Wno-missing-prototypes
-Werror=return-type
-Wunreachable-code
-Wquoted-include-in-framework-header
-Wno-missing-braces
-Wparentheses
-Wswitch
-Wno-unused-function
-Wno-unused-label
-Wunused-parameter
-Wunused-variable
-Wunused-value
-Wempty-body
-Wuninitialized
-Wno-unknown-pragmas
-Wfour-char-constants
-Wconstant-conversion
-Wno-conversion
-Wint-conversion
-Wbool-conversion
-Wenum-conversion
-Wnon-literal-null-conversion
-Wsign-compare
-Wshorten-64-to-32
-Wpointer-sign
-Wnewline-eof
-Wno-implicit-fallthrough
-Wdeprecated-declarations
-Wno-sign-conversion
-Winfinite-recursion
-Wcomma
-Wno-strict-prototypes
-Wno-semicolon-before-method-body
-Wformat-security
-Wvla
-Wno-error=shorten-64-to-32
)
# clang options for C
set(_obs_clang_c_options ${_obs_clang_common_options} -Wno-shadow -Wno-float-conversion)
# clang options for C++
set(
_obs_clang_cxx_options
${_obs_clang_common_options}
-Wno-non-virtual-dtor
-Wno-overloaded-virtual
-Wno-exit-time-destructors
-Wno-shadow
-Winvalid-offsetof
-Wmove
-Werror=block-capture-autoreleasing
-Wrange-loop-analysis
)
if(CMAKE_CXX_STANDARD GREATER_EQUAL 20)
list(APPEND _obs_clang_cxx_options -fno-char8_t)
endif()
if(NOT DEFINED CMAKE_COMPILE_WARNING_AS_ERROR)
set(CMAKE_COMPILE_WARNING_AS_ERROR ON)
endif()
|