Address Geoffrey's comments
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 75f1b5c..bf77c9a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -330,7 +330,7 @@
# Set the FLATBUFFERS_FLATC_EXECUTABLE. It controls where to find the flatc
# binary in BuildFlatBuffers().
- iree_get_executable_path(flatc FLATBUFFERS_FLATC_EXECUTABLE)
+ iree_get_executable_path(FLATBUFFERS_FLATC_EXECUTABLE flatc)
# Add a custom target to copy the flatc to the binary directory.
add_custom_target(iree_host_flatc
diff --git a/build_tools/cmake/flatbuffer_cc_library.cmake b/build_tools/cmake/flatbuffer_cc_library.cmake
index 7236d01..febf234 100644
--- a/build_tools/cmake/flatbuffer_cc_library.cmake
+++ b/build_tools/cmake/flatbuffer_cc_library.cmake
@@ -95,11 +95,13 @@
set(FLATBUFFERS_FLATC_SCHEMA_EXTRA_ARGS ${_RULE_FLATC_ARGS})
endif()
+ set(_GEN_TARGET "${_NAME}_gen")
+
build_flatbuffers(
"${_RULE_SRCS}"
"${IREE_ROOT_DIR}"
- "${_NAME}_gen" # custom_target_name
- "${_RULE_DEPS}" # additional_dependencies
+ "${_GEN_TARGET}" # custom_target_name
+ "${_RULE_DEPS}" # additional_dependencies
"${CMAKE_CURRENT_BINARY_DIR}" # generated_include_dir
"${CMAKE_CURRENT_BINARY_DIR}" # binary_schemas_dir
"" # copy_text_schemas_dir
@@ -107,10 +109,10 @@
# Add dependency on flatc explicitly. This is needed for cross-compiling
# where flatc comes from another CMake invocation for host.
- iree_add_executable_dependencies("${_NAME}_gen" flatc)
+ iree_add_executable_dependencies(${_GEN_TARGET} flatc)
add_library(${_NAME} INTERFACE)
- add_dependencies(${_NAME} ${_NAME}_gen)
+ add_dependencies(${_NAME} ${_GEN_TARGET})
target_include_directories(${_NAME}
INTERFACE
"$<BUILD_INTERFACE:${IREE_COMMON_INCLUDE_DIRS}>"
diff --git a/build_tools/cmake/iree_bytecode_module.cmake b/build_tools/cmake/iree_bytecode_module.cmake
index 3c56aa9..64f8fd0 100644
--- a/build_tools/cmake/iree_bytecode_module.cmake
+++ b/build_tools/cmake/iree_bytecode_module.cmake
@@ -59,7 +59,7 @@
set(_TRANSLATE_TOOL "iree-translate")
endif()
- iree_get_executable_path(${_TRANSLATE_TOOL} _TRANSLATE_TOOL_EXECUTABLE)
+ iree_get_executable_path(_TRANSLATE_TOOL_EXECUTABLE ${_TRANSLATE_TOOL})
set(_ARGS "${_FLAGS}")
list(APPEND _ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${_RULE_SRC}")
diff --git a/build_tools/cmake/iree_cc_embed_data.cmake b/build_tools/cmake/iree_cc_embed_data.cmake
index 40fd0c0..7eeac23 100644
--- a/build_tools/cmake/iree_cc_embed_data.cmake
+++ b/build_tools/cmake/iree_cc_embed_data.cmake
@@ -79,7 +79,7 @@
list(APPEND _ARGS "${SRC}")
endforeach(SRC)
- iree_get_executable_path(generate_cc_embed_data _EXE_PATH)
+ iree_get_executable_path(_EXE_PATH generate_cc_embed_data)
add_custom_command(
OUTPUT "${_RULE_H_FILE_OUTPUT}" "${_RULE_CC_FILE_OUTPUT}"
diff --git a/build_tools/cmake/iree_copts.cmake b/build_tools/cmake/iree_copts.cmake
index c367023..7356fbf 100644
--- a/build_tools/cmake/iree_copts.cmake
+++ b/build_tools/cmake/iree_copts.cmake
@@ -168,7 +168,7 @@
set(MLIR_TABLEGEN_EXE mlir-tblgen)
# iree-tblgen is not defined using the add_tablegen mechanism as other TableGen
# tools in LLVM.
-iree_get_executable_path(iree-tblgen IREE_TABLEGEN_EXE)
+iree_get_executable_path(IREE_TABLEGEN_EXE iree-tblgen)
#-------------------------------------------------------------------------------
# Third party: tensorflow
diff --git a/build_tools/cmake/iree_cross_compile.cmake b/build_tools/cmake/iree_cross_compile.cmake
index e70da92..4b5e3df 100644
--- a/build_tools/cmake/iree_cross_compile.cmake
+++ b/build_tools/cmake/iree_cross_compile.cmake
@@ -162,24 +162,24 @@
function(iree_host_install TARGET)
cmake_parse_arguments(_RULE "" "TARGET;COMPONENT;PREFIX" "DEPENDS" ${ARGN})
if(_RULE_COMPONENT)
- set(component_option -DCMAKE_INSTALL_COMPONENT="${_RULE_COMPONENT}")
+ set(_COMPONENT_OPTION -DCMAKE_INSTALL_COMPONENT="${_RULE_COMPONENT}")
endif()
if(_RULE_PREFIX)
- set(prefix_option -DCMAKE_INSTALL_PREFIX="${_RULE_PREFIX}")
+ set(_PREFIX_OPTION -DCMAKE_INSTALL_PREFIX="${_RULE_PREFIX}")
endif()
- iree_get_executable_path(${TARGET} output_path)
+ iree_get_executable_path(_OUTPUT_PATH ${TARGET})
add_custom_command(
- OUTPUT ${output_path}
+ OUTPUT ${_OUTPUT_PATH}
DEPENDS ${_RULE_DEPENDS}
- COMMAND "${CMAKE_COMMAND}" ${component_option} ${prefix_option}
+ COMMAND "${CMAKE_COMMAND}" ${_COMPONENT_OPTION} ${_PREFIX_OPTION}
-P "${IREE_HOST_BINARY_ROOT}/cmake_install.cmake"
USES_TERMINAL)
# Give it a custom target so we can drive the generation manually
# when useful.
- add_custom_target(iree_host_install_${TARGET} DEPENDS ${output_path})
+ add_custom_target(iree_host_install_${TARGET} DEPENDS ${_OUTPUT_PATH})
endfunction()
# iree_declare_host_excutable
@@ -197,7 +197,7 @@
function(iree_declare_host_excutable TARGET)
cmake_parse_arguments(_RULE "BUILDONLY" "" "DEPENDS" ${ARGN})
- iree_get_executable_path(${TARGET} output_path)
+ iree_get_executable_path(_OUTPUT_PATH ${TARGET})
iree_get_build_command(${TARGET}
BINDIR ${IREE_HOST_BINARY_ROOT}
@@ -219,7 +219,8 @@
PREFIX ${IREE_HOST_BINARY_ROOT}
DEPENDS iree_host_build_${TARGET})
- # Give it a custom target so we can drive the generation manually
- # when useful.
- add_custom_target(iree_host_${TARGET} DEPENDS "${output_path}")
+ # Note that this is not enabled when BUILDONLY so we can define
+ # iree_host_${TARGET} to point to another installation path to
+ # allow flexibility.
+ add_custom_target(iree_host_${TARGET} DEPENDS "${_OUTPUT_PATH}")
endfunction()
diff --git a/build_tools/cmake/iree_macros.cmake b/build_tools/cmake/iree_macros.cmake
index 64f1201..6e4602b 100644
--- a/build_tools/cmake/iree_macros.cmake
+++ b/build_tools/cmake/iree_macros.cmake
@@ -95,18 +95,18 @@
# can only be built on host.
#
# Paramters:
-# - target: the target to build on host.
-# - output_path_var: variable name for receiving the path to the built target.
-function(iree_get_executable_path target output_path_var)
+# - OUTPUT_PATH_VAR: variable name for receiving the path to the built target.
+# - TARGET: the target to build on host.
+function(iree_get_executable_path OUTPUT_PATH_VAR TARGET)
if(CMAKE_CROSSCOMPILING)
# The target is defined in the CMake invocation for host. We don't have
# access to the target; relying on the path here.
- set(output_path "${IREE_HOST_BINARY_ROOT}/bin/${target}")
- set(${output_path_var} "${output_path}" PARENT_SCOPE)
+ set(_OUTPUT_PATH "${IREE_HOST_BINARY_ROOT}/bin/${TARGET}")
+ set(${OUTPUT_PATH_VAR} "${_OUTPUT_PATH}" PARENT_SCOPE)
else()
# The target is defined in this CMake invocation. We can query the location
# directly from CMake.
- set(${output_path_var} "$<TARGET_FILE:${target}>" PARENT_SCOPE)
+ set(${OUTPUT_PATH_VAR} "$<TARGET_FILE:${TARGET}>" PARENT_SCOPE)
endif()
endfunction()