Add CMake Support

This commit is contained in:
Zaphhh 2025-04-06 02:01:57 +01:00
parent 706806433f
commit 165376757d
6 changed files with 73 additions and 2 deletions

22
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,22 @@
{
"configurations": [
{
"type": "swift",
"request": "launch",
"args": [],
"cwd": "${workspaceFolder:levenshtein-transformations}",
"name": "Debug LevenshteinTransformationsTests",
"program": "${workspaceFolder:levenshtein-transformations}/.build/debug/LevenshteinTransformationsTests",
"preLaunchTask": "swift: Build Debug LevenshteinTransformationsTests"
},
{
"type": "swift",
"request": "launch",
"args": [],
"cwd": "${workspaceFolder:levenshtein-transformations}",
"name": "Release LevenshteinTransformationsTests",
"program": "${workspaceFolder:levenshtein-transformations}/.build/release/LevenshteinTransformationsTests",
"preLaunchTask": "swift: Build Release LevenshteinTransformationsTests"
}
]
}

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: [
.target(
name: "LevenshteinTransformations"
name: "LevenshteinTransformations",
exclude: [
"CMakeLists.txt"
]
),
.executableTarget(
name: "LevenshteinTransformationsTests",
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
)