From df4057db6fd8b5d19106a99695450aa145920917 Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Wed, 4 Dec 2019 16:23:51 +0300 Subject: [PATCH] mdbx-cmake: refine installation. Change-Id: I085aba06b957eb1a0e9ce24791bcb5bcc496a609 --- CMakeLists.dist-minimal | 118 ++++++++++++++++++++++++++++++++++----- src/CMakeLists.txt | 58 ++++++++++++++----- src/tools/CMakeLists.txt | 25 +++++++-- 3 files changed, 170 insertions(+), 31 deletions(-) diff --git a/CMakeLists.dist-minimal b/CMakeLists.dist-minimal index 99bc9032..48592297 100644 --- a/CMakeLists.dist-minimal +++ b/CMakeLists.dist-minimal @@ -167,7 +167,7 @@ if(MDBX_BUILD_SHARED_LIBRARY) endif() # static library used for tools, to avoid rpath/dll-path troubles -add_library(mdbx-static STATIC EXCLUDE_FROM_ALL mdbx.c mdbx.h) +add_library(mdbx-static STATIC mdbx.c mdbx.h) set_target_properties(mdbx-static PROPERTIES C_STANDARD ${MDBX_C_STANDARD} C_STANDARD_REQUIRED ON PUBLIC_HEADER mdbx.h) @@ -197,20 +197,112 @@ endforeach() # installation if(MDBX_BUILD_SHARED_LIBRARY) - install(TARGETS mdbx EXPORT libmdbx - LIBRARY DESTINATION lib COMPONENT runtime - PUBLIC_HEADER DESTINATION include - INCLUDES DESTINATION include COMPONENT devel) + if(CMAKE_VERSION VERSION_LESS 3.12) + install(TARGETS mdbx EXPORT libmdbx + RUNTIME + DESTINATION bin + COMPONENT runtime + LIBRARY + DESTINATION lib + COMPONENT runtime + OBJECTS + DESTINATION lib + COMPONENT devel + ARCHIVE + DESTINATION lib + COMPONENT devel + PUBLIC_HEADER + DESTINATION include + COMPONENT devel + INCLUDES + DESTINATION include + COMPONENT devel) + else() + install(TARGETS mdbx EXPORT libmdbx + RUNTIME + DESTINATION bin + COMPONENT runtime + LIBRARY + DESTINATION lib + COMPONENT runtime + NAMELINK_COMPONENT devel + OBJECTS + DESTINATION lib + COMPONENT devel + ARCHIVE + DESTINATION lib + COMPONENT devel + PUBLIC_HEADER + DESTINATION include + COMPONENT devel + INCLUDES + DESTINATION include + COMPONENT devel) + endif() endif() -install(TARGETS mdbx-static EXPORT libmdbx - LIBRARY DESTINATION lib COMPONENT runtime - OBJECTS DESTINATION lib/static COMPONENT devel - ARCHIVE DESTINATION lib/static COMPONENT devel - PUBLIC_HEADER DESTINATION include - INCLUDES DESTINATION include COMPONENT devel) +if(CMAKE_VERSION VERSION_LESS 3.12) + install(TARGETS mdbx-static EXPORT libmdbx EXCLUDE_FROM_ALL + RUNTIME + DESTINATION bin + COMPONENT runtime + LIBRARY + DESTINATION lib + COMPONENT runtime + OBJECTS + DESTINATION lib + COMPONENT devel + ARCHIVE + DESTINATION lib + COMPONENT devel + PUBLIC_HEADER + DESTINATION include + COMPONENT devel + INCLUDES + DESTINATION include + COMPONENT devel) +else() + install(TARGETS mdbx-static EXPORT libmdbx EXCLUDE_FROM_ALL + RUNTIME + DESTINATION bin + COMPONENT runtime + LIBRARY + DESTINATION lib + COMPONENT runtime + NAMELINK_COMPONENT devel + OBJECTS + DESTINATION lib + COMPONENT devel + ARCHIVE + DESTINATION lib + COMPONENT devel + PUBLIC_HEADER + DESTINATION include + COMPONENT devel + INCLUDES + DESTINATION include + COMPONENT devel) +endif() -install(TARGETS mdbx_chk mdbx_stat mdbx_copy mdbx_dump mdbx_load - RUNTIME DESTINATION bin COMPONENT runtime) +install( + TARGETS + mdbx_chk + mdbx_stat + mdbx_copy + mdbx_dump + mdbx_load + RUNTIME + DESTINATION bin + COMPONENT runtime) + +install( + FILES + man1/mdbx_chk.1 + man1/mdbx_stat.1 + man1/mdbx_copy.1 + man1/mdbx_dump.1 + man1/mdbx_load.1 + DESTINATION man/man1 + COMPONENT doc) cmake_policy(POP) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 782cc9df..a127eaee 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -120,13 +120,6 @@ if(CC_HAS_VISIBILITY) target_compile_options(mdbx PRIVATE "-fvisibility=hidden") endif() -install(TARGETS mdbx - LIBRARY DESTINATION lib COMPONENT runtime - RUNTIME DESTINATION bin COMPONENT runtime - ARCHIVE DESTINATION lib/static COMPONENT devel - PUBLIC_HEADER DESTINATION include - INCLUDES DESTINATION include COMPONENT devel) - ################################################################################ # # library build info (used in library version output) @@ -226,11 +219,50 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/elements/config.h.in" "${CMAKE_CURRENT_SOURCE_DIR}/elements/config.h" ESCAPE_QUOTES) add_definitions(-DMDBX_CONFIG_H="config.h") -install(TARGETS mdbx EXPORT libmdbx - LIBRARY DESTINATION lib COMPONENT runtime - OBJECTS DESTINATION lib/static COMPONENT devel - ARCHIVE DESTINATION lib/static COMPONENT devel - PUBLIC_HEADER DESTINATION include - INCLUDES DESTINATION include COMPONENT devel) +# installation +if(MDBX_BUILD_SHARED_LIBRARY) + if(CMAKE_VERSION VERSION_LESS 3.12) + install(TARGETS mdbx EXPORT libmdbx + RUNTIME + DESTINATION bin + COMPONENT runtime + LIBRARY + DESTINATION lib + COMPONENT runtime + OBJECTS + DESTINATION lib + COMPONENT devel + ARCHIVE + DESTINATION lib + COMPONENT devel + PUBLIC_HEADER + DESTINATION include + COMPONENT devel + INCLUDES + DESTINATION include + COMPONENT devel) + else() + install(TARGETS mdbx EXPORT libmdbx + RUNTIME + DESTINATION bin + COMPONENT runtime + LIBRARY + DESTINATION lib + COMPONENT runtime + NAMELINK_COMPONENT devel + OBJECTS + DESTINATION lib + COMPONENT devel + ARCHIVE + DESTINATION lib + COMPONENT devel + PUBLIC_HEADER + DESTINATION include + COMPONENT devel + INCLUDES + DESTINATION include + COMPONENT devel) + endif() +endif() add_subdirectory(tools) diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt index a1f66a9a..99167fa8 100644 --- a/src/tools/CMakeLists.txt +++ b/src/tools/CMakeLists.txt @@ -31,9 +31,6 @@ foreach(TOOL ${MDBX_TOOLS}) set_target_properties(${TOOL} PROPERTIES C_STANDARD ${MDBX_C_STANDARD} C_STANDARD_REQUIRED ON INTERPROCEDURAL_OPTIMIZATION $) - - install(TARGETS ${TOOL} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin COMPONENT mdbx) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../man1/${TOOL}.1 DESTINATION ${CMAKE_INSTALL_PREFIX}/man/man1 COMPONENT mdbx) endforeach() if(LIB_MATH) @@ -41,5 +38,23 @@ if(LIB_MATH) target_link_libraries(mdbx_stat ${LIB_MATH}) endif() -install(TARGETS mdbx_chk mdbx_stat mdbx_copy mdbx_dump mdbx_load - RUNTIME DESTINATION bin COMPONENT runtime) +install( + TARGETS + mdbx_chk + mdbx_stat + mdbx_copy + mdbx_dump + mdbx_load + RUNTIME + DESTINATION bin + COMPONENT runtime) + +install( + FILES + ../man1/mdbx_chk.1 + ../man1/mdbx_stat.1 + ../man1/mdbx_copy.1 + ../man1/mdbx_dump.1 + ../man1/mdbx_load.1 + DESTINATION man/man1 + COMPONENT doc)