[mlir] Do not use an empty source file when building aggregate libraries.

See discussion: https://discourse.llvm.org/t/check-mlir-times-examples-standalone-testing-time/6073/7

It turns out that it has been legal since CMake 3.11 to omit sources at library creation time if they are added later via target_sources, as is done here. This side-steps the issue of having a file that changes and invalidates the build of leaves.

Differential Revision: https://reviews.llvm.org/D119069
This commit is contained in:
Stella Laurenzo 2022-02-05 22:04:19 -08:00
parent 52d981a4c1
commit b4626f22de

View file

@ -321,18 +321,11 @@ function(add_mlir_aggregate name)
" DEPS = ${_local_deps}\n\n")
endforeach()
# Unfortunately need to compile at least one source file, which is hard
# to guarantee, so just always generate one. We generate one vs using the
# LLVM common dummy.cpp because it works better out of tree.
set(_empty_src "${CMAKE_CURRENT_BINARY_DIR}/${name}__empty.cpp")
file(WRITE "${_empty_src}" "typedef int dummy;")
add_mlir_library(${name}
${_libtype}
${ARG_UNPARSED_ARGUMENTS}
PARTIAL_SOURCES_INTENDED
EXCLUDE_FROM_LIBMLIR
"${_empty_src}"
LINK_LIBS PRIVATE
${_deps}
${ARG_PUBLIC_LIBS}