svn commit: r1936655 - subversion/trunk
[email protected] Tue, 28 Jul 2026 03:09:31 -0000
| Newsgroups | gmane.comp.version-control.subversion.svn |
|---|---|
| Message-ID | <178520817195.3342466.14965686739836548056@svn03-he-fi> |
Author: jun66j5
Date: Tue Jul 28 03:09:31 2026
New Revision: 1936655
Log:
cmake: Prevent `SVN_CFLAGS_ADD_IFELSE` from applying the flags to anything
other than the C compiler.
* CMakeLists.txt
(svn_add_compiler_options_ifelse):
Add the function to add compiler flags if each one is supported by the
compiler for the lang.
(SVN_CFLAGS_ADD_IFELSE):
Use `svn_add_compiler_options_ifelse()` simply; it allows for multiple
flags and prevents them from being applied to other compilers.
(SVN_CXXFLAGS_ADD_IFELSE):
Add the function for C++.
Modified:
subversion/trunk/CMakeLists.txt
Modified: subversion/trunk/CMakeLists.txt
==============================================================================
--- subversion/trunk/CMakeLists.txt Tue Jul 28 02:55:18 2026 (r1936654)
+++ subversion/trunk/CMakeLists.txt Tue Jul 28 03:09:31 2026 (r1936655)
@@ -379,15 +379,30 @@ else()
# the -W syntax
include(CheckCompilerFlag)
- # Adds flags if one is supported by the compiler
- function(SVN_CFLAGS_ADD_IFELSE flag)
- set(variable "HAVE_FLAG_${flag}")
- check_compiler_flag(C ${flag} ${variable})
- if (${${variable}})
- add_compile_options("${flag}")
+
+ # Adds flags if each one is supported by the compiler for the lang
+ function(svn_add_compiler_options_ifelse lang)
+ if(CMAKE_${lang}_COMPILER)
+ foreach(flag ${ARGN})
+ if(flag)
+ set(variable "HAVE_FLAG_${lang}_${flag}")
+ check_compiler_flag(${lang} ${flag} ${variable})
+ if(${${variable}})
+ add_compile_options($<$<COMPILE_LANGUAGE:${lang}>:${flag}>)
+ endif()
+ endif()
+ endforeach()
endif()
endfunction()
+ function(SVN_CFLAGS_ADD_IFELSE)
+ svn_add_compiler_options_ifelse(C ${ARGN})
+ endfunction()
+
+ function(SVN_CXXFLAGS_ADD_IFELSE)
+ svn_add_compiler_options_ifelse(CXX ${ARGN})
+ endfunction()
+
# Add flags that all versions of GCC/G++ (should) support
add_compile_options(
-Wpointer-arith
@@ -412,17 +427,25 @@ else()
$<$<COMPILE_LANGUAGE:CXX>:-Wunreachable-code>
)
- # Add each of the following flags only if the C compiler accepts it.
- SVN_CFLAGS_ADD_IFELSE(-Werror=implicit-function-declaration)
- SVN_CFLAGS_ADD_IFELSE(-Werror=declaration-after-statement)
- SVN_CFLAGS_ADD_IFELSE(-Wextra-tokens)
- SVN_CFLAGS_ADD_IFELSE(-Wnewline-eof)
- SVN_CFLAGS_ADD_IFELSE(-Wshorten-64-to-32)
- SVN_CFLAGS_ADD_IFELSE(-Wold-style-definition)
- SVN_CFLAGS_ADD_IFELSE(-Wno-system-headers)
- SVN_CFLAGS_ADD_IFELSE(-Wno-format-nonliteral)
- SVN_CFLAGS_ADD_IFELSE(-Wmissing-variable-declarations)
- SVN_CFLAGS_ADD_IFELSE(-Wno-unused-const-variable)
+ # Add each of the following flags only if the C/C++ compiler accepts it.
+ SVN_CFLAGS_ADD_IFELSE(
+ -Wextra-tokens
+ -Wnewline-eof
+ -Wshorten-64-to-32
+ -Wno-system-headers
+ -Wno-format-nonliteral
+ -Wmissing-variable-declarations
+ -Wno-unused-const-variable
+ -Werror=implicit-function-declaration
+ -Werror=declaration-after-statement
+ -Wold-style-definition
+ )
+ SVN_CXXFLAGS_ADD_IFELSE(
+ -Wextra-tokens
+ -Wnewline-eof
+ -Wshorten-64-to-32
+ -Wno-system-headers
+ )
endif()
# Setup modules path