Add support for .tar.gz and .zip packages via CPack

This commit is contained in:
David Zemon 2019-05-17 23:17:46 -05:00
parent 55e7844ca0
commit b021be29e5
2 changed files with 46 additions and 6 deletions

View File

@ -91,13 +91,27 @@ if(SPDLOG_BUILD_BENCH)
add_subdirectory(bench)
endif()
#---------------------------------------------------------------------------------------
# install
#---------------------------------------------------------------------------------------
install(DIRECTORY ${HEADER_BASE} DESTINATION include)
install(TARGETS spdlog DESTINATION lib)
if (SPDLOG_INSTALL)
#---------------------------------------------------------------------------------------
# install
#---------------------------------------------------------------------------------------
install(DIRECTORY include/ DESTINATION include)
install(TARGETS spdlog EXPORT ${PROJECT_NAME} DESTINATION lib)
install(EXPORT ${PROJECT_NAME}
DESTINATION lib/${PROJECT_NAME}/cmake
NAMESPACE ${PROJECT_NAME}::
FILE ${PROJECT_NAME}Config.cmake
)
#---------------------------------------------------------------------------------------
# Support creation of installable packages
#---------------------------------------------------------------------------------------
include(SpdlogCPack.cmake)
endif ()
#---------------------------------------------------------------------------------------
# register project in CMake user registry
# register project in CMake user registry - disabled by default since the
# installed/packaged version of the project is preferred.
#---------------------------------------------------------------------------------------
option(CMAKE_EXPORT_NO_PACKAGE_REGISTRY "Disable registration of CMake's build directory." ON)
export(PACKAGE ${PROJECT_NAME})

26
SpdlogCPack.cmake Normal file
View File

@ -0,0 +1,26 @@
set(CPACK_GENERATOR
TGZ
ZIP
)
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0)
set(CPACK_INSTALL_CMAKE_PROJECTS
"${CMAKE_BINARY_DIR}"
"${PROJECT_NAME}"
ALL
.
)
set(CPACK_PROJECT_URL "https://github.com/gabime/spdlog")
set(CPACK_PACKAGE_VENDOR "Gabi Melman")
set(CPACK_PACKAGE_CONTACT "Gabi Melman <gmelman1@gmail.com>")
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
if (PROJECT_VERSION_TWEAK)
set(CPACK_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}.${PROJECT_VERSION_TWEAK})
endif ()
set(CPACK_PACKAGE_RELOCATABLE ON)
include(CPack)