Skip to content

Fix macro source location #910

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 10, 2024

Conversation

etcwilde
Copy link
Contributor

@etcwilde etcwilde commented Sep 9, 2024

When a project is used through a FetchContent/add_subdirectory, the CMAKE_SOURCE_DIR path points to the calling project. This is resulting in some of the CI jobs attempting to FetchContent the macros from swift-corelibs-foundation/Sources/FoundationMacros, rather than swift-foundation/Sources/FoundationMacros, ultimately failing the build.

The project call sets a ${CMAKE_PROJECT_NAME}_SOURCE_DIR variable to the source directory of the project itself, making it more reliable. CMAKE_CURRENT_SOURCE_DIR would also work here too.

Noticed in: https://ci.swift.org/view/all/job/swift-build-static-sdk/46

When a project is used through a FetchContent/add_subdirectory, the
`CMAKE_SOURCE_DIR` path points to the calling project. This is resulting
in some of the CI jobs attempting to FetchContent the macros from
`swift-corelibs-foundation/Sources/FoundationMacros`, rather than
`swift-foundation/Sources/FoundationMacros`, ultimately failing the
build.

The `project` call sets a `${CMAKE_PROJECT_NAME}_SOURCE_DIR` variable to
the source directory of the project itself, making it more reliable.
`CMAKE_CURRENT_SOURCE_DIR` would also work here too.
@etcwilde
Copy link
Contributor Author

etcwilde commented Sep 9, 2024

@swift-ci please test

Copy link
Contributor

@jmschonfeld jmschonfeld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine to me, but before merging could we kick off a cross-repo toolchain build to make sure this behaves as expected since this repo doesn't (yet) have tests for the CMake build? The new swift-integration-tests should ensure that the built macro loads as expected

@etcwilde etcwilde merged commit a74c8b3 into swiftlang:main Sep 10, 2024
3 checks passed
@etcwilde etcwilde deleted the ewilde/fix-macro-src-path branch September 10, 2024 20:46
cthielen pushed a commit to cthielen/swift-foundation that referenced this pull request Nov 8, 2024
When a project is used through a FetchContent/add_subdirectory, the
`CMAKE_SOURCE_DIR` path points to the calling project. This is resulting
in some of the CI jobs attempting to FetchContent the macros from
`swift-corelibs-foundation/Sources/FoundationMacros`, rather than
`swift-foundation/Sources/FoundationMacros`, ultimately failing the
build.

The `project` call sets a `${CMAKE_PROJECT_NAME}_SOURCE_DIR` variable to
the source directory of the project itself, making it more reliable.
`CMAKE_CURRENT_SOURCE_DIR` would also work here too.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants