Files
swift-mirror/utils/api_checker/CMakeLists.txt
Daniel Rodríguez Troitiño 42e43edef3 [cmake] Unify usage of create_symlink/copy across the build files. (#72202)
In several places, there was the same or similar code to either do
a symlink or use copy/copy_if_different/copy_directory in Windows
systems. The checks were also slightly different in some cases.

There is a `SWIFT_COPY_OR_SYMLINK` that can be controlled as a CMake
option, and uses `CMAKE_HOST_UNIX` as default. Change all cases that
I can find to use that value. Also create a parallel value
`SWIFT_COPY_OR_SYMLINK_DIR` to apply to directories.

There is still a couple of cases that are specific to macOS SourceKit
framework which I have left as-is, since symlinks is probably the only
right thing to do there.

There's a case for Windows specifically that uses symlinks (in
523f807694/cmake/modules/SwiftConfigureSDK.cmake (L502))
which I have not modified as well.
2024-03-09 18:03:55 -08:00

29 lines
1.3 KiB
CMake

set(framework "FrameworkABIBaseline")
swift_install_in_component(PROGRAMS "swift-api-checker.py"
DESTINATION "bin"
COMPONENT toolchain-tools)
swift_install_in_component(DIRECTORY "sdk-module-lists"
DESTINATION "bin"
COMPONENT toolchain-tools)
swift_install_in_component(DIRECTORY "${framework}"
DESTINATION "lib/swift"
COMPONENT toolchain-tools)
# Add symlink of FrameworkABIBaseline to the build dir. This ensures we can
# find the baseline data from the same relative path as if we are running the
# checker from the toolchain.
set(SWIFTLIB_DIR "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib/swift")
set(dest "${SWIFTLIB_DIR}/${framework}")
set(source "${CMAKE_CURRENT_SOURCE_DIR}/${framework}")
add_custom_command(OUTPUT "${dest}"
DEPENDS "${source}"
COMMAND "${CMAKE_COMMAND}" "-E" "${SWIFT_COPY_OR_SYMLINK}" "${source}" "${dest}"
COMMENT "Symlinking ABI checker baseline data to ${dest}")
add_custom_target("symlink_abi_checker_data" ALL
DEPENDS "${dest}"
COMMENT "Symlinking ABI checker baseline data to ${dest}")
if(TARGET swift-frontend)
add_dependencies(swift-frontend symlink_abi_checker_data)
endif()