Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

69 the packaging via cpack was gone #73

Merged
merged 2 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ jobs:
generator: MinGW Makefiles
- os: ubuntu-latest
generator: Visual Studio 17
- generator: MinGW Makefiles
cxx-std: 17
- generator: MinGW Makefiles
cxx-std: 20

name: ${{ matrix.os }} (C++${{ matrix.cxx-std }} - ${{ matrix.generator }})
runs-on: ${{ matrix.os }}
Expand Down
78 changes: 78 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,81 @@ if(DYLIB_BUILD_TESTS)
include(GoogleTest)
gtest_discover_tests(unit_tests PROPERTIES DISCOVERY_TIMEOUT 600 WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
endif()

set(CPACK_PACKAGE_NAME "dylib")
set(CPACK_PACKAGE_VENDOR "Martin Olivier")
set(CPACK_PACKAGE_VERSION_MAJOR "2")
set(CPACK_PACKAGE_VERSION_MINOR "1")
set(CPACK_PACKAGE_VERSION_PATCH "0")
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
set(CPACK_PACKAGE_DESCRIPTION "C++ cross-platform wrapper around dynamic loading of shared libraries")
set(CPACK_DEBIAN_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")
set(CPACK_RPM_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")

include(CPackComponent)
include(CMakePackageConfigHelpers)

set(PackagingTemplatesDir "${CMAKE_CURRENT_SOURCE_DIR}/packaging")

set(LIB_NAME "dylib")
string(TOUPPER "${LIB_NAME}" LIB_NAME_UPPER)
set(CMAKE_EXPORT_NAME "${LIB_NAME}")
set(PKG_CONFIG_NAME "${LIB_NAME}")

cpack_add_component(dev
DISPLAY_NAME "${LIB_NAME} header"
DESCRIPTION "The header needed for using ${LIB_NAME} in own software"
)

install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/${LIB_NAME}.hpp"
TYPE INCLUDE
COMPONENT "dev"
)

set(PKG_CONFIG_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/${PKG_CONFIG_NAME}.pc")
configure_file("${PackagingTemplatesDir}/pkgconfig.pc.in" "${PKG_CONFIG_FILE_NAME}" @ONLY)
install(FILES "${PKG_CONFIG_FILE_NAME}"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
COMPONENT "dev"
)

set(CMAKE_CONFIG_FILE_BASENAME "${CMAKE_EXPORT_NAME}Config.cmake")
set(CMAKE_CONFIG_VERSION_FILE_BASENAME "${CMAKE_EXPORT_NAME}ConfigVersion.cmake")
set(CMAKE_CONFIG_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CONFIG_FILE_BASENAME}")
configure_package_config_file("${PackagingTemplatesDir}/CMakeConfig.cmake.in" "${CMAKE_CONFIG_FILE_NAME}"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake"
)

set(CMAKE_CONFIG_VERSION_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CONFIG_VERSION_FILE_BASENAME}")
write_basic_package_version_file(
"${CMAKE_CONFIG_VERSION_FILE_NAME}"
VERSION "100500.100500.100500" # any version of same bitness suits. CMake cannot compare to infinity
COMPATIBILITY AnyNewerVersion
)

install(FILES "${CMAKE_CONFIG_FILE_NAME}" "${CMAKE_CONFIG_VERSION_FILE_NAME}"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_EXPORT_NAME}"
COMPONENT "dev"
)

set("CPACK_DEBIAN_DEV_PACKAGE_NAME" "lib${LIB_NAME}-dev")
set("CPACK_DEBIAN_DEV_PACKAGE_DEPENDS" "libc6-dev")
set("CPACK_DEBIAN_DEV_PACKAGE_SUGGESTS" "cmake, pkg-config, pkg-conf")

set("CPACK_RPM_DEV_PACKAGE_NAME" "lib${LIB_NAME}-devel")
set("CPACK_RPM_DEV_PACKAGE_SUGGESTS" "${CPACK_DEBIAN_DEV_PACKAGE_SUGGESTS}")

set(CPACK_COMPONENTS_ALL "dev")

set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/martin-olivier/dylib")
set(CPACK_PACKAGE_MAINTAINER "${CPACK_PACKAGE_VENDOR}")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${CPACK_PACKAGE_MAINTAINER}")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_PACKAGE_MAINTAINER "${CPACK_PACKAGE_VENDOR}")
set(CPACK_DEB_COMPONENT_INSTALL ON)
set(CPACK_RPM_COMPONENT_INSTALL ON)
set(CPACK_NSIS_COMPONENT_INSTALL ON)
set(CPACK_DEBIAN_COMPRESSION_TYPE "xz")

include(CPack)
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<h1 align="center">
Dylib
</h1>
dylib</h1>
<p align="center">
<a href="https://github.com/martin-olivier/dylib/releases/tag/v2.1.0">
<img src="https://img.shields.io/badge/Version-2.1.0-blue.svg" alt="version"/>
Expand Down
2 changes: 0 additions & 2 deletions _config.yml

This file was deleted.

7 changes: 7 additions & 0 deletions packaging/CMakeConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@PACKAGE_INIT@


message(STATUS "@[email protected]")
find_package(PkgConfig REQUIRED)
pkg_check_modules("@CMAKE_EXPORT_NAME@" "@PKG_CONFIG_NAME@")
check_required_components("@CMAKE_EXPORT_NAME@")
9 changes: 9 additions & 0 deletions packaging/pkgconfig.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
prefix=@CMAKE_INSTALL_PREFIX@
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@

Name: @PKG_CONFIG_NAME@
Description: @CPACK_PACKAGE_DESCRIPTION@
Version: @CPACK_PACKAGE_VERSION@
Libs: -L${libdir} -l@LIB_FILE_NAME@
Cflags: -I${includedir}
Loading