Merge pull request #524 from Balluff/feature/cpack

Feature/cpack
This commit is contained in:
Leonid Stryzhevskyi 2021-12-03 01:46:41 +02:00 committed by GitHub
commit ee61f12ba7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 112 additions and 7 deletions

View File

@ -121,3 +121,9 @@ if(OATPP_BUILD_TESTS)
enable_testing()
add_subdirectory(test)
endif()
include(cpack.cmake)
# This must always be last!
include( CPack )

View File

@ -57,16 +57,25 @@ endforeach()
#######################################################################################
install(TARGETS ${OATPP_THIS_MODULE_TARGETS}
EXPORT "${OATPP_MODULE_NAME}Targets"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/oatpp-${OATPP_MODULE_VERSION}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/oatpp-${OATPP_MODULE_VERSION}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/oatpp-${OATPP_MODULE_VERSION}"
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/oatpp-${OATPP_MODULE_VERSION}/${OATPP_MODULE_NAME}"
install(
TARGETS ${OATPP_THIS_MODULE_TARGETS}
EXPORT "${OATPP_MODULE_NAME}Targets"
ARCHIVE
DESTINATION "${CMAKE_INSTALL_LIBDIR}/oatpp-${OATPP_MODULE_VERSION}"
COMPONENT Devel
LIBRARY
DESTINATION "${CMAKE_INSTALL_LIBDIR}/oatpp-${OATPP_MODULE_VERSION}"
COMPONENT Library
RUNTIME
DESTINATION "${CMAKE_INSTALL_BINDIR}/oatpp-${OATPP_MODULE_VERSION}"
COMPONENT Library
INCLUDES
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/oatpp-${OATPP_MODULE_VERSION}/${OATPP_MODULE_NAME}"
)
install(DIRECTORY ${OATPP_DIRS_TO_INSTALL}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/oatpp-${OATPP_MODULE_VERSION}/${OATPP_MODULE_NAME}"
COMPONENT Devel
FILES_MATCHING PATTERN "*.hpp"
)
@ -74,6 +83,7 @@ install(EXPORT "${OATPP_MODULE_NAME}Targets"
FILE "${OATPP_MODULE_NAME}Targets.cmake"
NAMESPACE oatpp::
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${OATPP_MODULE_NAME}-${OATPP_MODULE_VERSION}"
COMPONENT Devel
)
include(CMakePackageConfigHelpers)
@ -104,4 +114,5 @@ install(
"${CMAKE_CURRENT_BINARY_DIR}/${OATPP_MODULE_NAME}ConfigVersion.cmake"
DESTINATION
"${CMAKE_INSTALL_LIBDIR}/cmake/${OATPP_MODULE_NAME}-${OATPP_MODULE_VERSION}"
)
COMPONENT Devel
)

88
cpack.cmake Normal file
View File

@ -0,0 +1,88 @@
#
# Packaging
# https://cmake.org/cmake/help/latest/module/CPack.html
#
set( CPACK_PACKAGE_NAME ${PROJECT_NAME} )
set( CPACK_PACKAGE_VENDOR "Balluff" )
set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "oatpp - Light and powerful C++ web framework" )
set( CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/oatpp/oatpp" )
set( CPACK_PACKAGE_CONTACT "https://github.com/oatpp/oatpp" )
set( CPACK_PACKAGE_VERSION ${OATPP_THIS_MODULE_VERSION} )
set( CPACK_PACKAGE_INSTALL_DIRECTORY ${PROJECT_NAME} )
get_filename_component( oatpp_root_dir ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY )
set( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE" )
set( CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md" )
set( CPACK_COMPONENT_Library_DISPLAY_NAME "oatpp Library" )
set( CPACK_COMPONENT_Library_DESCRIPTION "The oatpp binary library." )
set( CPACK_COMPONENT_Library_REQUIRED 1 )
set( CPACK_COMPONENT_Devel_DISPLAY_NAME "oatpp Development Files" )
set( CPACK_COMPONENT_Devel_DESCRIPTION "Development files for compiling against oatpp." )
set( CPACK_COMPONENT_Devel_REQUIRED 0 )
if( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" )
if ( "${CPACK_PACKAGE_ARCHITECTURE}" STREQUAL "" )
# Note: the architecture should default to the local architecture, but it
# in fact comes up empty. We call `uname -m` to ask the kernel instead.
EXECUTE_PROCESS( COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE CPACK_PACKAGE_ARCHITECTURE )
endif()
set( CPACK_INCLUDE_TOPLEVEL_DIRECTORY 1 )
set( CPACK_PACKAGE_RELEASE 1 )
# RPM - https://cmake.org/cmake/help/latest/cpack_gen/rpm.html
set( CPACK_RPM_PACKAGE_RELEASE ${CPACK_PACKAGE_RELEASE} )
set( CPACK_RPM_PACKAGE_ARCHITECTURE ${CPACK_PACKAGE_ARCHITECTURE} )
set( CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY} )
set( CPACK_RPM_PACKAGE_URL ${CPACK_PACKAGE_HOMEPAGE_URL} )
set( CPACK_RPM_PACKAGE_LICENSE "APACHE-2" )
set( CPACK_RPM_COMPONENT_INSTALL 1 )
set( CPACK_RPM_MAIN_COMPONENT "Library" )
set( CPACK_RPM_COMPRESSION_TYPE "xz" )
set( CPACK_RPM_PACKAGE_AUTOPROV 1 )
set( CPACK_RPM_PACKAGE_NAME "${CPACK_PACKAGE_NAME}" )
set( CPACK_RPM_FILE_NAME "RPM-DEFAULT" )
set( CPACK_RPM_Library_PACKAGE_ARCHITECTURE ${CPACK_PACKAGE_ARCHITECTURE} )
set( CPACK_RPM_Library_PACKAGE_NAME ${CPACK_PACKAGE_NAME} )
set( CPACK_RPM_Library_FILE_NAME
"${CPACK_RPM_Library_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}.${CPACK_RPM_Library_PACKAGE_ARCHITECTURE}.rpm" )
set( CPACK_RPM_Library_PACKAGE_SUMMARY ${CPACK_COMPONENT_Library_DESCRIPTION} )
set( CPACK_RPM_Devel_PACKAGE_REQUIRES "cmake >= ${CMAKE_MINIMUM_REQUIRED_VERSION},oatpp >= ${CPACK_PACKAGE_VERSION}" )
set( CPACK_RPM_Devel_PACKAGE_SUMMARY ${CPACK_COMPONENT_Devel_DESCRIPTION} )
set( CPACK_RPM_Devel_PACKAGE_ARCHITECTURE "noarch" ) # only contains headers and cmake files
set( CPACK_RPM_Devel_PACKAGE_NAME "${CPACK_PACKAGE_NAME}-devel" )
set( CPACK_RPM_Devel_FILE_NAME
"${CPACK_RPM_Devel_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}.${CPACK_RPM_Devel_PACKAGE_ARCHITECTURE}.rpm" )
# DEB - https://cmake.org/cmake/help/latest/cpack_gen/deb.html
set( CPACK_DEBIAN_PACKAGE_NAME "${CPACK_PACKAGE_NAME}-dev" )
set( CPACK_DEBIAN_PACKAGE_RELEASE ${CPACK_PACKAGE_RELEASE} )
set( CPACK_DEBIAN_PACKAGE_HOMEPAGE ${CPACK_PACKAGE_HOMEPAGE_URL} )
set( CPACK_DEB_COMPONENT_INSTALL 1 )
set( CPACK_DEBIAN_COMPRESSION_TYPE "xz")
if ( ${CPACK_PACKAGE_ARCHITECTURE} STREQUAL "x86_64" )
set( CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64" ) # DEB doesn't always use the kernel's arch name
else()
set( CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${CPACK_PACKAGE_ARCHITECTURE} )
endif()
set( CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT" ) # Use default naming scheme
set( CPACK_DEBIAN_LIBRARY_PACKAGE_NAME ${CPACK_PACKAGE_NAME} )
set( CPACK_DEBIAN_LIBRARY_PACKAGE_SHLIBDEPS 1 )
set( CPACK_DEBIAN_DEVEL_PACKAGE_DEPENDS "cmake (>= ${CMAKE_MINIMUM_REQUIRED_VERSION}), oatpp (>= ${CPACK_PACKAGE_VERSION})" )
set( CPACK_DEBIAN_DEVEL_PACKAGE_NAME "${CPACK_PACKAGE_NAME}-dev" )
elseif( ${CMAKE_HOST_WIN32} )
set( CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON )
set( CPACK_NSIS_DISPLAY_NAME ${PROJECT_NAME} )
set( CPACK_NSIS_PACKAGE_NAME ${PROJECT_NAME} )
set( CPACK_NSIS_URL_INFO_ABOUT ${CPACK_PACKAGE_HOMEPAGE_URL} )
endif()