Skip to content

Add cmake build for Windows #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
cmake_minimum_required(VERSION 3.24)

project(LMDB
LANGUAGES C)

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_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)

add_subdirectory(Sources)
add_subdirectory(cmake/modules)
3 changes: 2 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ let package = Package(
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "CLMDB",
dependencies: []),
dependencies: [],
exclude: ["CMakeLists.txt"]),
]
)
7 changes: 7 additions & 0 deletions Sources/CLMDB/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
add_library(LMDB
mdb.c
midl.c)
target_include_directories(LMDB PUBLIC
include)

set_property(GLOBAL APPEND PROPERTY LMDB_EXPORTS LMDB)
3 changes: 3 additions & 0 deletions Sources/CLMDB/include/module.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module CLMDB {
header "lmdb.h"
}
1 change: 1 addition & 0 deletions Sources/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(CLMDB)
7 changes: 7 additions & 0 deletions cmake/modules/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

set(LMDB_EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/LMDBConfig.cmake)
configure_file(LMDBConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/LMDBConfig.cmake)

get_property(LMDB_EXPORTS GLOBAL PROPERTY LMDB_EXPORTS)
export(TARGETS ${LMDB_EXPORTS} FILE ${LMDB_EXPORTS_FILE})
3 changes: 3 additions & 0 deletions cmake/modules/LMDBConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if(NOT TARGET LMDB::CLMDB)
include("@LMDB_EXPORTS_FILE@")
endif()