Skip to content

Commit b0dce6b

Browse files
Revert "[RFC] Factor out repetitive cmake patterns for llvm-style projects"
This reverts commit e9b87f4. There are issues with macros generating macros without an obvious simple fix so I'm going to revert this and try something different.
1 parent 37010d4 commit b0dce6b

File tree

17 files changed

+28
-221
lines changed

17 files changed

+28
-221
lines changed

llvm/cmake/modules/LLVMProjectOptions.cmake

Lines changed: 0 additions & 68 deletions
This file was deleted.

llvm/cmake/modules/LLVMProjectTargets.cmake

Lines changed: 0 additions & 109 deletions
This file was deleted.

mlir/CMakeLists.txt

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ set_target_properties(mlir-headers PROPERTIES FOLDER "Misc")
2121
add_dependencies(mlir-headers mlir-generic-headers)
2222
add_custom_target(mlir-doc)
2323

24-
# Get a bunch of LLVM-style default options.
25-
include(LLVMProjectOptions)
26-
add_llvm_project_options(mlir)
27-
2824
# Build the CUDA conversions and run according tests if the NVPTX backend
2925
# is available
3026
if ("NVPTX" IN_LIST LLVM_TARGETS_TO_BUILD)
@@ -48,6 +44,13 @@ set(MLIR_CUDA_RUNNER_ENABLED 0 CACHE BOOL "Enable building the mlir CUDA runner"
4844
set(MLIR_ROCM_RUNNER_ENABLED 0 CACHE BOOL "Enable building the mlir ROCm runner")
4945
set(MLIR_VULKAN_RUNNER_ENABLED 0 CACHE BOOL "Enable building the mlir Vulkan runner")
5046

47+
option(MLIR_INCLUDE_TESTS
48+
"Generate build targets for the MLIR unit tests."
49+
${LLVM_INCLUDE_TESTS})
50+
51+
option(MLIR_INCLUDE_INTEGRATION_TESTS
52+
"Generate build targets for the MLIR integration tests.")
53+
5154
#-------------------------------------------------------------------------------
5255
# Python Bindings Configuration
5356
# Requires:
@@ -80,46 +83,42 @@ if(MLIR_BINDINGS_PYTHON_ENABLED)
8083
"extension = '${PYTHON_MODULE_EXTENSION}")
8184
endif()
8285

83-
# Get a bunch of default targets
84-
include(LLVMProjectTargets)
85-
add_llvm_project_targets(mlir)
86-
8786
include_directories( "include")
8887
include_directories( ${MLIR_INCLUDE_DIR})
8988

9089
# Adding tools/mlir-tblgen here as calling add_tablegen sets some variables like
9190
# MLIR_TABLEGEN_EXE in PARENT_SCOPE which gets lost if that folder is included
9291
# from another directory like tools
93-
if (MLIR_INCLUDE_TOOLS)
94-
add_subdirectory(tools/mlir-tblgen)
95-
endif()
92+
add_subdirectory(tools/mlir-tblgen)
9693

9794
add_subdirectory(include/mlir)
9895
add_subdirectory(lib)
9996
# C API needs all dialects for registration, but should be built before tests.
10097
add_subdirectory(lib/CAPI)
10198
if (MLIR_INCLUDE_TESTS)
99+
add_definitions(-DMLIR_INCLUDE_TESTS)
102100
add_subdirectory(unittests)
103101
add_subdirectory(test)
104102
endif()
105103
if (MLIR_INCLUDE_INTEGRATION_TESTS)
104+
add_definitions(-DMLIR_INCLUDE_INTEGRATION_TESTS)
106105
add_subdirectory(integration_test)
107106
endif()
108107
# Tools needs to come late to ensure that MLIR_ALL_LIBS is populated.
109108
# Generally things after this point may depend on MLIR_ALL_LIBS or libMLIR.so.
110-
if (MLIR_INCLUDE_TOOLS)
111-
add_subdirectory(tools)
112-
endif()
109+
add_subdirectory(tools)
113110

114-
if (MLIR_INCLUDE_EXAMPLES)
111+
if( LLVM_INCLUDE_EXAMPLES )
115112
add_subdirectory(examples)
116113
endif()
117114

115+
option(MLIR_INCLUDE_DOCS "Generate build targets for the MLIR docs."
116+
${LLVM_INCLUDE_DOCS})
118117
if (MLIR_INCLUDE_DOCS)
119118
add_subdirectory(docs)
120119
endif()
121120

122-
if (NOT MLIR_INSTALL_TOOLCHAIN_ONLY)
121+
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
123122
install(DIRECTORY include/mlir include/mlir-c
124123
DESTINATION include
125124
COMPONENT mlir-headers

mlir/cmake/modules/AddMLIR.cmake

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,7 @@ function(add_mlir_interface interface)
2424
endfunction()
2525

2626

27-
# Generate Documentation using the mlir-doc rule
28-
# doc_filename: the basename of a .td tablegen file
29-
# command: the tablegen command to run, typically "-gen-op-doc",
30-
# "-gen-pass-doc", or "-gen-dialect-doc"
31-
# output_file: the basename of a .md markdown file to be output
32-
# output_directory: the directory to place the output
27+
# Generate Documentation
3328
function(add_mlir_doc doc_filename command output_file output_directory)
3429
set(LLVM_TARGET_DEFINITIONS ${doc_filename}.td)
3530
tablegen(MLIR ${output_file}.md ${command} "-I${MLIR_MAIN_INCLUDE_DIR}" "-I${MLIR_INCLUDE_DIR}")
@@ -45,7 +40,7 @@ function(add_mlir_doc doc_filename command output_file output_directory)
4540
endfunction()
4641

4742
# Declare an mlir library which can be compiled in libMLIR.so
48-
# In addition to everything that llvm_add_library accepts, this
43+
# In addition to everything that llvm_add_librar accepts, this
4944
# also has the following option:
5045
# EXCLUDE_FROM_LIBMLIR
5146
# Don't include this library in libMLIR.so. This option should be used

mlir/examples/standalone/CMakeLists.txt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,8 @@ list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
3131
include(TableGen)
3232
include(AddLLVM)
3333
include(AddMLIR)
34-
35-
# Get a bunch of LLVM-style default options.
36-
include(LLVMProjectOptions)
37-
add_llvm_project_options(standalone)
38-
3934
include(HandleLLVMOptions)
4035

41-
# Get a bunch of default targets
42-
include(LLVMProjectTargets)
43-
add_llvm_project_targets(standalone)
44-
4536
include_directories(${LLVM_INCLUDE_DIRS})
4637
include_directories(${MLIR_INCLUDE_DIRS})
4738
include_directories(${PROJECT_SOURCE_DIR}/include)

mlir/examples/standalone/standalone-opt/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set(LIBS
66
MLIROptLib
77
MLIRStandalone
88
)
9-
add_standalone_tool(standalone-opt standalone-opt.cpp)
9+
add_llvm_executable(standalone-opt standalone-opt.cpp)
1010

1111
llvm_update_compile_flags(standalone-opt)
1212
target_link_libraries(standalone-opt PRIVATE ${LIBS})

mlir/examples/standalone/standalone-translate/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set(LLVM_LINK_COMPONENTS
55
get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
66
get_property(translation_libs GLOBAL PROPERTY MLIR_TRANSLATION_LIBS)
77

8-
add_standalone_tool(standalone-translate
8+
add_llvm_executable(standalone-translate
99
standalone-translate.cpp
1010
)
1111
llvm_update_compile_flags(standalone-translate)

mlir/examples/toy/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ set_target_properties(Toy PROPERTIES FOLDER Examples)
33

44
macro(add_toy_chapter name)
55
add_dependencies(Toy ${name})
6-
add_mlir_example(${name} ${ARGN})
6+
add_llvm_example(${name} ${ARGN})
77
endmacro(add_toy_chapter name)
88

99
add_subdirectory(Ch1)
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# RUN: %cmake %mlir_src_root/examples/standalone -DCMAKE_CXX_COMPILER=%host_cxx -DCMAKE_C_COMPILER=%host_cc -DMLIR_DIR=%llvm_lib_dir/cmake/mlir ; %cmake --build . --target check-standalone | tee %t | FileCheck %s
2-
# RUN: %cmake --build . --target mlir-doc
32

43
# CHECK: Passed: 3
54
# UNSUPPORTED: windows, android

mlir/tools/mlir-cpu-runner/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set(LLVM_LINK_COMPONENTS
44
nativecodegen
55
)
66

7-
add_mlir_tool(mlir-cpu-runner
7+
add_llvm_tool(mlir-cpu-runner
88
mlir-cpu-runner.cpp
99
)
1010
llvm_update_compile_flags(mlir-cpu-runner)

mlir/tools/mlir-cuda-runner/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ if(MLIR_CUDA_RUNNER_ENABLED)
6868
LIST(APPEND targets_to_link "LLVM${t}")
6969
ENDFOREACH(t)
7070

71-
add_mlir_tool(mlir-cuda-runner
71+
add_llvm_tool(mlir-cuda-runner
7272
mlir-cuda-runner.cpp
7373

7474
DEPENDS

mlir/tools/mlir-linalg-ods-gen/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ set(LLVM_LINK_COMPONENTS
22
Core
33
Support
44
)
5-
add_mlir_tool(mlir-linalg-ods-gen
5+
add_llvm_tool(mlir-linalg-ods-gen
66
mlir-linalg-ods-gen.cpp
77
)
88
llvm_update_compile_flags(mlir-linalg-ods-gen)

mlir/tools/mlir-opt/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ add_mlir_library(MLIRMlirOptMain
5050
${LIBS}
5151
)
5252

53-
add_mlir_tool(mlir-opt
53+
add_llvm_tool(mlir-opt
5454
mlir-opt.cpp
5555

5656
DEPENDS

mlir/tools/mlir-reduce/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ set(LIBS
4343
MLIRTransformUtils
4444
)
4545

46-
add_mlir_tool(mlir-reduce
46+
add_llvm_tool(mlir-reduce
4747
OptReductionPass.cpp
4848
Passes/OpReducer.cpp
4949
ReductionNode.cpp

mlir/tools/mlir-rocm-runner/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ if(MLIR_ROCM_RUNNER_ENABLED)
104104
LIST(APPEND targets_to_link "LLVM${t}")
105105
ENDFOREACH(t)
106106

107-
add_mlir_tool(mlir-rocm-runner
107+
add_llvm_tool(mlir-rocm-runner
108108
mlir-rocm-runner.cpp
109109

110110
DEPENDS

mlir/tools/mlir-translate/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set(LLVM_LINK_COMPONENTS
55
get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
66
get_property(translation_libs GLOBAL PROPERTY MLIR_TRANSLATION_LIBS)
77

8-
add_mlir_tool(mlir-translate
8+
add_llvm_tool(mlir-translate
99
mlir-translate.cpp
1010
)
1111
llvm_update_compile_flags(mlir-translate)

0 commit comments

Comments
 (0)