File: CMakeLists.txt

package info (click to toggle)
llvm-toolchain-17 1%3A17.0.6-22
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,799,624 kB
  • sloc: cpp: 6,428,607; ansic: 1,383,196; asm: 793,408; python: 223,504; objc: 75,364; f90: 60,502; lisp: 33,869; pascal: 15,282; sh: 9,684; perl: 7,453; ml: 4,937; awk: 3,523; makefile: 2,889; javascript: 2,149; xml: 888; fortran: 619; cs: 573
file content (76 lines) | stat: -rw-r--r-- 3,190 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# This library is shared by both MLIRSparseTensorDialect and
# MLIRSparseTensorRuntime, so it must not depend on any of the MLIR/LLVM
# internals or else mlir_c_runner_utils will inherit that dependency.
#
# Because this is a header-only (`INTERFACE`) library, we cannot use
# the `add_mlir_library` function.  So we do our best to replicate the
# relevant portions below.  If doing so becomes too complicated, then
# we should adjust the `add_mlir_library` function to also work for
# `INTERFACE` libraries.
set(MLIRSparseTensorEnums_hdrs
    mlir/Dialect/SparseTensor/IR/Enums.h)
# This conditional is copypasta from `add_mlir_library`.
if(MSVC_IDE OR XCODE)
  foreach(hdr ${MLIRSparseTensorEnums_hdrs})
    set_source_files_properties(${MLIR_MAIN_INCLUDE_DIR}/${hdr}
      PROPERTIES HEADER_FILE_ONLY ON)
  endforeach()
endif()
# Older versions of cmake (< 3.19) require INTERFACE libraries to separate
# the `add_library` and `target_sources` calls.
add_library(MLIRSparseTensorEnums INTERFACE)
# If we call target_sources naively, then the library won't be
# installed properly (i.e., so that it can be used by projects outside
# the llvm-project repo).  To correct this, we must use BUILD_INTERFACE /
# INSTALL_INTERFACE generator expressions to avoid paths being interpreted
# as absolute; for more details, see <https://stackoverflow.com/a/62465051>.
# Unfortunately BUILD_INTERFACE and INSTALL_INTERFACE require their file
# paths to be relative to different things, hence why we use a foreach loop
# to iterate over the sources (in case we ever need to have more than one).
foreach(hdr ${MLIRSparseTensorEnums_hdrs})
  target_sources(MLIRSparseTensorEnums INTERFACE
    $<BUILD_INTERFACE:${MLIR_MAIN_INCLUDE_DIR}/${hdr}>
    $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${hdr}>)
endforeach()
# 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
  SparseTensorDialect.cpp
  Detail/Var.cpp
  Detail/DimLvlMap.cpp
  Detail/LvlTypeParser.cpp
  Detail/DimLvlMapParser.cpp

  ADDITIONAL_HEADER_DIRS
  ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/SparseTensor

  DEPENDS
  MLIRSparseTensorAttrDefsIncGen
  MLIRSparseTensorOpsIncGen
  MLIRSparseTensorTypesIncGen

  LINK_LIBS PUBLIC
  MLIRArithDialect
  MLIRDialect
  MLIRDialectUtils
  MLIRIR
  MLIRInferTypeOpInterface
  MLIRSupport
  MLIRSparseTensorEnums
  )