Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mlir][python][cmake] Remove unsupported argument from AddMLIRPython. #123858

Merged
merged 1 commit into from
Jan 22, 2025

Conversation

ScottTodd
Copy link
Member

See https://cmake.org/cmake/help/latest/policy/CMP0175.html

The OUTPUT form does not accept PRE_BUILD, PRE_LINK, or POST_BUILD keywords.

When using CMake version 3.31+, this results in ~2000 lines of warning spam in my downstream project:

CMake Warning (dev) at build-gcc/lib/cmake/mlir/AddMLIRPython.cmake:606 (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):
  build-gcc/lib/cmake/mlir/AddMLIRPython.cmake:222 (add_mlir_python_sources_target)
  build-gcc/lib/cmake/mlir/AddMLIRPython.cmake:256 (_process_target)
  compiler/bindings/python/CMakeLists.txt:239 (add_mlir_python_modules)
This warning is for project developers.  Use -Wno-dev to suppress it.

General docs: https://cmake.org/cmake/help/latest/command/add_custom_command.html. Note that PRE_BUILD only appears in the second signature for the function (which takes TARGET) not the first (which takes OUTPUT).

@llvmbot
Copy link
Member

llvmbot commented Jan 22, 2025

@llvm/pr-subscribers-mlir

Author: Scott Todd (ScottTodd)

Changes

See https://cmake.org/cmake/help/latest/policy/CMP0175.html

> The OUTPUT form does not accept PRE_BUILD, PRE_LINK, or POST_BUILD keywords.

When using CMake version 3.31+, this results in ~2000 lines of warning spam in my downstream project:

CMake Warning (dev) at build-gcc/lib/cmake/mlir/AddMLIRPython.cmake:606 (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):
  build-gcc/lib/cmake/mlir/AddMLIRPython.cmake:222 (add_mlir_python_sources_target)
  build-gcc/lib/cmake/mlir/AddMLIRPython.cmake:256 (_process_target)
  compiler/bindings/python/CMakeLists.txt:239 (add_mlir_python_modules)
This warning is for project developers.  Use -Wno-dev to suppress it.

General docs: https://cmake.org/cmake/help/latest/command/add_custom_command.html. Note that PRE_BUILD only appears in the second signature for the function (which takes TARGET) not the first (which takes OUTPUT).


Full diff: /~https://github.com/llvm/llvm-project/pull/123858.diff

1 Files Affected:

  • (modified) mlir/cmake/modules/AddMLIRPython.cmake (+1-2)
diff --git a/mlir/cmake/modules/AddMLIRPython.cmake b/mlir/cmake/modules/AddMLIRPython.cmake
index 815f65b106d945..3f5f2a35f8fb2e 100644
--- a/mlir/cmake/modules/AddMLIRPython.cmake
+++ b/mlir/cmake/modules/AddMLIRPython.cmake
@@ -605,7 +605,6 @@ function(add_mlir_python_sources_target name)
 
       add_custom_command(
         OUTPUT "${_dest_path}"
-        PRE_BUILD
         COMMENT "Copying python source ${_src_path} -> ${_dest_path}"
         DEPENDS "${_src_path}"
         COMMAND "${CMAKE_COMMAND}" -E ${_link_or_copy}
@@ -702,7 +701,7 @@ function(add_mlir_python_extension libname extname)
           ${eh_rtti_enable}
       )
     endif()
-    
+
     if(APPLE)
       # NanobindAdaptors.h uses PyClassMethod_New to build `pure_subclass`es but nanobind
       # doesn't declare this API as undefined in its linker flags. So we need to declare it as such

Copy link
Contributor

@makslevental makslevental left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks this one's been bugging me for a while.

Copy link
Contributor

@dukebw dukebw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you!

@ScottTodd ScottTodd merged commit 582fe3e into llvm:main Jan 22, 2025
10 checks passed
@ScottTodd ScottTodd deleted the cmake-3.31-fixes-python branch January 22, 2025 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants