Skip to content

Commit

Permalink
Remove special casing for IreeFileCheck in iree_lit_test.cmake (#5209)
Browse files Browse the repository at this point in the history
  • Loading branch information
GMNGeoffrey authored Mar 23, 2021
1 parent b67af5a commit b7e2b09
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 8 deletions.
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})
# 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

0 comments on commit b7e2b09

Please sign in to comment.