Skip to content

Commit 224d763

Browse files
committed
[cmake] Follow LLVM/Clang's example and use add_llvm_subdirectory and invoke add_llvm_subdirectory when adding tools/libs. This allows us to selectively disable the building of tools by setting the variable SWIFT_{TOOL,LIB}_XXX_BUILD=OFF.
This is done by introducing the macros: add_swift_{lib,tool}_subdirectory.
1 parent 1f63d98 commit 224d763

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1759,3 +1759,11 @@ function(add_swift_executable name)
17591759
${SWIFTEXE_DONT_STRIP_NON_MAIN_SYMBOLS_FLAG}
17601760
${SWIFTEXE_DISABLE_ASLR_FLAG})
17611761
endfunction()
1762+
1763+
macro(add_swift_tool_subdirectory name)
1764+
add_llvm_subdirectory(SWIFT TOOL ${name})
1765+
endmacro()
1766+
1767+
macro(add_swift_lib_subdirectory name)
1768+
add_llvm_subdirectory(SWIFT LIB ${name})
1769+
endmacro()

tools/CMakeLists.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
add_subdirectory(driver)
2-
add_subdirectory(sil-opt)
3-
add_subdirectory(swift-ide-test)
4-
add_subdirectory(swift-remoteast-test)
5-
add_subdirectory(swift-demangle)
6-
add_subdirectory(lldb-moduleimport-test)
7-
add_subdirectory(sil-extract)
8-
add_subdirectory(swift-llvm-opt)
1+
add_swift_tool_subdirectory(driver)
2+
add_swift_tool_subdirectory(sil-opt)
3+
add_swift_tool_subdirectory(swift-ide-test)
4+
add_swift_tool_subdirectory(swift-remoteast-test)
5+
add_swift_tool_subdirectory(swift-demangle)
6+
add_swift_tool_subdirectory(lldb-moduleimport-test)
7+
add_swift_tool_subdirectory(sil-extract)
8+
add_swift_tool_subdirectory(swift-llvm-opt)
99

1010
if(SWIFT_BUILD_SOURCEKIT)
11-
add_subdirectory(SourceKit)
11+
add_swift_tool_subdirectory(SourceKit)
1212
endif()

tools/SourceKit/tools/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ include_directories(
44
${SOURCEKITD_SOURCE_DIR}/include
55
)
66

7-
add_subdirectory(sourcekitd)
8-
add_subdirectory(sourcekitd-test)
9-
add_subdirectory(sourcekitd-repl)
10-
add_subdirectory(complete-test)
7+
add_swift_lib_subdirectory(sourcekitd)
8+
add_swift_tool_subdirectory(sourcekitd-test)
9+
add_swift_tool_subdirectory(sourcekitd-repl)
10+
add_swift_tool_subdirectory(complete-test)

0 commit comments

Comments
 (0)