"Fossies" - the Fresh Open Source Software Archive

Member "evolution-mapi-3.46.1/cmake/modules/SetupBuildFlags.cmake" (2 Dec 2022, 2415 Bytes) of package /linux/misc/evolution-mapi-3.46.1.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) CMake source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 # SetupBuildFlags.cmake
    2 #
    3 # Setups compiler/linker flags, skipping those which are not supported.
    4 
    5 include(CheckCCompilerFlag)
    6 
    7 if(CMAKE_CXX_COMPILER_ID)
    8     include(CheckCXXCompilerFlag)
    9 endif(CMAKE_CXX_COMPILER_ID)
   10 
   11 macro(setup_build_flags _maintainer_mode)
   12     list(APPEND proposed_flags
   13         -Wformat
   14         -Wformat-security
   15         -Winit-self
   16         -Wmissing-declarations
   17         -Wmissing-noreturn
   18         -Wpointer-arith
   19         -Wredundant-decls
   20         -Wundef
   21         -Wwrite-strings
   22         -Wno-cast-function-type
   23         -Wl,--no-undefined
   24         -fno-strict-aliasing
   25     )
   26 
   27     if(${_maintainer_mode})
   28         list(APPEND proposed_flags
   29             -Wall
   30             -Wextra
   31             -Wdeprecated-declarations
   32             -Wmissing-include-dirs
   33         )
   34     else(${_maintainer_mode})
   35         list(APPEND proposed_flags
   36             -Wno-deprecated-declarations
   37             -Wno-missing-include-dirs)
   38     endif(${_maintainer_mode})
   39 
   40     list(APPEND proposed_c_flags
   41         ${proposed_flags}
   42         -Werror-implicit-function-declaration
   43         -Wdeclaration-after-statement
   44         -Wno-missing-field-initializers
   45         -Wno-sign-compare
   46         -Wno-unused-parameter
   47         -Wnested-externs
   48     )
   49 
   50     if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
   51         list(APPEND proposed_c_flags
   52             -Wno-parentheses-equality
   53             -Wno-format-nonliteral
   54         )
   55     endif("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
   56 
   57     list(APPEND proposed_cxx_flags
   58         ${proposed_flags}
   59         -Wnoexcept
   60     )
   61 
   62     foreach(flag IN LISTS proposed_c_flags)
   63         check_c_compiler_flag(${flag} c_flag_${flag}_supported)
   64         if(c_flag_${flag}_supported)
   65             set(CMAKE_C_FLAGS "${flag} ${CMAKE_C_FLAGS}")
   66         endif(c_flag_${flag}_supported)
   67         unset(c_flag_${flag}_supported)
   68     endforeach()
   69 
   70     if(CMAKE_CXX_COMPILER_ID)
   71         foreach(flag IN LISTS proposed_cxx_flags)
   72             check_cxx_compiler_flag(${flag} cxx_flag_${flag}_supported)
   73             if(cxx_flag_${flag}_supported)
   74                 set(CMAKE_CXX_FLAGS "${flag} ${CMAKE_CXX_FLAGS}")
   75             endif(cxx_flag_${flag}_supported)
   76             unset(cxx_flag_${flag}_supported)
   77         endforeach()
   78     endif(CMAKE_CXX_COMPILER_ID)
   79 
   80     if(("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") AND (NOT ${CMAKE_SYSTEM_NAME} MATCHES "BSD"))
   81         set(CMAKE_EXE_LINKER_FLAGS "-Wl,--no-undefined ${CMAKE_EXE_LINKER_FLAGS}")
   82         set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--no-undefined ${CMAKE_MODULE_LINKER_FLAGS}")
   83         set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined ${CMAKE_SHARED_LINKER_FLAGS}")
   84     endif(("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") AND (NOT ${CMAKE_SYSTEM_NAME} MATCHES "BSD"))
   85 endmacro()