Warning, /graphics/digikam/core/cmake/macros/MacroCompiler.cmake is written in an unsupported language. File is not indexed.
0001 # Some useful macros to manage compiler rules 0002 # 0003 # For a complete list of GCC and Clang compiler warnings options available 0004 # depending of compiler version, check this url: 0005 # https://github.com/Barro/compiler-warnings 0006 # 0007 # SPDX-FileCopyrightText: 2010-2024 by Gilles Caulier, <caulier dot gilles at gmail dot com> 0008 # 0009 # SPDX-License-Identifier: BSD-3-Clause 0010 # 0011 0012 # ------------------------------------------------------------------------- 0013 0014 # Macro to remove GCC compilation option. 0015 0016 macro(REMOVE_GCC_COMPILER_WARNINGS COMPILATION_OPTION) 0017 0018 if(CMAKE_COMPILER_IS_GNUCXX) 0019 0020 message(STATUS "Remove GCC compiler option ${COMPILATION_OPTION} from ${CMAKE_CURRENT_SOURCE_DIR}") 0021 0022 while(CMAKE_CXX_FLAGS MATCHES ${COMPILATION_OPTION}) 0023 0024 string(REPLACE ${COMPILATION_OPTION} "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 0025 0026 endwhile() 0027 0028 endif() 0029 0030 endmacro() 0031 0032 # ------------------------------------------------------------------------- 0033 0034 # Macro to remove CLANG compilation option. 0035 0036 macro(REMOVE_CLANG_COMPILER_WARNINGS COMPILATION_OPTION) 0037 0038 if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") 0039 0040 message(STATUS "Remove CLANG compiler option ${COMPILATION_OPTION} from ${CMAKE_CURRENT_SOURCE_DIR}") 0041 0042 while(CMAKE_CXX_FLAGS MATCHES ${COMPILATION_OPTION}) 0043 0044 string(REPLACE ${COMPILATION_OPTION} "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 0045 0046 endwhile() 0047 0048 endif() 0049 0050 endmacro() 0051 0052 # ------------------------------------------------------------------------- 0053 0054 # Macro to remove GCC or CLANG compilation option which use the same syntax. 0055 0056 macro(REMOVE_COMPILER_WARNINGS COMPILATION_OPTION) 0057 0058 REMOVE_GCC_COMPILER_WARNINGS(${COMPILATION_OPTION}) 0059 REMOVE_CLANG_COMPILER_WARNINGS(${COMPILATION_OPTION}) 0060 0061 endmacro() 0062 0063 # ------------------------------------------------------------------------- 0064 0065 # Macro to disable GCC compilation option using -Wno* syntax. 0066 0067 macro(DISABLE_GCC_COMPILER_WARNINGS COMPILER_VERSION NO_COMPILATION_OPTION) 0068 0069 if(CMAKE_COMPILER_IS_GNUCXX) 0070 0071 execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "${CMAKE_CXX_COMPILER_ARG1}" "-dumpversion" OUTPUT_VARIABLE GCC_VERSION) 0072 0073 if (${GCC_VERSION} VERSION_GREATER ${COMPILER_VERSION}) 0074 0075 message(STATUS "Disable GCC compiler option ${NO_COMPILATION_OPTION} from ${CMAKE_CURRENT_SOURCE_DIR}") 0076 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${NO_COMPILATION_OPTION}") 0077 0078 endif() 0079 0080 endif() 0081 0082 endmacro() 0083 0084 # ------------------------------------------------------------------------- 0085 0086 # Macro to disable CLANG compilation option using -Wno* syntax. 0087 0088 macro(DISABLE_CLANG_COMPILER_WARNINGS COMPILER_VERSION NO_COMPILATION_OPTION) 0089 0090 if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") 0091 0092 execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "${CMAKE_CXX_COMPILER_ARG1}" "-dumpversion" OUTPUT_VARIABLE CLANG_VERSION) 0093 0094 if (${CLANG_VERSION} VERSION_GREATER ${COMPILER_VERSION}) 0095 0096 message(STATUS "Disable CLANG compiler option ${NO_COMPILATION_OPTION} from ${CMAKE_CURRENT_SOURCE_DIR}") 0097 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${NO_COMPILATION_OPTION}") 0098 0099 endif() 0100 0101 endif() 0102 0103 endmacro()