Skip to content

Commit a74c8b3

Browse files
authored
Fix macro source location (#910)
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.
1 parent ab00818 commit a74c8b3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Sources/FoundationEssentials/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ else()
5959
# No path to Foundation macros was provided, so we must build it ourselves
6060
set(FoundationMacros_BuildLocalExecutable YES)
6161
FetchContent_Declare(FoundationMacros
62-
SOURCE_DIR ${CMAKE_SOURCE_DIR}/Sources/FoundationMacros)
62+
SOURCE_DIR ${SwiftFoundation_SOURCE_DIR}/Sources/FoundationMacros)
6363
FetchContent_MakeAvailable(FoundationMacros)
6464
add_dependencies(FoundationEssentials FoundationMacros)
6565
get_target_property(MacroDIR FoundationMacros RUNTIME_OUTPUT_DIRECTORY)

0 commit comments

Comments
 (0)