[Mlir-commits] [mlir] 5e12c18 - [mlir][sparse] Fix breakage on older versions of cmake

wren romano llvmlistbot at llvm.org
Wed Oct 19 13:56:02 PDT 2022


Author: wren romano
Date: 2022-10-19T13:55:54-07:00
New Revision: 5e12c183920b506f83b2a10205b4a26b17ca9115

URL: https://github.com/llvm/llvm-project/commit/5e12c183920b506f83b2a10205b4a26b17ca9115
DIFF: https://github.com/llvm/llvm-project/commit/5e12c183920b506f83b2a10205b4a26b17ca9115.diff

LOG: [mlir][sparse] Fix breakage on older versions of cmake

Per https://reviews.llvm.org/D136005#3866692 the introduction of the MLIRSparseTensorEnums target in D136002 caused breakage on some versions of cmake.  This differential aims to fix those errors.

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D136217

Added: 
    

Modified: 
    mlir/lib/Dialect/SparseTensor/IR/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/SparseTensor/IR/CMakeLists.txt b/mlir/lib/Dialect/SparseTensor/IR/CMakeLists.txt
index 14511f5626d60..019b5d046756b 100644
--- a/mlir/lib/Dialect/SparseTensor/IR/CMakeLists.txt
+++ b/mlir/lib/Dialect/SparseTensor/IR/CMakeLists.txt
@@ -9,13 +9,31 @@
 # `INTERFACE` libraries.
 set(MLIRSparseTensorEnums_srcs
     ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/SparseTensor/IR/Enums.h)
-add_library(MLIRSparseTensorEnums INTERFACE ${MLIRSparseTensorEnums_srcs})
+# This conditional is copypasta from `add_mlir_library`.
 if(MSVC_IDE OR XCODE)
   set_source_files_properties(${MLIRSparseTensorEnums_srcs}
     PROPERTIES HEADER_FILE_ONLY ON)
 endif()
-add_mlir_library_install(MLIRSparseTensorEnums)
-set_property(TARGET MLIRSparseTensorEnums PROPERTY CXX_STANDARD 17)
+# Older versions of cmake (< 3.19) require INTERFACE libraries to separate
+# the `add_library` and `target_sources` calls.
+add_library(MLIRSparseTensorEnums INTERFACE)
+target_sources(MLIRSparseTensorEnums INTERFACE ${MLIRSparseTensorEnums_srcs})
+# The `add_mlir_library_install` is required for other libraries to
+# depend on this one, but the conditional itself and the phony target
+# are copypasta from `add_mlir_library`.  Afaict (wrengr), the version
+# in `add_mlir_library` is to prevent `add_mlir_library_install` from
+# raising additional errors whenever the underlying call to `add_llvm_library`
+# fails.  However, since we are using `add_library` directly, I'm not
+# sure if the conditional is helpful/required here or not.
+if(TARGET MLIRSparseTensorEnums)
+  add_mlir_library_install(MLIRSparseTensorEnums)
+else()
+  # Add empty "phony" target
+  add_custom_target(MLIRSparseTensorEnums)
+endif()
+# Older versions of cmake (i.e., 3.18.0 but not 3.24.2) disallow setting
+# the CXX_STANDARD property for INTERFACE libraries.  However, this library
+# must adhere to the same CXX_STANDARD restriction as mlir_c_runner_utils.
 
 
 add_mlir_dialect_library(MLIRSparseTensorDialect


        


More information about the Mlir-commits mailing list