]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: do not pass PRE_BUILD to add_custom_command(OUTPUT) 62565/head
authorKefu Chai <tchaikov@gmail.com>
Sun, 30 Mar 2025 02:10:28 +0000 (10:10 +0800)
committerKefu Chai <tchaikov@gmail.com>
Sun, 30 Mar 2025 02:19:54 +0000 (10:19 +0800)
Removes the invalid PRE_BUILD argument from add_custom_command(OUTPUT)
calls that was triggering CMake warnings. The PRE_BUILD option is only
valid for target-based custom commands and specifically with Visual
Studio generators.

Additionally sets the CMP0175 policy to NEW to ensure CMake fails on
invalid arguments to add_custom_command(), helping catch similar issues
earlier in the development process.

This change:

- Removes unnecessary PRE_BUILD argument from OUTPUT-based custom commands
- Sets CMP0175 policy to enforce validation of add_custom_command() arguments
- Resolves CMake warning in src/common/options/CMakeLists.txt

Reference:
https://cmake.org/cmake/help/latest/command/add_custom_command.html#build-events

The CMake warning looks like:

```
CMake Warning (dev) at src/common/options/CMakeLists.txt:34 (add_custom_command):
  The following keywords are not supported when using
  add_custom_command(OUTPUT): PRE_BUILD.

  Policy CMP0175 is not set: add_custom_command() rejects invalid arguments.
  Run "cmake --help-policy CMP0175" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.
Call Stack (most recent call first):
  src/common/options/CMakeLists.txt:85 (add_options)
This warning is for project developers.  Use -Wno-dev to suppress it.
```

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
CMakeLists.txt
src/common/options/CMakeLists.txt

index 9f84f4e7b2523cf6ba4d2c7b252ba87c552a17c8..4e30d65e31d2d0a9ca2c8a08212c8eee67b13fcd 100644 (file)
@@ -4,7 +4,7 @@ project(ceph
   VERSION 20.0.0
   LANGUAGES CXX C ASM)
 
-foreach(policy CMP0127 CMP0135)
+foreach(policy CMP0127 CMP0135 CMP0175)
   if(POLICY ${policy})
     cmake_policy(SET ${policy} NEW)
   endif()
index fcec49e549ad277fc26546a5a75f5dba1ecd0bca..60cdbc3f224b8bc2795c73ed1e621f4df17dd0e8 100644 (file)
@@ -31,7 +31,7 @@ function(add_options name)
   set(options_yamls ${options_yamls} PARENT_SCOPE)
   set(cc_file "${name}_options.cc")
   set(h_file "${PROJECT_BINARY_DIR}/include/${name}_legacy_options.h")
-  add_custom_command(PRE_BUILD
+  add_custom_command(
     OUTPUT ${cc_file} ${h_file}
     COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/y2c.py
       --input ${yaml_file}