diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000000..85b9557fbc --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,23 @@ +#[[ +This source file is part of the DocC open source project + +Copyright (c) 2024 Apple Inc. and the DocC project authors +Licensed under Apache License v2.0 with Runtime Library Exception + +See https://swift.org/LICENSE.txt for license information +#]] + +cmake_minimum_required(VERSION 3.24) + +project(LMDB + LANGUAGES C) + +# Set the build artifact directories to ensure that the generated products are +# colocated and findable for wiring up into the test suites across repositories. +# This pattern is applied to all Swift and LLVM repositories. +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(cmake/modules) diff --git a/Sources/CLMDB/CMakeLists.txt b/Sources/CLMDB/CMakeLists.txt new file mode 100644 index 0000000000..71c0cedef0 --- /dev/null +++ b/Sources/CLMDB/CMakeLists.txt @@ -0,0 +1,16 @@ +#[[ +This source file is part of the DocC open source project + +Copyright (c) 2024 Apple Inc. and the DocC project authors +Licensed under Apache License v2.0 with Runtime Library Exception + +See https://swift.org/LICENSE.txt for license information +#]] + +add_library(CLMDB + mdb.c + midl.c) +target_include_directories(CLMDB PUBLIC + include) + +set_property(GLOBAL APPEND PROPERTY LMDB_EXPORTS CLMDB) diff --git a/Sources/CLMDB/include/module.modulemap b/Sources/CLMDB/include/module.modulemap new file mode 100644 index 0000000000..03507ae8af --- /dev/null +++ b/Sources/CLMDB/include/module.modulemap @@ -0,0 +1,4 @@ + +module CLMDB { + header "lmdb.h" +} diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt new file mode 100644 index 0000000000..d572410d2f --- /dev/null +++ b/Sources/CMakeLists.txt @@ -0,0 +1,10 @@ +#[[ +This source file is part of the DocC open source project + +Copyright (c) 2024 Apple Inc. and the DocC project authors +Licensed under Apache License v2.0 with Runtime Library Exception + +See https://swift.org/LICENSE.txt for license information +#]] + +add_subdirectory(CLMDB) diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt new file mode 100644 index 0000000000..9c69bea482 --- /dev/null +++ b/cmake/modules/CMakeLists.txt @@ -0,0 +1,19 @@ +#[[ +This source file is part of the DocC open source project + +Copyright (c) 2024 Apple Inc. and the DocC project authors +Licensed under Apache License v2.0 with Runtime Library Exception + +See https://swift.org/LICENSE.txt for license information +#]] + +set(LMDB_EXPORTS_FILE + ${CMAKE_CURRENT_BINARY_DIR}/LMDBExports.cmake) +configure_file(LMDBConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/LMDBConfig.cmake) + +get_property(LMDB_EXPORTS GLOBAL PROPERTY LMDB_EXPORTS) +export(TARGETS ${LMDB_EXPORTS} + NAMESPACE LMDB:: + FILE ${LMDB_EXPORTS_FILE} + EXPORT_LINK_INTERFACE_LIBRARIES) diff --git a/cmake/modules/LMDBConfig.cmake.in b/cmake/modules/LMDBConfig.cmake.in new file mode 100644 index 0000000000..bedf5ae579 --- /dev/null +++ b/cmake/modules/LMDBConfig.cmake.in @@ -0,0 +1,12 @@ +#[[ +This source file is part of the DocC open source project + +Copyright (c) 2024 Apple Inc. and the DocC project authors +Licensed under Apache License v2.0 with Runtime Library Exception + +See https://swift.org/LICENSE.txt for license information +#]] + +if(NOT TARGET LMDB::CLMDB) + include("@LMDB_EXPORTS_FILE@") +endif()