From 165376757d71e8a7463bd5f665c78c3eb44435b7 Mon Sep 17 00:00:00 2001 From: Zaphhh Date: Sun, 6 Apr 2025 02:01:57 +0100 Subject: [PATCH] Add CMake Support --- .vscode/launch.json | 22 +++++++++++++++++++ CMakeLists.txt | 16 ++++++++++++++ Package.swift | 10 +++++++-- Sources/CMakeLists.txt | 1 + .../LevenshteinTransformations/CMakeLists.txt | 15 +++++++++++++ Tests/CMakeLists.txt | 11 ++++++++++ 6 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 CMakeLists.txt create mode 100644 Sources/CMakeLists.txt create mode 100644 Sources/LevenshteinTransformations/CMakeLists.txt create mode 100644 Tests/CMakeLists.txt diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..6cb96db --- /dev/null +++ b/.vscode/launch.json @@ -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" + } + ] +} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..9ecc08a --- /dev/null +++ b/CMakeLists.txt @@ -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() \ No newline at end of file diff --git a/Package.swift b/Package.swift index a4a9d88..dc019d4 100644 --- a/Package.swift +++ b/Package.swift @@ -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" + ] ) ] ) diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt new file mode 100644 index 0000000..4a10c2c --- /dev/null +++ b/Sources/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(LevenshteinTransformations) \ No newline at end of file diff --git a/Sources/LevenshteinTransformations/CMakeLists.txt b/Sources/LevenshteinTransformations/CMakeLists.txt new file mode 100644 index 0000000..f4f34f8 --- /dev/null +++ b/Sources/LevenshteinTransformations/CMakeLists.txt @@ -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 +) \ No newline at end of file diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt new file mode 100644 index 0000000..5d5a5c1 --- /dev/null +++ b/Tests/CMakeLists.txt @@ -0,0 +1,11 @@ +add_executable(Tests + LevenshteinTransformationsTests.swift +) + +target_compile_options(Tests PUBLIC + -parse-as-library +) + +target_link_libraries(Tests PRIVATE + LevenshteinTransformations +) \ No newline at end of file