Add CMake Support #1

Merged
david-swift merged 2 commits from Zaph/levenshtein-transformations:main into main 2025-04-06 16:38:23 +02:00
6 changed files with 52 additions and 2 deletions

1
.gitignore vendored
View File

@ -11,3 +11,4 @@ DerivedData/
.swiftpm/config/registries.json .swiftpm/config/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc .netrc
/.vscode

16
CMakeLists.txt Normal file
View File

@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 3.29)
cmake_policy(SET CMP0157 NEW)
project(LevenshteinTransformations
LANGUAGES Swift)
set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
add_subdirectory(Sources)
if(CMAKE_PROJECT_NAME STREQUAL "LevenshteinTransformations")
add_subdirectory(Tests)
endif()

View File

@ -23,12 +23,18 @@ let package = Package(
], ],
targets: [ targets: [
.target( .target(
name: "LevenshteinTransformations" name: "LevenshteinTransformations",
exclude: [
"CMakeLists.txt"
]
), ),
.executableTarget( .executableTarget(
name: "LevenshteinTransformationsTests", name: "LevenshteinTransformationsTests",
dependencies: ["LevenshteinTransformations"], dependencies: ["LevenshteinTransformations"],
path: "Tests" path: "Tests",
exclude: [
"CMakeLists.txt"
]
) )
] ]
) )

1
Sources/CMakeLists.txt Normal file
View File

@ -0,0 +1 @@
add_subdirectory(LevenshteinTransformations)

View File

@ -0,0 +1,15 @@
add_library(LevenshteinTransformations
Extensions/Array.swift
Extensions/String.swift
AsyncFunctions.swift
EditOperation.swift
Functions.swift
LevenshteinTransformations.swift
Transformation.swift
)
install(TARGETS LevenshteinTransformations
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
)

11
Tests/CMakeLists.txt Normal file
View File

@ -0,0 +1,11 @@
add_executable(Tests
LevenshteinTransformationsTests.swift
)
target_compile_options(Tests PUBLIC
-parse-as-library
)
target_link_libraries(Tests PRIVATE
LevenshteinTransformations
)