Skip to content

Commit f8347f1

Browse files
bnbarhamahoppen
authored andcommitted
Add option to install targets even when not top level
Also add namespaced targets for any exported target to facilitate find_package and FetchContent both using the same target names.
1 parent 3301d33 commit f8347f1

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

cmake/modules/AddSwiftHostLibrary.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ function(add_swift_syntax_library name)
130130
endif()
131131
endif()
132132

133-
if(PROJECT_IS_TOP_LEVEL)
133+
if(PROJECT_IS_TOP_LEVEL OR SWIFT_SYNTAX_INSTALL_TARGETS)
134134
# Install this target
135135
install(TARGETS ${name}
136136
EXPORT SwiftSyntaxTargets
@@ -148,4 +148,5 @@ function(add_swift_syntax_library name)
148148
else()
149149
set_property(GLOBAL APPEND PROPERTY SWIFT_EXPORTS ${name})
150150
endif()
151+
add_library(SwiftSyntax::${name} ALIAS ${name})
151152
endfunction()

cmake/modules/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
if(PROJECT_IS_TOP_LEVEL)
1+
if(PROJECT_IS_TOP_LEVEL OR SWIFT_SYNTAX_INSTALL_TARGETS)
22
export(EXPORT SwiftSyntaxTargets
33
FILE ${CMAKE_CURRENT_BINARY_DIR}/SwiftSyntaxConfig.cmake
44
NAMESPACE SwiftSyntax::)

0 commit comments

Comments
 (0)