mdbx-windows: fix MDBX_AVOID_CRT option & ntdll.def distribution.

Resolve https://github.com/erthink/libmdbx/issues/100

Change-Id: I18ab055e79e249fca856353b2585739c88e01758
This commit is contained in:
Leonid Yuriev 2020-05-10 03:41:28 +03:00
parent a238179c23
commit 5b4b3fa9ea
3 changed files with 17 additions and 4 deletions

View File

@ -38,6 +38,9 @@ cmake_minimum_required(VERSION 3.8.2)
cmake_policy(PUSH) cmake_policy(PUSH)
cmake_policy(VERSION 3.8.2) cmake_policy(VERSION 3.8.2)
if(NOT CMAKE_VERSION VERSION_LESS 3.15)
cmake_policy(SET CMP0091 NEW)
endif()
if(NOT CMAKE_VERSION VERSION_LESS 3.13) if(NOT CMAKE_VERSION VERSION_LESS 3.13)
cmake_policy(SET CMP0077 NEW) cmake_policy(SET CMP0077 NEW)
endif() endif()
@ -465,7 +468,7 @@ macro(libmdbx_setup_libs TARGET MODE)
target_link_libraries(${TARGET} ${MODE} ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries(${TARGET} ${MODE} ${CMAKE_THREAD_LIBS_INIT})
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
target_link_libraries(${TARGET} ${MODE} ntdll.lib) target_link_libraries(${TARGET} ${MODE} ntdll.lib)
if(MDBX_NTDLL_EXTRA_IMPLIB) if(MDBX_NTDLL_EXTRA_IMPLIB AND MDBX_AVOID_CRT)
target_link_libraries(${TARGET} ${MODE} ntdll_extra) target_link_libraries(${TARGET} ${MODE} ntdll_extra)
endif() endif()
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Solaris") elseif(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Solaris")
@ -504,6 +507,13 @@ if(MDBX_BUILD_SHARED_LIBRARY)
target_compile_definitions(mdbx PRIVATE LIBMDBX_EXPORTS MDBX_BUILD_SHARED_LIBRARY=1 INTERFACE LIBMDBX_IMPORTS) target_compile_definitions(mdbx PRIVATE LIBMDBX_EXPORTS MDBX_BUILD_SHARED_LIBRARY=1 INTERFACE LIBMDBX_IMPORTS)
target_setup_options(mdbx) target_setup_options(mdbx)
libmdbx_setup_libs(mdbx PRIVATE) libmdbx_setup_libs(mdbx PRIVATE)
if(MSVC)
if(MDBX_NTDLL_EXTRA_IMPLIB AND MDBX_AVOID_CRT)
set_property(TARGET mdbx PROPERTY LINKER_FLAGS "/NODEFAULTLIB")
else()
set_property(TARGET mdbx PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
endif()
endif()
if(CC_HAS_VISIBILITY AND (LTO_ENABLED OR INTERPROCEDURAL_OPTIMIZATION)) if(CC_HAS_VISIBILITY AND (LTO_ENABLED OR INTERPROCEDURAL_OPTIMIZATION))
set_target_properties(mdbx PROPERTIES LINK_FLAGS "-fvisibility=hidden") set_target_properties(mdbx PROPERTIES LINK_FLAGS "-fvisibility=hidden")
endif() endif()

View File

@ -113,7 +113,7 @@ define uname2titer
esac esac
endef endef
DIST_EXTRA := LICENSE README.md CMakeLists.txt GNUmakefile Makefile VERSION config.h.in \ DIST_EXTRA := LICENSE README.md CMakeLists.txt GNUmakefile Makefile VERSION config.h.in ntdll.def \
$(addprefix man1/, $(MANPAGES)) cmake/compiler.cmake cmake/profile.cmake cmake/utils.cmake $(addprefix man1/, $(MANPAGES)) cmake/compiler.cmake cmake/profile.cmake cmake/utils.cmake
DIST_SRC := mdbx.h mdbx.c $(addsuffix .c, $(TOOLS)) DIST_SRC := mdbx.h mdbx.c $(addsuffix .c, $(TOOLS))
@ -280,11 +280,14 @@ dist/$(1): $(1)
mkdir -p $$(dir $$@) && sed -e '/^#> dist-cutoff-begin/,/^#< dist-cutoff-end/d' $$< > $$@ mkdir -p $$(dir $$@) && sed -e '/^#> dist-cutoff-begin/,/^#< dist-cutoff-end/d' $$< > $$@
endef endef
$(foreach file,$(filter-out man1/% VERSION %.in,$(DIST_EXTRA)),$(eval $(call dist-extra-rule,$(file)))) $(foreach file,$(filter-out man1/% VERSION %.in ntdll.def,$(DIST_EXTRA)),$(eval $(call dist-extra-rule,$(file))))
dist/VERSION: src/version.c dist/VERSION: src/version.c
mkdir -p dist/ && echo "$(MDBX_VERSION_GIT).$(MDBX_REVISION_GIT)" > $@ mkdir -p dist/ && echo "$(MDBX_VERSION_GIT).$(MDBX_REVISION_GIT)" > $@
dist/ntdll.def: src/ntdll.def
mkdir -p dist/cmake/ && cp $< $@
dist/config.h.in: src/config.h.in dist/config.h.in: src/config.h.in
mkdir -p dist/cmake/ && cp $< $@ mkdir -p dist/cmake/ && cp $< $@

View File

@ -35,7 +35,7 @@
#define _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS
#endif #endif
#if !defined(_NO_CRT_STDIO_INLINE) && MDBX_BUILD_SHARED_LIBRARY && \ #if !defined(_NO_CRT_STDIO_INLINE) && MDBX_BUILD_SHARED_LIBRARY && \
!defined(MDBX_TOOLS) !defined(MDBX_TOOLS) && MDBX_AVOID_CRT
#define _NO_CRT_STDIO_INLINE #define _NO_CRT_STDIO_INLINE
#endif #endif
#elif !defined(_POSIX_C_SOURCE) #elif !defined(_POSIX_C_SOURCE)