diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..b45a598 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,35 @@ +cmake_minimum_required(VERSION 3.19) + +# Enable C and Swift languages +project(swift-log + LANGUAGES C Swift) + +option(BUILD_TESTING "Build testing targets" ON) +option(BUILD_SHARED_LIBS "Build shared libraries by default" YES) + +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) + +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) + +set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift) + +include(CTest) +include(GNUInstallDirs) +include(SwiftSupport) + +if(NOT APPLE) + find_package(dispatch QUIET) + find_package(Foundation QUIET) + if(BUILD_TESTING) + find_package(XCTest CONFIG QUIET) + endif() +endif() + +add_subdirectory(Sources) +if(BUILD_TESTING) + add_subdirectory(Tests) +endif() + +add_subdirectory(cmake/modules) diff --git a/Package.swift b/Package.swift index 44e1916..b513b07 100644 --- a/Package.swift +++ b/Package.swift @@ -29,19 +29,23 @@ let package = Package( targets: [ .target( name: "Logging", - dependencies: [] + dependencies: [], + exclude: ["CMakeLists.txt"] ), .target( name: "InMemoryLogging", - dependencies: ["Logging"] + dependencies: ["Logging"], + exclude: ["CMakeLists.txt"] ), .testTarget( name: "LoggingTests", - dependencies: ["Logging"] + dependencies: ["Logging"], + exclude: ["CMakeLists.txt"] ), .testTarget( name: "InMemoryLoggingTests", - dependencies: ["InMemoryLogging", "Logging"] + dependencies: ["InMemoryLogging", "Logging"], + exclude: ["CMakeLists.txt"] ), ] ) diff --git a/Package@swift-6.1.swift b/Package@swift-6.1.swift index 4a4ef46..022d26d 100644 --- a/Package@swift-6.1.swift +++ b/Package@swift-6.1.swift @@ -29,19 +29,23 @@ let package = Package( targets: [ .target( name: "Logging", - dependencies: [] + dependencies: [], + exclude: ["CMakeLists.txt"] ), .target( name: "InMemoryLogging", - dependencies: ["Logging"] + dependencies: ["Logging"], + exclude: ["CMakeLists.txt"] ), .testTarget( name: "LoggingTests", - dependencies: ["Logging"] + dependencies: ["Logging"], + exclude: ["CMakeLists.txt"] ), .testTarget( name: "InMemoryLoggingTests", - dependencies: ["InMemoryLogging", "Logging"] + dependencies: ["InMemoryLogging", "Logging"], + exclude: ["CMakeLists.txt"] ), ] )