forked from microsoft/vcpkg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lmdb] Update, refresh (microsoft#33967)
* [lmdb] Update, refresh * Use getopt-win32
- Loading branch information
Showing
12 changed files
with
172 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,72 @@ | ||
cmake_minimum_required(VERSION 2.8) | ||
|
||
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/lmdb.h" VERSION_HEADER) | ||
string(REGEX MATCH ".*MDB_VERSION_MAJOR[ \t]+([0-9])" MAJOR_VERSION_MATCH "${VERSION_HEADER}") | ||
set(LMDB_MAJOR_VERSION ${CMAKE_MATCH_1}) | ||
string(REGEX MATCH ".*MDB_VERSION_MINOR[ \t]+([0-9])" MINOR_VERSION_MATCH "${VERSION_HEADER}") | ||
set(LMDB_MINOR_VERSION ${CMAKE_MATCH_1}) | ||
string(REGEX MATCH ".*MDB_VERSION_PATCH[ \t]+([0-9]+)" PATCH_VERSION_MATCH "${VERSION_HEADER}") | ||
set(LMDB_PATCH_VERSION ${CMAKE_MATCH_1}) | ||
|
||
set(LMDB_VERSION "${LMDB_MAJOR_VERSION}.${LMDB_MINOR_VERSION}.${LMDB_PATCH_VERSION}") | ||
cmake_minimum_required(VERSION 3.27) | ||
|
||
project(lmdb) | ||
|
||
option(LMDB_BUILD_TOOLS "Build lmdb tools" OFF) | ||
option(LMDB_BUILD_TESTS "Build lmdb tests" OFF) | ||
option(LMDB_INSTALL_HEADERS "Install LMDB header files" ON) | ||
set(LMDB_INCLUDE_INSTALL_DIR include CACHE PATH "Install directory for headers") | ||
set(LMDB_LIBRARY_INSTALL_DIR lib CACHE PATH "Install directory for library") | ||
set(LMDB_RUNTIME_INSTALL_DIR bin CACHE PATH "Install directory for binaries/dlls") | ||
set(LMDB_CONFIG_INSTALL_DIR share/lmdb CACHE PATH "Install directory for cmake config files") | ||
|
||
if(MSVC AND BUILD_SHARED_LIBS) | ||
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /DEF:\"${CMAKE_CURRENT_SOURCE_DIR}/lmdbd.def\"") | ||
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /DEF:\"${CMAKE_CURRENT_SOURCE_DIR}/lmdb.def\"") | ||
endif() | ||
|
||
set(SRCS lmdb mdb.c lmdb.h midl.c midl.h ) | ||
add_library(lmdb ${SRCS}) | ||
include(GNUInstallDirs) | ||
|
||
if (WIN32) | ||
target_link_libraries(lmdb PRIVATE ntdll.lib) | ||
add_library(lmdb mdb.c lmdb.h midl.c midl.h) | ||
if(WIN32 AND BUILD_SHARED_LIBS) | ||
target_sources(lmdb PRIVATE lmdb.def) | ||
endif() | ||
|
||
install(TARGETS lmdb DESTINATION lib | ||
EXPORT lmdb-targets | ||
RUNTIME DESTINATION ${LMDB_RUNTIME_INSTALL_DIR} | ||
LIBRARY DESTINATION ${LMDB_LIBRARY_INSTALL_DIR} | ||
ARCHIVE DESTINATION ${LMDB_LIBRARY_INSTALL_DIR} | ||
) | ||
set(THREADS_PREFER_PTHREAD_FLAG 1) | ||
find_package(Threads REQUIRED) | ||
target_link_libraries(lmdb PRIVATE Threads::Threads) | ||
|
||
install(TARGETS lmdb | ||
EXPORT unofficial-lmdb-targets | ||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" | ||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" | ||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" | ||
) | ||
|
||
if(LMDB_INSTALL_HEADERS) | ||
install(FILES lmdb.h midl.h DESTINATION ${LMDB_INCLUDE_INSTALL_DIR}) | ||
install(FILES lmdb.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") | ||
endif() | ||
target_include_directories(lmdb INTERFACE "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>") | ||
|
||
include(CMakePackageConfigHelpers) | ||
|
||
set(INSTALL_INCLUDE_DIR ${LMDB_INCLUDE_INSTALL_DIR}) | ||
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/package-config.cmakein ${CMAKE_CURRENT_BINARY_DIR}/lmdb-config.cmake | ||
INSTALL_DESTINATION ${LMDB_CONFIG_INSTALL_DIR} | ||
PATH_VARS INSTALL_INCLUDE_DIR | ||
) | ||
|
||
write_basic_package_version_file( ${CMAKE_CURRENT_BINARY_DIR}/lmdb-config-version.cmake VERSION ${LMDB_VERSION} COMPATIBILITY SameMajorVersion ) | ||
|
||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/lmdb-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/lmdb-config-version.cmake | ||
DESTINATION ${LMDB_CONFIG_INSTALL_DIR} ) | ||
|
||
|
||
install(EXPORT lmdb-targets DESTINATION ${LMDB_CONFIG_INSTALL_DIR}) | ||
configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/package-config.cmakein" "${CMAKE_CURRENT_BINARY_DIR}/unofficial-lmdb-config.cmake" | ||
INSTALL_DESTINATION "${CMAKE_INSTALL_DATADIR}/lmdb" | ||
) | ||
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/unofficial-lmdb-config-version.cmake" | ||
VERSION "${LMDB_VERSION}" | ||
COMPATIBILITY SameMajorVersion | ||
) | ||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/unofficial-lmdb-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/unofficial-lmdb-config-version.cmake" | ||
DESTINATION "${CMAKE_INSTALL_DATADIR}/unofficial-lmdb" | ||
) | ||
install(EXPORT unofficial-lmdb-targets | ||
NAMESPACE unofficial::lmdb:: | ||
DESTINATION "${CMAKE_INSTALL_DATADIR}/unofficial-lmdb" | ||
) | ||
|
||
if(LMDB_BUILD_TOOLS) | ||
# don't build mdb_dump/load/stat since they will | ||
# not build on windows | ||
foreach(_tool mdb_copy) | ||
add_executable(${_tool} ${_tool}.c) | ||
target_link_libraries(${_tool} lmdb) | ||
endforeach() | ||
set(getopt_libs "") | ||
if(WIN32 AND NOT MINGW) | ||
find_package(unofficial-getopt-win32 REQUIRED) | ||
set(getopt_libs "unofficial::getopt-win32::getopt") | ||
endif() | ||
foreach(tool IN ITEMS mdb_copy mdb_dump mdb_load mdb_stat) | ||
add_executable(${tool} ${tool}.c) | ||
target_link_libraries(${tool} lmdb ${getopt_libs}) | ||
install(TARGETS ${tool} | ||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" | ||
) | ||
endforeach() | ||
endif() | ||
|
||
if(LMDB_BUILD_TESTS) | ||
enable_testing() | ||
# don't use mtest6 since it will only build in static | ||
# build | ||
foreach(_test mtest mtest2 mtest3 mtest4 mtest5) | ||
add_executable(${_test} ${_test}.c) | ||
target_link_libraries(${_test} lmdb) | ||
add_test(NAME ${_test} | ||
COMMAND ${CMAKE_COMMAND} -DTEST=$<TARGET_FILE:"${_test}" -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/runtest.cmake) | ||
endforeach() | ||
enable_testing() | ||
# mtest6 needs more symbols than provided by some builds of lmdb | ||
foreach(test IN ITEMS mtest mtest2 mtest3 mtest4 mtest5) | ||
add_executable(${test} ${test}.c) | ||
target_link_libraries(${test} lmdb) | ||
add_test(NAME ${test} | ||
COMMAND "${CMAKE_COMMAND}" "-DTEST=$<TARGET_FILE:${test}" -P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/runtest.cmake") | ||
endforeach() | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,7 @@ | ||
@PACKAGE_INIT@ | ||
|
||
include("${CMAKE_CURRENT_LIST_DIR}/lmdb-targets.cmake") | ||
include(CMakeFindDependencyMacro) | ||
set(THREADS_PREFER_PTHREAD_FLAG 1) | ||
find_dependency(Threads) | ||
|
||
set(${CMAKE_FIND_PACKAGE_NAME}_INCLUDE_DIR @PACKAGE_INSTALL_INCLUDE_DIR@) | ||
set(${CMAKE_FIND_PACKAGE_NAME}_INCLUDE_DIRS @PACKAGE_INSTALL_INCLUDE_DIR@) | ||
set(${CMAKE_FIND_PACKAGE_NAME}_LIBRARIES lmdb) | ||
|
||
string(TOUPPER "${CMAKE_FIND_PACKAGE_NAME}" UPPER_PACKAGE_NAME) | ||
|
||
set(${UPPER_PACKAGE_NAME}_INCLUDE_DIR @PACKAGE_INSTALL_INCLUDE_DIR@) | ||
set(${UPPER_PACKAGE_NAME}_INCLUDE_DIRS @PACKAGE_INSTALL_INCLUDE_DIR@) | ||
set(${UPPER_PACKAGE_NAME}_LIBRARIES lmdb) | ||
include("${CMAKE_CURRENT_LIST_DIR}/unofficial-lmdb-targets.cmake") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
file(MAKE_DIRECTORY testb) | ||
execute_process(COMMAND ${TEST}) | ||
file(REMOVE_RECURSE testdb) | ||
file(REMOVE_RECURSE testdb) | ||
file(MAKE_DIRECTORY testdb) | ||
execute_process(COMMAND "${TEST}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,4 +55,4 @@ EXPORTS | |
mdb_cmp | ||
mdb_dcmp | ||
mdb_reader_list | ||
mdb_reader_check | ||
mdb_reader_check |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
diff --git a/libraries/liblmdb/mdb_dump.c b/libraries/liblmdb/mdb_dump.c | ||
index 7ea72e8..198230c 100644 | ||
--- a/libraries/liblmdb/mdb_dump.c | ||
+++ b/libraries/liblmdb/mdb_dump.c | ||
@@ -16,7 +16,11 @@ | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <ctype.h> | ||
+#ifdef _MSC_VER | ||
+#include <getopt.h> | ||
+#else | ||
#include <unistd.h> | ||
+#endif | ||
#include <signal.h> | ||
#include "lmdb.h" | ||
|
||
diff --git a/libraries/liblmdb/mdb_load.c b/libraries/liblmdb/mdb_load.c | ||
index d2a3cec..f050286 100644 | ||
--- a/libraries/liblmdb/mdb_load.c | ||
+++ b/libraries/liblmdb/mdb_load.c | ||
@@ -16,7 +16,11 @@ | ||
#include <errno.h> | ||
#include <string.h> | ||
#include <ctype.h> | ||
+#ifdef _MSC_VER | ||
+#include <getopt.h> | ||
+#else | ||
#include <unistd.h> | ||
+#endif | ||
#include "lmdb.h" | ||
|
||
#define PRINT 1 | ||
diff --git a/libraries/liblmdb/mdb_stat.c b/libraries/liblmdb/mdb_stat.c | ||
index 3a81175..f1f4a75 100644 | ||
--- a/libraries/liblmdb/mdb_stat.c | ||
+++ b/libraries/liblmdb/mdb_stat.c | ||
@@ -14,7 +14,13 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
+#ifdef _MSC_VER | ||
+#include <getopt.h> | ||
+#include <BaseTsd.h> | ||
+typedef SSIZE_T ssize_t; | ||
+#else | ||
#include <unistd.h> | ||
+#endif | ||
#include "lmdb.h" | ||
|
||
#ifdef _WIN32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
file(READ "${CMAKE_CURRENT_LIST_DIR}/../lmdb/usage" usage) | ||
message(WARNING "find_package(lmdb) is deprecated.\n${usage}") | ||
|
||
include(CMakeFindDependencyMacro) | ||
find_dependency(unofficial-lmdb ${${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION}) | ||
|
||
set(${CMAKE_FIND_PACKAGE_NAME}_INCLUDE_DIR "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include") | ||
set(${CMAKE_FIND_PACKAGE_NAME}_INCLUDE_DIRS "${${CMAKE_FIND_PACKAGE_NAME}_INCLUDE_DIR}") | ||
set(${CMAKE_FIND_PACKAGE_NAME}_LIBRARIES lmdb) | ||
|
||
string(TOUPPER "${CMAKE_FIND_PACKAGE_NAME}" UPPER_PACKAGE_NAME) | ||
set(${UPPER_PACKAGE_NAME}_INCLUDE_DIR "${${CMAKE_FIND_PACKAGE_NAME}_INCLUDE_DIR}") | ||
set(${UPPER_PACKAGE_NAME}_INCLUDE_DIRS "${${CMAKE_FIND_PACKAGE_NAME}_INCLUDE_DIR}") | ||
set(${UPPER_PACKAGE_NAME}_LIBRARIES lmdb) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,43 @@ | ||
vcpkg_from_github( | ||
OUT_SOURCE_PATH SOURCE_PATH | ||
REPO LMDB/lmdb | ||
REF 8ad7be2510414b9506ec9f9e24f24d04d9b04a1a # LMDB_0.9.29 | ||
SHA512 a18b6217761bdfcc5964d9817addd2d0c6c735d02a823717eb7ae1561a48110da0708a3290e21297d481e4d8eeb5d92a4a6860ff44888bf2da665cd9f167513c | ||
REF "LMDB_${VERSION}" | ||
SHA512 a5763ff94af0b5bbc2406c52890797e6232e77593bacdb240441ed30c8634e4e6de6eba206880475544e21561ccd0be2dee16733d6ec35483eb1dbbb81913a8d | ||
HEAD_REF master | ||
PATCHES | ||
getopt-win32.diff | ||
) | ||
|
||
file(COPY "${CMAKE_CURRENT_LIST_DIR}/cmake/" DESTINATION "${SOURCE_PATH}/libraries/liblmdb") | ||
|
||
vcpkg_check_features(OUT_FEATURE_OPTIONS options_release | ||
FEATURES | ||
tools LMDB_BUILD_TOOLS | ||
) | ||
|
||
vcpkg_cmake_configure( | ||
SOURCE_PATH "${SOURCE_PATH}/libraries/liblmdb" | ||
OPTIONS | ||
"-DLMDB_VERSION=${VERSION}" | ||
OPTIONS_RELEASE | ||
${options_release} | ||
OPTIONS_DEBUG | ||
-DLMDB_INSTALL_HEADERS=OFF | ||
) | ||
|
||
vcpkg_cmake_install() | ||
vcpkg_copy_pdbs() | ||
vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-lmdb) | ||
|
||
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") | ||
if(LMDB_BUILD_TOOLS) | ||
vcpkg_copy_tools(TOOL_NAMES mdb_copy mdb_dump mdb_load mdb_stat AUTO_CLEAN) | ||
endif() | ||
|
||
file(INSTALL "${SOURCE_PATH}/libraries/liblmdb/COPYRIGHT" DESTINATION "${CURRENT_PACKAGES_DIR}/share/lmdb" RENAME copyright) | ||
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") | ||
|
||
vcpkg_copy_pdbs() | ||
file(COPY "${CURRENT_PORT_DIR}/lmdb-config.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") | ||
file(COPY "${CURRENT_PORT_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") | ||
vcpkg_install_copyright( | ||
FILE_LIST | ||
"${SOURCE_PATH}/libraries/liblmdb/COPYRIGHT" | ||
"${SOURCE_PATH}/libraries/liblmdb/LICENSE" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
lmdb provides CMake targets: | ||
|
||
find_package(unofficial-lmdb CONFIG REQUIRED) | ||
target_link_libraries(main PRIVATE unofficial::lmdb::lmdb) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters