Warning, /rolisteam/rolisteam/cmake/CompilerWarnings.cmake is written in an unsupported language. File is not indexed.
0001 # from here: 0002 # 0003 # https://github.com/lefticus/cppbestpractices/blob/master/02-Use_the_Tools_Avai lable.md 0004 0005 function(set_project_warnings project_name) 0006 option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors" TRUE) 0007 0008 set(MSVC_WARNINGS 0009 /W4 # Baseline reasonable warnings 0010 /w14242 # 'identifier': conversion from 'type1' to 'type1', possible loss of data 0011 /w14254 # 'operator': conversion from 'type1:field_bits' to 'type2:field_bits', possible loss of data 0012 /w14263 # 'function': member function does not override any base class virtual member function 0013 /w14265 # 'classname': class has virtual functions, but destructor is not virtual instances of this class may not 0014 # be destructed correctly 0015 /w14287 # 'operator': unsigned/negative constant mismatch 0016 /we4289 # nonstandard extension used: 'variable': loop control variable declared in the for-loop is used outside 0017 # the for-loop scope 0018 /w14296 # 'operator': expression is always 'boolean_value' 0019 /w14311 # 'variable': pointer truncation from 'type1' to 'type2' 0020 /w14545 # expression before comma evaluates to a function which is missing an argument list 0021 /w14546 # function call before comma missing argument list 0022 /w14547 # 'operator': operator before comma has no effect; expected operator with side-effect 0023 /w14549 # 'operator': operator before comma has no effect; did you intend 'operator'? 0024 /w14555 # expression has no effect; expected expression with side- effect 0025 /w14619 # pragma warning: there is no warning number 'number' 0026 /w14640 # Enable warning on thread un-safe static member initialization 0027 /w14826 # Conversion from 'type1' to 'type_2' is sign-extended. This may cause unexpected runtime behavior. 0028 /w14905 # wide string literal cast to 'LPSTR' 0029 /w14906 # string literal cast to 'LPWSTR' 0030 /w14928 # illegal copy-initialization; more than one user-defined conversion has been implicitly applied 0031 /permissive- # standards conformance mode for MSVC compiler. 0032 ) 0033 0034 set(CLANG_WARNINGS 0035 -Wall 0036 -Wextra # reasonable and standard 0037 -Wshadow # warn the user if a variable declaration shadows one from a parent context 0038 -Wnon-virtual-dtor # warn the user if a class with virtual functions has a non-virtual destructor. This helps 0039 # catch hard to track down memory errors 0040 -Wold-style-cast # warn for c-style casts 0041 -Wcast-align # warn for potential performance problem casts 0042 -Wunused # warn on anything being unused 0043 -Woverloaded-virtual # warn if you overload (not override) a virtual function 0044 -Wpedantic # warn if non-standard C++ is used 0045 -Wconversion # warn on type conversions that may lose data 0046 -Wsign-conversion # warn on sign conversions 0047 -Wnull-dereference # warn if a null dereference is detected 0048 -Wdouble-promotion # warn if float is implicit promoted to double 0049 -Wformat=2 # warn on security issues around functions that format output (ie printf) 0050 ) 0051 0052 if(WARNINGS_AS_ERRORS) 0053 set(CLANG_WARNINGS ${CLANG_WARNINGS} -Werror) 0054 set(MSVC_WARNINGS ${MSVC_WARNINGS} /WX) 0055 endif() 0056 0057 set(GCC_WARNINGS 0058 ${CLANG_WARNINGS} 0059 -Wmisleading-indentation # warn if indentation implies blocks where blocks do not exist 0060 -Wduplicated-cond # warn if if / else chain has duplicated conditions 0061 -Wduplicated-branches # warn if if / else branches have duplicated code 0062 -Wlogical-op # warn about logical operations being used where bitwise were probably wanted 0063 -Wuseless-cast # warn if you perform a cast to the same type 0064 ) 0065 0066 if(MSVC) 0067 set(PROJECT_WARNINGS ${MSVC_WARNINGS}) 0068 elseif(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") 0069 set(PROJECT_WARNINGS ${CLANG_WARNINGS}) 0070 elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") 0071 set(PROJECT_WARNINGS ${GCC_WARNINGS}) 0072 else() 0073 message(AUTHOR_WARNING "No compiler warnings set for '${CMAKE_CXX_COMPILER_ID}' compiler.") 0074 endif() 0075 0076 target_compile_options(${project_name} INTERFACE ${PROJECT_WARNINGS}) 0077 0078 endfunction()