Swift: CMAKE_Swift_MODULE_DIRECTORY not respected by Xcode generator
!9524 (merged) demonstrates. The test will pass with the Ninja generator and fail with Xcode. That's also true if you modify the test this way, to account for multi-config:
if("${CMAKE_CONFIGURATION_TYPES}" STREQUAL "")
set(config_directory_suffix "")
else()
set(config_directory_suffix "/$<CONFIG>")
endif()
add_custom_command(TARGET M
POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E compare_files
"${CMAKE_Swift_MODULE_DIRECTORY}${config_directory_suffix}/M.swiftmodule"
"${CMAKE_Swift_MODULE_DIRECTORY}${config_directory_suffix}/M.swiftmodule"
COMMENT "check that .swiftmodule files are generated in CMAKE_Swift_MODULE_DIRECTORY"
VERBATIM)