mdbx-cmake: avoid cmake warnings in amalgamated build.

This commit is contained in:
Leo Yuriev 2019-09-19 15:39:32 +03:00
parent 9b9baddd0b
commit b20363d187

View File

@ -48,9 +48,15 @@
cmake_minimum_required(VERSION 3.8.2)
cmake_policy(PUSH)
cmake_policy(VERSION 3.8.2)
if(NOT CMAKE_VERSION VERSION_LESS 3.9)
cmake_policy(SET CMP0069 NEW)
endif()
if(NOT CMAKE_VERSION VERSION_LESS 3.12)
cmake_policy(SET CMP0075 NEW)
endif()
if(NOT CMAKE_VERSION VERSION_LESS 3.13)
cmake_policy(SET CMP0077 NEW)
endif()
if(DEFINED PROJECT_NAME)
set(SUBPROJECT ON)
@ -126,14 +132,19 @@ string(REPLACE ";" "" MDBX_BUILD_FLAGS "${MDBX_BUILD_FLAGS}")
add_definitions(-DMDBX_BUILD_FLAGS="${MDBX_BUILD_FLAGS}")
# shared library
if(DEFINED BUILD_SHARED_LIBS)
option(MDBX_BUILD_SHARED_LIBRARY "Build libmdbx as shared library (DLL)" ${BUILD_SHARED_LIBS})
else()
option(MDBX_BUILD_SHARED_LIBRARY "Build libmdbx as shared library (DLL)" ON)
if(NOT DEFINED MDBX_BUILD_SHARED_LIBRARY)
if(DEFINED BUILD_SHARED_LIBS)
option(MDBX_BUILD_SHARED_LIBRARY "Build libmdbx as shared library (DLL)" ${BUILD_SHARED_LIBS})
else()
option(MDBX_BUILD_SHARED_LIBRARY "Build libmdbx as shared library (DLL)" ON)
endif()
endif()
if(MDBX_BUILD_SHARED_LIBRARY)
add_library(mdbx SHARED mdbx.c mdbx.h)
target_compile_definitions(mdbx PRIVATE LIBMDBX_EXPORTS INTERFACE LIBMDBX_IMPORTS)
if(DEFINED INTERPROCEDURAL_OPTIMIZATION)
set_target_properties(mdbx PROPERTIES INTERPROCEDURAL_OPTIMIZATION $<BOOL:${INTERPROCEDURAL_OPTIMIZATION}>)
endif()
target_link_libraries(mdbx PRIVATE ${CMAKE_THREAD_LIBS_INIT})
if(WIN32)
target_link_libraries(mdbx PRIVATE ntdll.lib)
@ -143,6 +154,9 @@ endif()
# static library used for tools, to avoid rpath/dll-path troubles
add_library(mdbx-static STATIC EXCLUDE_FROM_ALL mdbx.c mdbx.h)
target_link_libraries(mdbx-static INTERFACE ${CMAKE_THREAD_LIBS_INIT})
if(DEFINED INTERPROCEDURAL_OPTIMIZATION)
set_target_properties(mdbx-static PROPERTIES INTERPROCEDURAL_OPTIMIZATION $<BOOL:${INTERPROCEDURAL_OPTIMIZATION}>)
endif()
if(WIN32)
target_link_libraries(mdbx-static INTERFACE ntdll.lib)
endif()
@ -150,6 +164,9 @@ endif()
# mdbx-tools
foreach(TOOL mdbx_chk mdbx_copy mdbx_stat mdbx_dump mdbx_load)
add_executable(${TOOL} ${TOOL}.c)
if(DEFINED INTERPROCEDURAL_OPTIMIZATION)
set_target_properties(${TOOL} PROPERTIES INTERPROCEDURAL_OPTIMIZATION $<BOOL:${INTERPROCEDURAL_OPTIMIZATION}>)
endif()
target_link_libraries(${TOOL} mdbx-static)
endforeach()