From 18f51ffb936accdab2ebe90005dac806de5d9e3a Mon Sep 17 00:00:00 2001 From: Zaphhh Date: Wed, 2 Apr 2025 20:22:43 +0100 Subject: [PATCH] Add CMake support --- CMakeLists.txt | 14 ++++++++++++++ Package.swift | 15 ++++++++++++--- Sources/CMakeLists.txt | 26 ++++++++++++++++++++++++++ Tests/CMakeLists.txt | 2 ++ Tests/DemoApp/CMakeLists.txt | 13 +++++++++++++ Tests/SampleBackends/CMakeLists.txt | 12 ++++++++++++ 6 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 Sources/CMakeLists.txt create mode 100644 Tests/CMakeLists.txt create mode 100644 Tests/DemoApp/CMakeLists.txt create mode 100644 Tests/SampleBackends/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..bb8ecd9 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.29) +project(Meta LANGUAGES Swift) + +if(POLICY CMP0157) + cmake_policy(SET CMP0157 NEW) +endif() + +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) +add_subdirectory(Tests) \ No newline at end of file diff --git a/Package.swift b/Package.swift index a5e0a2d..3e9c4a1 100644 --- a/Package.swift +++ b/Package.swift @@ -24,17 +24,26 @@ let package = Package( targets: [ .target( name: "Meta", - path: "Sources" + path: "Sources", + exclude: [ + "CMakeLists.txt" + ] ), .target( name: "SampleBackends", dependencies: ["Meta"], - path: "Tests/SampleBackends" + path: "Tests/SampleBackends", + exclude: [ + "CMakeLists.txt" + ] ), .executableTarget( name: "DemoApp", dependencies: ["SampleBackends"], - path: "Tests/DemoApp" + path: "Tests/DemoApp", + exclude: [ + "CMakeLists.txt" + ] ) ], swiftLanguageModes: [.v5] diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt new file mode 100644 index 0000000..a1f0cd6 --- /dev/null +++ b/Sources/CMakeLists.txt @@ -0,0 +1,26 @@ +file(GLOB META_SOURCES + "Model/Data Flow/*.swift" + + "Model/Extensions/*.swift" + + "Model/User Interface/App/*.swift" + "Model/User Interface/Scene/*.swift" + "Model/User Interface/View/Properties/*.swift" + "Model/User Interface/View/*.swift" + + "View/*.swift" +) + +add_library(Meta ${META_SOURCES}) + +target_compile_options(Meta PUBLIC -enable-testing) + +set_target_properties(Meta PROPERTIES + Swift_LANGUAGE_VERSION 5 +) + +install(TARGETS Meta + 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..928bdc2 --- /dev/null +++ b/Tests/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(SampleBackends) +add_subdirectory(DemoApp) \ No newline at end of file diff --git a/Tests/DemoApp/CMakeLists.txt b/Tests/DemoApp/CMakeLists.txt new file mode 100644 index 0000000..8b83a77 --- /dev/null +++ b/Tests/DemoApp/CMakeLists.txt @@ -0,0 +1,13 @@ +add_executable(DemoApp + DemoApp.swift +) + +target_compile_options(DemoApp PUBLIC + -parse-as-library +) + +target_link_libraries(DemoApp PRIVATE SampleBackends) + +set_target_properties(DemoApp PROPERTIES + Swift_LANGUAGE_VERSION 5 +) diff --git a/Tests/SampleBackends/CMakeLists.txt b/Tests/SampleBackends/CMakeLists.txt new file mode 100644 index 0000000..0a7dc47 --- /dev/null +++ b/Tests/SampleBackends/CMakeLists.txt @@ -0,0 +1,12 @@ +add_library(SampleBackends + Backend1.swift + Backend2.swift +) + +target_link_libraries(SampleBackends + PRIVATE Meta +) + +set_target_properties(SampleBackends PROPERTIES + Swift_LANGUAGE_VERSION 5 +) \ No newline at end of file