Skip to content

Commit b53aefd

Browse files
pgoodmanclaude
andcommitted
Fix dependency cycle when build and source trees overlap
Guard the unsupported_args.cfg copy command with a path comparison so that it is skipped when PROJECT_BINARY_DIR == PROJECT_SOURCE_DIR (or the resolved paths otherwise collide). This avoids the ninja error "dependency cycle: share/multiplier/unsupported_args.cfg -> ..." in CI builds that reuse the source tree as the build tree. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d18e707 commit b53aefd

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

bin/Index/CMakeLists.txt

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,21 @@ find_and_link_llvm_dependencies("${exe_name}")
134134
# <build>/<bin_dir>/, and it looks for ../<share_dir>/multiplier/).
135135
set(MX_ARG_FILTER_SRC "${PROJECT_SOURCE_DIR}/share/multiplier/unsupported_args.cfg")
136136
set(MX_ARG_FILTER_DST "${PROJECT_BINARY_DIR}/${MX_INSTALL_SHARE_DIR}/multiplier/unsupported_args.cfg")
137-
add_custom_command(
138-
OUTPUT "${MX_ARG_FILTER_DST}"
139-
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
140-
"${MX_ARG_FILTER_SRC}" "${MX_ARG_FILTER_DST}"
141-
DEPENDS "${MX_ARG_FILTER_SRC}"
142-
COMMENT "Copying unsupported_args.cfg to build tree"
143-
)
144-
add_custom_target("${exe_name}-arg-filter" ALL DEPENDS "${MX_ARG_FILTER_DST}")
145-
add_dependencies("${exe_name}" "${exe_name}-arg-filter")
137+
138+
# Skip the copy when source and build trees overlap (avoids a dependency cycle).
139+
cmake_path(ABSOLUTE_PATH MX_ARG_FILTER_SRC NORMALIZE OUTPUT_VARIABLE _src_abs)
140+
cmake_path(ABSOLUTE_PATH MX_ARG_FILTER_DST NORMALIZE OUTPUT_VARIABLE _dst_abs)
141+
if(NOT _src_abs STREQUAL _dst_abs)
142+
add_custom_command(
143+
OUTPUT "${MX_ARG_FILTER_DST}"
144+
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
145+
"${MX_ARG_FILTER_SRC}" "${MX_ARG_FILTER_DST}"
146+
DEPENDS "${MX_ARG_FILTER_SRC}"
147+
COMMENT "Copying unsupported_args.cfg to build tree"
148+
)
149+
add_custom_target("${exe_name}-arg-filter" ALL DEPENDS "${MX_ARG_FILTER_DST}")
150+
add_dependencies("${exe_name}" "${exe_name}-arg-filter")
151+
endif()
146152

147153
if(MX_ENABLE_INSTALL AND NOT MX_ENABLE_BOOTSTRAP)
148154
install(

0 commit comments

Comments
 (0)