Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove special casing for IreeFileCheck in iree_lit_test.cmake #5209

Merged
merged 1 commit into from
Mar 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions build_tools/cmake/iree_lit_test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,7 @@ function(iree_lit_test)
set(_DATA_DEP_PATHS)
foreach(_DATA_DEP ${_RULE_DATA})
string(REPLACE "::" "_" _DATA_DEP_NAME ${_DATA_DEP})
Comment on lines 62 to 64
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests aren't targets in CMake :-/

Cannot add target-level dependencies to non-existent target
"iree/samples/custom_modules/dialect/test/custom_ops.mlir.test".

# TODO(*): iree_sh_binary so we can avoid this.
if("${_DATA_DEP_NAME}" STREQUAL "iree_tools_IreeFileCheck")
list(APPEND _DATA_DEP_PATHS "${PROJECT_BINARY_DIR}/iree/tools/IreeFileCheck")
else()
list(APPEND _DATA_DEP_PATHS $<TARGET_FILE:${_DATA_DEP_NAME}>)
endif()
list(APPEND _DATA_DEP_PATHS $<TARGET_FILE:${_DATA_DEP_NAME}>)
endforeach(_DATA_DEP)

iree_package_ns(_PACKAGE_NS)
Expand Down
36 changes: 34 additions & 2 deletions iree/tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,41 @@ if(${IREE_BUILD_COMPILER})
HOSTONLY
)

add_custom_target(IreeFileCheck ALL
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/IreeFileCheck.sh IreeFileCheck
# IreeFileCheck
# We could encapsulate this in iree_sh_binary, but we only have one use of it
# in the project and this file is already not covered by Bazel->CMake

# Symlink the shell script into the build tree as the expected executable name
add_custom_command(
OUTPUT
IreeFileCheck
COMMAND
${CMAKE_COMMAND} -E create_symlink
${CMAKE_CURRENT_SOURCE_DIR}/IreeFileCheck.sh
IreeFileCheck
)

# CMake always needs to custom targets to drive custom commands. We have to
# give it a different name.
add_custom_target(_IreeFileCheck_Driver ALL DEPENDS IreeFileCheck)

# But custom target doesn't have the TARGET_FILE property, which we need, so
# wrap it yet again in an executable. This is marke as an imported executable
# because otherwise CMake would try to compile it as C++. The executable
# target has to have a different name than the output file of the custom
# command... (https://gitlab.kitware.com/cmake/cmake/-/issues/18627).
add_executable(IreeFileCheck_exe IMPORTED GLOBAL)
set_property(
TARGET
IreeFileCheck_exe
PROPERTY IMPORTED_LOCATION
"${CMAKE_CURRENT_BINARY_DIR}/IreeFileCheck"
)
add_dependencies(IreeFileCheck_exe _IreeFileCheck_Driver)
# Finally do our normal aliasing trick to make this accessible as a qualified
# target name throughout the project.
add_executable(iree_tools_IreeFileCheck ALIAS IreeFileCheck_exe)

if(${IREE_MLIR_DEP_MODE} STREQUAL "BUNDLED")
add_custom_target(BundledLLVMFileCheck ALL
COMMAND ${CMAKE_COMMAND} -E create_symlink $<TARGET_FILE:FileCheck> FileCheck
Expand Down