svn commit: r1936654 - subversion/trunk

[email protected] Tue, 28 Jul 2026 02:55:18 -0000
Newsgroups gmane.comp.version-control.subversion.svn
Message-ID <178520731825.3337099.1327174445457664686@svn03-he-fi>
Author: jun66j5
Date: Tue Jul 28 02:55:18 2026
New Revision: 1936654

Log:
cmake: Do not add options for GCC to G++.

* CMakeLists.txt
  (MSVC flags):
    Instead of calling `add_compile_options()` multiple times, call it once
    with multiple flags specified.

  (GCC/G++ flags):
    Call `add_compiler_options()` with `$<$<COMPILE_LANGUAGE:{lang}>:{flag}>`
    to prevent options for GCC from being added to G++.

Modified:
   subversion/trunk/CMakeLists.txt

Modified: subversion/trunk/CMakeLists.txt
==============================================================================
--- subversion/trunk/CMakeLists.txt	Tue Jul 28 02:41:23 2026	(r1936653)
+++ subversion/trunk/CMakeLists.txt	Tue Jul 28 02:55:18 2026	(r1936654)
@@ -336,38 +336,38 @@ if(SVN_ENABLE_JAVAHL)
 endif()
 
 if (MSVC)
-  # Setup warning level
-  add_compile_options(/W4)
-
-  # Disable warning
-  add_compile_options(/wd4100)
-  add_compile_options(/wd4127)
-  add_compile_options(/wd4206)
-  add_compile_options(/wd4512)
-  add_compile_options(/wd4701)
-  add_compile_options(/wd4706)
-  add_compile_options(/wd4800)
-
-  # Treat some criticial warnings as error
-  add_compile_options(/we4002)
-  add_compile_options(/we4003)
-  add_compile_options(/we4013)
-  add_compile_options(/we4020)
-  add_compile_options(/we4022)
-  add_compile_options(/we4024)
-  add_compile_options(/we4028)
-  add_compile_options(/we4029)
-  add_compile_options(/we4030)
-  add_compile_options(/we4031)
-  add_compile_options(/we4033)
-  add_compile_options(/we4047)
-  add_compile_options(/we4089)
-  add_compile_options(/we4113)
-  add_compile_options(/we4133)
-  add_compile_options(/we4204)
-  add_compile_options(/we4700)
-  add_compile_options(/we4715)
-  add_compile_options(/we4789)
+  add_compile_options(
+    # Setup warning level
+    /W4
+    # Disable warnings
+    /wd4100
+    /wd4127
+    /wd4206
+    /wd4512
+    /wd4701
+    /wd4706
+    /wd4800
+    # Treat some criticial warnings as error
+    /we4002
+    /we4003
+    /we4013
+    /we4020
+    /we4022
+    /we4024
+    /we4028
+    /we4029
+    /we4030
+    /we4031
+    /we4033
+    /we4047
+    /we4089
+    /we4113
+    /we4133
+    /we4204
+    /we4700
+    /we4715
+    /we4789
+  )
 
   add_compile_definitions(
     "_CRT_SECURE_NO_DEPRECATE"
@@ -388,21 +388,29 @@ else()
     endif()
   endfunction()
 
-  # Add flags that all versions of GCC (should) support
-  add_compile_options(-Wpointer-arith)
-  add_compile_options(-Wwrite-strings)
-  add_compile_options(-Wshadow)
-  add_compile_options(-Wformat=2)
-  add_compile_options(-Wunused)
-  add_compile_options(-Wstrict-prototypes)
-  add_compile_options(-Wmissing-prototypes)
-  add_compile_options(-Wmissing-declarations)
-  add_compile_options(-Wno-multichar)
-  add_compile_options(-Wredundant-decls)
-  add_compile_options(-Wnested-externs)
-  add_compile_options(-Winline)
-  add_compile_options(-Wno-long-long)
-  add_compile_options(-Wbad-function-cast)
+  # Add flags that all versions of GCC/G++ (should) support
+  add_compile_options(
+    -Wpointer-arith
+    -Wwrite-strings
+    -Wshadow
+    -Wformat=2
+    -Wunused
+    -Wmissing-declarations
+    -Wno-multichar
+    -Wredundant-decls
+    -Winline
+    -Wno-long-long
+    $<$<COMPILE_LANGUAGE:C>:-Wstrict-prototypes>
+    $<$<COMPILE_LANGUAGE:C>:-Wmissing-prototypes>
+    $<$<COMPILE_LANGUAGE:C>:-Wnested-externs>
+    $<$<COMPILE_LANGUAGE:C>:-Wbad-function-cast>
+    $<$<COMPILE_LANGUAGE:CXX>:-Wall>
+    $<$<COMPILE_LANGUAGE:CXX>:-Wpointer-arith>
+    $<$<COMPILE_LANGUAGE:CXX>:-Wwrite-strings>
+    $<$<COMPILE_LANGUAGE:CXX>:-Wshadow>
+    $<$<COMPILE_LANGUAGE:CXX>:-Wunused>
+    $<$<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)