diff --git a/cmake/TileDB-Superbuild.cmake b/cmake/TileDB-Superbuild.cmake index 62e07f9b790..1a09e997439 100644 --- a/cmake/TileDB-Superbuild.cmake +++ b/cmake/TileDB-Superbuild.cmake @@ -191,3 +191,10 @@ if (TILEDB_TESTS) WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tiledb ) endif() + +# make package (.tar.gz for Linux and MacOS, .zip for Windows) +add_custom_target(package + DEPENDS tiledb + COMMAND ${CMAKE_CPACK_COMMAND} --config CPackConfig.cmake -G "$,ZIP,TGZ>" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tiledb +) \ No newline at end of file diff --git a/cmake/inputs/CustomCPackOptions.cmake.in b/cmake/inputs/CustomCPackOptions.cmake.in new file mode 100644 index 00000000000..60f20100346 --- /dev/null +++ b/cmake/inputs/CustomCPackOptions.cmake.in @@ -0,0 +1,18 @@ +set(CPACK_SOURCE_IGNORE_FILES ".*\\.git;.*build.*") + +set(CPACK_PACKAGE_VENDOR "TileDB Inc.") +set(CPACK_PACKAGE_VERSION "@TILEDB_VERSION@") + +set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF) + +# Append NOAVX2 if needed +if(NOT ${COMPILER_SUPPORTS_AVX2}) + set(NOAVX2 "-noavx2") +endif() + +# Set output name +set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}${NOAVX2}-${CPACK_PACKAGE_VERSION}") +string(TOLOWER ${CPACK_PACKAGE_FILE_NAME} CPACK_PACKAGE_FILE_NAME ) + +# Enable HASH +set(CPACK_PACKAGE_CHECKSUM "SHA256") \ No newline at end of file diff --git a/tiledb/CMakeLists.txt b/tiledb/CMakeLists.txt index f4a11f7c052..06cf1186af6 100644 --- a/tiledb/CMakeLists.txt +++ b/tiledb/CMakeLists.txt @@ -1053,3 +1053,21 @@ configure_file( ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tiledb.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + +# Packaging configuration +configure_file ("${PROJECT_SOURCE_DIR}/cmake/inputs/CustomCPackOptions.cmake.in" + "${PROJECT_BINARY_DIR}/CustomCPackOptions.cmake" + @ONLY) +set (CPACK_PROJECT_CONFIG_FILE + "${PROJECT_BINARY_DIR}/CustomCPackOptions.cmake") + +# Not all options can be set in CustomCPackOptions.cmake +if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + set(CPACK_SOURCE_GENERATOR "ZIP") + set(CPACK_GENERATOR "ZIP") +else() + set(CPACK_SOURCE_GENERATOR "TGZ") + set(CPACK_GENERATOR "TGZ") +endif() + +include(CPack)