Skip to content

Commit 40e14e3

Browse files
author
Chris Bieneman
committed
[CMake] Fix the Xcode generator
In PR 5182 I broke the Xcode generator in cases where the output path had ${CMAKE_CFG_INTDIR} in it. This broke because $(CONFIGURATION) is invalid in the name of a target. Since all targets will have the same value for CMAKE_BINARY_DIR and CMAKE_CFG_INTDIR we can remove those from the target names and still have unique values. This has the impact of shortening the generated target names so that the filename components are unlikely to hit OS limits using IDE generators where CMake generates Makefiles or scripts for custom commands. It also retains the debug ability that PR 5182 was attempting to add.
1 parent 42a0c46 commit 40e14e3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

cmake/modules/SwiftAddCustomCommandTarget.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ function(add_custom_command_target dependency_out_var_name)
122122
if("${ACCT_CUSTOM_TARGET_NAME}" STREQUAL "")
123123
# CMake doesn't allow '/' characters in filenames, so replace them with '-'
124124
list(GET ACCT_OUTPUT 0 output_filename)
125-
string(REPLACE "/" "-" target_name "${output_filename}")
125+
string(REPLACE "${CMAKE_BINARY_DIR}/" "" target_name "${output_filename}")
126+
string(REPLACE "${CMAKE_CFG_INTDIR}/" "" target_name "${target_name}")
127+
string(REPLACE "/" "-" target_name "${target_name}")
126128
else()
127129
set(target_name "${ACCT_CUSTOM_TARGET_NAME}")
128130
endif()

0 commit comments

Comments
 (0)