support apt install
diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 75cc55a..8c63e12 100755 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt
@@ -29,6 +29,7 @@ if (POLICY CMP0079) cmake_policy(SET CMP0079 NEW) endif () +include(GNUInstallDirs) set(TsFile_CPP_VERSION 2.3.2.dev) if (MSVC) @@ -305,3 +306,5 @@ endif () add_subdirectory(examples) + +include(${CMAKE_SOURCE_DIR}/cmake/TsFileCPack.cmake)
diff --git a/cpp/cmake/TsFileCPack.cmake b/cpp/cmake/TsFileCPack.cmake new file mode 100644 index 0000000..f816c53 --- /dev/null +++ b/cpp/cmake/TsFileCPack.cmake
@@ -0,0 +1,97 @@ +#[[ +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +]] + +set(TSFILE_ROOT_DIR ${CMAKE_SOURCE_DIR}/..) +set(TSFILE_DOC_FILES "") +foreach(doc_file LICENSE NOTICE) + if (EXISTS ${TSFILE_ROOT_DIR}/${doc_file}) + list(APPEND TSFILE_DOC_FILES ${TSFILE_ROOT_DIR}/${doc_file}) + endif() +endforeach() + +if (TSFILE_DOC_FILES) + install(FILES ${TSFILE_DOC_FILES} + DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/libtsfile + COMPONENT runtime) + install(FILES ${TSFILE_DOC_FILES} + DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/libtsfile-dev + COMPONENT development) + install(FILES ${TSFILE_DOC_FILES} + DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/tsfile-cli + COMPONENT tools) +endif() + +set(CPACK_PACKAGE_NAME "apache-tsfile") +set(CPACK_PACKAGE_VENDOR "Apache Software Foundation") +set(CPACK_PACKAGE_CONTACT "Apache TsFile Developers <dev@tsfile.apache.org>") +set(CPACK_PACKAGE_HOMEPAGE_URL "https://tsfile.apache.org/") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Apache TsFile C++ library and command-line tools") +set(CPACK_PACKAGE_VERSION ${TsFile_CPP_VERSION}) +if (TsFile_CPP_VERSION MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+)") + set(CPACK_PACKAGE_VERSION_MAJOR ${CMAKE_MATCH_1}) + set(CPACK_PACKAGE_VERSION_MINOR ${CMAKE_MATCH_2}) + set(CPACK_PACKAGE_VERSION_PATCH ${CMAKE_MATCH_3}) +endif() +set(CPACK_PACKAGE_FILE_NAME + "apache-tsfile-${CPACK_PACKAGE_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}") +if (EXISTS ${TSFILE_ROOT_DIR}/LICENSE) + set(CPACK_RESOURCE_FILE_LICENSE ${TSFILE_ROOT_DIR}/LICENSE) +endif() + +set(CPACK_COMPONENTS_ALL runtime development tools) +set(CPACK_COMPONENT_RUNTIME_DISPLAY_NAME "libtsfile") +set(CPACK_COMPONENT_RUNTIME_DESCRIPTION "Apache TsFile shared library.") +set(CPACK_COMPONENT_DEVELOPMENT_DISPLAY_NAME "libtsfile development files") +set(CPACK_COMPONENT_DEVELOPMENT_DESCRIPTION + "Apache TsFile C/C++ headers and CMake package files.") +set(CPACK_COMPONENT_DEVELOPMENT_DEPENDS runtime) +set(CPACK_COMPONENT_TOOLS_DISPLAY_NAME "tsfile-cli") +set(CPACK_COMPONENT_TOOLS_DESCRIPTION "Apache TsFile command-line tool.") +set(CPACK_COMPONENT_TOOLS_DEPENDS runtime) + +set(CPACK_GENERATOR "TGZ") +if (CMAKE_SYSTEM_NAME STREQUAL "Linux") + list(APPEND CPACK_GENERATOR "DEB" "RPM") +endif() +set(CPACK_PACKAGING_INSTALL_PREFIX "/usr") + +set(CPACK_DEB_COMPONENT_INSTALL ON) +set(CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS ON) +set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") +set(CPACK_DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_CONTACT}) +set(CPACK_DEBIAN_RUNTIME_PACKAGE_NAME "libtsfile") +set(CPACK_DEBIAN_RUNTIME_PACKAGE_SECTION "libs") +set(CPACK_DEBIAN_RUNTIME_PACKAGE_SHLIBDEPS ON) +set(CPACK_DEBIAN_DEVELOPMENT_PACKAGE_NAME "libtsfile-dev") +set(CPACK_DEBIAN_DEVELOPMENT_PACKAGE_SECTION "libdevel") +set(CPACK_DEBIAN_TOOLS_PACKAGE_NAME "tsfile-cli") +set(CPACK_DEBIAN_TOOLS_PACKAGE_SECTION "database") + +set(CPACK_RPM_COMPONENT_INSTALL ON) +set(CPACK_RPM_FILE_NAME "RPM-DEFAULT") +set(CPACK_RPM_PACKAGE_LICENSE "Apache-2.0") +set(CPACK_RPM_PACKAGE_VENDOR ${CPACK_PACKAGE_VENDOR}) +set(CPACK_RPM_RUNTIME_PACKAGE_NAME "libtsfile") +set(CPACK_RPM_RUNTIME_PACKAGE_GROUP "System Environment/Libraries") +set(CPACK_RPM_DEVELOPMENT_PACKAGE_NAME "libtsfile-devel") +set(CPACK_RPM_DEVELOPMENT_PACKAGE_GROUP "Development/Libraries") +set(CPACK_RPM_TOOLS_PACKAGE_NAME "tsfile-cli") +set(CPACK_RPM_TOOLS_PACKAGE_GROUP "Applications/Databases") + +include(CPack)
diff --git a/cpp/cmake/TsFileConfig.cmake.in b/cpp/cmake/TsFileConfig.cmake.in new file mode 100644 index 0000000..08b2f2d --- /dev/null +++ b/cpp/cmake/TsFileConfig.cmake.in
@@ -0,0 +1,25 @@ +#[[ +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +]] + +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) +find_dependency(Threads) + +include("${CMAKE_CURRENT_LIST_DIR}/TsFileTargets.cmake")
diff --git a/cpp/src/CMakeLists.txt b/cpp/src/CMakeLists.txt index 895c1dd..a3de0ef 100644 --- a/cpp/src/CMakeLists.txt +++ b/cpp/src/CMakeLists.txt
@@ -151,6 +151,9 @@ target_link_libraries(write_obj ${COMPRESSION_LIBS}) add_library(tsfile SHARED) +target_include_directories(tsfile PUBLIC + $<BUILD_INTERFACE:${LIBRARY_INCLUDE_DIR}> + $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/tsfile>) if (${COV_ENABLED}) message("Enable code cov...") @@ -162,16 +165,16 @@ set(COV_LINK_LIB -lgcov) endif() if (ENABLE_ANTLR4) - target_link_libraries(tsfile common_obj compress_obj cwrapper_obj file_obj read_obj write_obj parser_obj ${COV_LINK_LIB}) + target_link_libraries(tsfile PRIVATE common_obj compress_obj cwrapper_obj file_obj read_obj write_obj parser_obj ${COV_LINK_LIB}) else() - target_link_libraries(tsfile common_obj compress_obj cwrapper_obj file_obj read_obj write_obj ${COV_LINK_LIB}) + target_link_libraries(tsfile PRIVATE common_obj compress_obj cwrapper_obj file_obj read_obj write_obj ${COV_LINK_LIB}) endif() else() message("Disable code cov...") if (ENABLE_ANTLR4) - target_link_libraries(tsfile common_obj compress_obj cwrapper_obj file_obj read_obj write_obj parser_obj) + target_link_libraries(tsfile PRIVATE common_obj compress_obj cwrapper_obj file_obj read_obj write_obj parser_obj) else() - target_link_libraries(tsfile common_obj compress_obj cwrapper_obj file_obj read_obj write_obj) + target_link_libraries(tsfile PRIVATE common_obj compress_obj cwrapper_obj file_obj read_obj write_obj) endif() endif() @@ -184,8 +187,37 @@ # On Windows a SHARED library produces a .dll (RUNTIME) plus an import .lib # (ARCHIVE); on Unix it produces a .so (LIBRARY). Cover all three so the -# install step works for every platform. +# install step works for every platform and for CPack-based system packages. install(TARGETS tsfile - RUNTIME DESTINATION ${LIBRARY_OUTPUT_PATH} - LIBRARY DESTINATION ${LIBRARY_OUTPUT_PATH} - ARCHIVE DESTINATION ${LIBRARY_OUTPUT_PATH}) + EXPORT TsFileTargets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + COMPONENT runtime + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + COMPONENT runtime + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + COMPONENT development) + +install(DIRECTORY ${CMAKE_SOURCE_DIR}/src/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/tsfile + COMPONENT development + FILES_MATCHING PATTERN "*.h") + +include(CMakePackageConfigHelpers) +set(TSFILE_CMAKE_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/tsfile) +configure_package_config_file( + ${CMAKE_SOURCE_DIR}/cmake/TsFileConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/TsFileConfig.cmake + INSTALL_DESTINATION ${TSFILE_CMAKE_INSTALL_DIR}) +write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/TsFileConfigVersion.cmake + VERSION ${TsFile_CPP_VERSION} + COMPATIBILITY SameMajorVersion) +install(EXPORT TsFileTargets + NAMESPACE TsFile:: + DESTINATION ${TSFILE_CMAKE_INSTALL_DIR} + COMPONENT development) +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/TsFileConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/TsFileConfigVersion.cmake + DESTINATION ${TSFILE_CMAKE_INSTALL_DIR} + COMPONENT development)
diff --git a/cpp/third_party/CMakeLists.txt b/cpp/third_party/CMakeLists.txt index 4ba94fc..f48f13b 100755 --- a/cpp/third_party/CMakeLists.txt +++ b/cpp/third_party/CMakeLists.txt
@@ -23,29 +23,31 @@ # pre-seeding it in the cache makes its option() call a no-op. set(WITH_STATIC_CRT OFF CACHE BOOL "Link the ANTLR4 runtime against the dynamic CRT" FORCE) - add_subdirectory(antlr4-cpp-runtime-4) + add_subdirectory(antlr4-cpp-runtime-4 EXCLUDE_FROM_ALL) message("ANTLR4 runtime is enabled") else() message("ANTLR4 runtime is disabled") endif() if (ENABLE_SNAPPY) - add_subdirectory(google_snappy) + set(SNAPPY_INSTALL OFF CACHE BOOL "Install Snappy's header and library" FORCE) + add_subdirectory(google_snappy EXCLUDE_FROM_ALL) endif() if (ENABLE_LZ4) - add_subdirectory(lz4) + add_subdirectory(lz4 EXCLUDE_FROM_ALL) endif() if (ENABLE_LZOKAY) - add_subdirectory(lzokay) + add_subdirectory(lzokay EXCLUDE_FROM_ALL) endif() if (ENABLE_ZLIB) - add_subdirectory(zlib-1.3.1) + set(SKIP_INSTALL_ALL ON CACHE BOOL "Skip bundled zlib install rules" FORCE) + add_subdirectory(zlib-1.3.1 EXCLUDE_FROM_ALL) endif() if (ENABLE_SIMD) - add_subdirectory(simde-0.8.4-rc3) + add_subdirectory(simde-0.8.4-rc3 EXCLUDE_FROM_ALL) endif() -set(CMAKE_POSITION_INDEPENDENT_CODE ON) \ No newline at end of file +set(CMAKE_POSITION_INDEPENDENT_CODE ON)
diff --git a/cpp/tools/CMakeLists.txt b/cpp/tools/CMakeLists.txt index 70fbcf8..f0f5cb1 100644 --- a/cpp/tools/CMakeLists.txt +++ b/cpp/tools/CMakeLists.txt
@@ -51,4 +51,6 @@ OUTPUT_NAME tsfile-cli RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) -install(TARGETS tsfile_cli RUNTIME DESTINATION bin) +install(TARGETS tsfile_cli + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + COMPONENT tools)