Merge pull request 'Add CMake support' (#2) from Zaph/meta:main into main
Some checks failed
Deploy Docs / publish (push) Failing after 25s
SwiftLint / SwiftLint (push) Successful in 3s

Reviewed-on: #2
Reviewed-by: david-swift <david-swift@noreply.aproksha.uber.space>
This commit is contained in:
david-swift 2025-04-05 18:33:45 +02:00
commit ce9c5bf7d1
6 changed files with 79 additions and 3 deletions

14
CMakeLists.txt Normal file
View File

@ -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)

View File

@ -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]

26
Sources/CMakeLists.txt Normal file
View File

@ -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
)

2
Tests/CMakeLists.txt Normal file
View File

@ -0,0 +1,2 @@
add_subdirectory(SampleBackends)
add_subdirectory(DemoApp)

View File

@ -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
)

View File

@ -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
)