[PATCH] D72418: [Flang] add some cmake code to allow for out-of-tree building of MLIR and LLVM
Eric Schweitz via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 16 12:28:04 PST 2020
schweitz updated this revision to Diff 238573.
schweitz marked an inline comment as done.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D72418/new/
https://reviews.llvm.org/D72418
Files:
mlir/CMakeLists.txt
mlir/cmake/modules/AddMLIR.cmake
mlir/cmake/modules/CMakeLists.txt
Index: mlir/cmake/modules/CMakeLists.txt
===================================================================
--- mlir/cmake/modules/CMakeLists.txt
+++ mlir/cmake/modules/CMakeLists.txt
@@ -40,15 +40,13 @@
set(MLIR_CONFIG_INCLUDE_DIRS
"\${MLIR_INSTALL_PREFIX}/include"
)
-#configure_file(
-# ${CMAKE_CURRENT_SOURCE_DIR}/MlirConfig.cmake.in
-# ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/MlirConfig.cmake
-# @ONLY)
set(MLIR_CONFIG_CODE)
set(MLIR_CONFIG_CMAKE_DIR)
set(MLIR_CONFIG_EXPORTS_FILE)
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
+ # Not TOOLCHAIN ONLY, so install the MLIR parts as well
+ # Include the cmake files so other tools can use mlir-tblgen, etc.
get_property(mlir_has_exports GLOBAL PROPERTY MLIR_HAS_EXPORTS)
if(mlir_has_exports)
install(EXPORT MlirTargets DESTINATION ${MLIR_INSTALL_PACKAGE_DIR}
Index: mlir/cmake/modules/AddMLIR.cmake
===================================================================
--- mlir/cmake/modules/AddMLIR.cmake
+++ mlir/cmake/modules/AddMLIR.cmake
@@ -4,6 +4,8 @@
PARENT_SCOPE)
endfunction()
+# TODO: This is to handle the current static registration, but should be
+# factored out a bit.
function(whole_archive_link target)
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
set(link_flags "-L${CMAKE_BINARY_DIR}/lib ")
Index: mlir/CMakeLists.txt
===================================================================
--- mlir/CMakeLists.txt
+++ mlir/CMakeLists.txt
@@ -8,12 +8,6 @@
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
-function(mlir_tablegen ofn)
- tablegen(MLIR ${ARGV} "-I${MLIR_MAIN_SRC_DIR}" "-I${MLIR_INCLUDE_DIR}")
- set(TABLEGEN_OUTPUT ${TABLEGEN_OUTPUT} ${CMAKE_CURRENT_BINARY_DIR}/${ofn}
- PARENT_SCOPE)
-endfunction()
-
function(add_mlir_dialect dialect dialect_doc_filename)
set(LLVM_TARGET_DEFINITIONS ${dialect}.td)
mlir_tablegen(${dialect}.h.inc -gen-op-decls)
@@ -35,34 +29,14 @@
add_dependencies(mlir-doc ${dialect_doc_filename}DocGen)
endfunction()
+include(AddMLIR)
+
# Installing the headers and docs needs to depend on generating any public
# tablegen'd targets.
add_custom_target(mlir-headers)
set_target_properties(mlir-headers PROPERTIES FOLDER "Misc")
add_custom_target(mlir-doc)
-# TODO: This is to handle the current static registration, but should be
-# factored out a bit.
-function(whole_archive_link target)
- if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
- set(link_flags "-L${CMAKE_BINARY_DIR}/lib ")
- FOREACH(LIB ${ARGN})
- string(CONCAT link_flags ${link_flags} "-Wl,-force_load ${CMAKE_BINARY_DIR}/lib/lib${LIB}.a ")
- ENDFOREACH(LIB)
- elseif(MSVC)
- FOREACH(LIB ${ARGN})
- string(CONCAT link_flags ${link_flags} "/WHOLEARCHIVE:${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib/${LIB}.lib ")
- ENDFOREACH(LIB)
- else()
- set(link_flags "-L${CMAKE_BINARY_DIR}/lib -Wl,--whole-archive,")
- FOREACH(LIB ${ARGN})
- string(CONCAT link_flags ${link_flags} "-l${LIB},")
- ENDFOREACH(LIB)
- string(CONCAT link_flags ${link_flags} "--no-whole-archive")
- endif()
- set_target_properties(${target} PROPERTIES LINK_FLAGS ${link_flags})
-endfunction(whole_archive_link)
-
# Build the CUDA conversions and run according tests if the NVPTX backend
# is available
if ("NVPTX" IN_LIST LLVM_TARGETS_TO_BUILD)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72418.238573.patch
Type: text/x-patch
Size: 3321 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200116/5534d4c9/attachment.bin>
More information about the llvm-commits
mailing list