Add CMake Support

This commit is contained in:
Zaphhh 2025-04-06 01:17:13 +01:00
parent 92ac8e8263
commit 2fa6f9395d
4 changed files with 52 additions and 2 deletions

26
CMakeLists.txt Normal file
View File

@ -0,0 +1,26 @@
cmake_minimum_required(VERSION 3.29)
cmake_policy(SET CMP0157 NEW)
project(meta-json
LANGUAGES Swift)
include(FetchContent)
FetchContent_Declare(
Meta
GIT_REPOSITORY https://git.aparoksha.dev/aparoksha/meta
GIT_TAG main
)
FetchContent_MakeAvailable(Meta)
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 PROJECT_NAME)
add_subdirectory(Tests)
endif()

View File

@ -23,13 +23,19 @@ let package = Package(
dependencies: [
.product(name: "Meta", package: "meta")
],
path: "Sources"
path: "Sources",
exclude: [
"CMakeLists.txt"
]
),
.executableTarget(
name: "Tests",
dependencies: ["MetaJSON"],
path: "Tests"
path: "Tests",
exclude: [
"CMakeLists.txt"
]
),
],

12
Sources/CMakeLists.txt Normal file
View File

@ -0,0 +1,12 @@
add_library(MetaJSON MetaJSON/State.swift)
target_link_libraries(MetaJSON PRIVATE Meta)
set_target_properties(MetaJSON PROPERTIES
Swift_LANGUAGE_VERSION 5
)
install(TARGETS MetaJSON
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
)

6
Tests/CMakeLists.txt Normal file
View File

@ -0,0 +1,6 @@
add_executable(Tests Test.swift)
target_link_libraries(Tests PRIVATE MetaJSON)
set_target_properties(Tests PROPERTIES
Swift_LANGUAGE_VERSION 5
)