Add CMake support
Some checks failed
SwiftLint / SwiftLint (pull_request) Has been cancelled

This commit is contained in:
Zaphhh 2025-04-02 20:22:43 +01:00
parent 9f50e272f3
commit 18f51ffb93
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
)