Skip to content

Commit 5b4b86e

Browse files
committed
[swift-inspect] support CMake build for Linux
1 parent d965cc6 commit 5b4b86e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tools/swift-inspect/CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@ if(WIN32)
2727
Sources/SwiftInspectClient/SwiftInspectClient.cpp)
2828
target_link_libraries(SwiftInspectClient PRIVATE
2929
SwiftInspectClientInterface)
30+
elseif(LINUX)
31+
string(APPEND CMAKE_Swift_FLAGS " -Xcc -D_GNU_SOURCE")
32+
add_library(SwiftInspectLinux STATIC
33+
Sources/SwiftInspectLinux/ElfFile.swift
34+
Sources/SwiftInspectLinux/LinkMap.swift
35+
Sources/SwiftInspectLinux/MemoryMap.swift
36+
Sources/SwiftInspectLinux/Process.swift
37+
Sources/SwiftInspectLinux/ProcFS.swift
38+
Sources/SwiftInspectLinux/SymbolCache.swift)
39+
target_link_libraries(SwiftInspectLinux PRIVATE
40+
LinuxSystemHeaders)
41+
add_library(LinuxSystemHeaders INTERFACE)
42+
target_include_directories(LinuxSystemHeaders INTERFACE
43+
Sources/SwiftInspectLinux/SystemHeaders)
3044
endif()
3145

3246
add_executable(swift-inspect
@@ -38,6 +52,7 @@ add_executable(swift-inspect
3852
Sources/swift-inspect/Operations/DumpRawMetadata.swift
3953
Sources/swift-inspect/Backtrace.swift
4054
Sources/swift-inspect/DarwinRemoteProcess.swift
55+
Sources/swift-inspect/LinuxRemoteProcess.swift
4156
Sources/swift-inspect/main.swift
4257
Sources/swift-inspect/Process.swift
4358
Sources/swift-inspect/RemoteMirror+Extensions.swift
@@ -54,6 +69,11 @@ target_link_libraries(swift-inspect PRIVATE
5469
if(WIN32)
5570
target_link_libraries(swift-inspect PRIVATE
5671
SwiftInspectClientInterface)
72+
elseif(LINUX)
73+
target_link_libraries(swift-inspect PRIVATE
74+
SwiftInspectLinux)
75+
target_link_libraries(swift-inspect PRIVATE
76+
LinuxSystemHeaders)
5777
endif()
5878

5979
install(TARGETS swift-inspect

0 commit comments

Comments
 (0)