Skip to content
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
18 changes: 18 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ on:
doc:
type: boolean
default: false
pack:
type: boolean
default: false

workflow_dispatch:
inputs:
Expand Down Expand Up @@ -50,6 +53,9 @@ on:
doc:
type: boolean
default: false
pack:
type: boolean
default: false

jobs:
format:
Expand Down Expand Up @@ -139,6 +145,18 @@ jobs:
- name: Run tests (release)
run: ctest --preset ${{ matrix.compiler }}-release

- name: Package
if: inputs.pack && matrix.compiler == 'gcc' && matrix.arch == 'amd64'
working-directory: build/gcc/release
run: cpack

- name: Upload package to GitHub
if: inputs.pack && matrix.compiler == 'gcc' && matrix.arch == 'amd64'
uses: actions/upload-artifact@v7.0.0
with:
name: package
path: build/gcc/release/*.deb

- name: Configure (debug)
run: cmake --preset ${{ matrix.compiler }}-debug

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ jobs:
scan: true
coverage: true
doc: true
pack: true
59 changes: 59 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: release

on:
push:
tags:
- 'v*.*.*'

jobs:
version:
runs-on: ubuntu-latest

permissions:
contents: read

steps:
- name: Checkout
uses: actions/checkout@v6.0.2

- name: Check version
run: test "$GITHUB_REF_NAME" = "v$(cat VERSION)"

build:
needs: [version]

uses: ./.github/workflows/build.yml

permissions:
contents: read
security-events: write
pull-requests: write
pages: write
id-token: write

secrets: inherit

with:
scan: true
asan: true
pack: true

release:
needs: [build]

runs-on: ubuntu-latest

permissions:
contents: write

steps:
- name: Download packages from GitHub
uses: actions/download-artifact@v7.0.0
with:
name: package

- name: Create release
uses: softprops/action-gh-release@v2.4.1
with:
files: '*.deb'
generate_release_notes: true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
build*
Testing/
*version.hpp
*.cproject
*.project
*.settings
*.launch
*.vscode
*.cache
CMakeUserPresets.json
32 changes: 32 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" DCONV_VERSION_PATCH ${

message(STATUS "dconv version: ${DCONV_VERSION}")

include(GNUInstallDirs)

if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to Release as none was specified.")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose build type." FORCE)
Expand Down Expand Up @@ -68,3 +70,33 @@ endif()

add_subdirectory(dconv)
add_subdirectory(tools)

include(CMakePackageConfigHelpers)

install(EXPORT dconvTargets
NAMESPACE dconv::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
COMPONENT dev
)

configure_package_config_file(
${PROJECT_SOURCE_DIR}/cmake/dconvConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/dconvConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)

write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/dconvConfigVersion.cmake
VERSION ${DCONV_VERSION}
COMPATIBILITY SameMajorVersion
ARCH_INDEPENDENT
)

install(FILES
${CMAKE_CURRENT_BINARY_DIR}/dconvConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/dconvConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
COMPONENT dev
)

include(${PROJECT_SOURCE_DIR}/cmake/packaging.cmake)
5 changes: 5 additions & 0 deletions cmake/dconvConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/dconvTargets.cmake")

check_required_components(dconv)
23 changes: 23 additions & 0 deletions cmake/packaging.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
set(CPACK_GENERATOR "DEB")
set(CPACK_PACKAGE_NAME "lib${PROJECT_NAME}")
set(CPACK_PACKAGE_VERSION "${DCONV_VERSION}")
set(CPACK_PACKAGE_VERSION_MAJOR "${DCONV_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${DCONV_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${DCONV_VERSION_PATCH}")
set(CPACK_PACKAGE_CONTACT "Mathieu Rabine")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Header-only C++ library for printing and parsing floating point numbers")
set(CPACK_COMPONENT_DEV_DESCRIPTION
"dconv converts doubles to and from text, from a buffer or a stream.
This package contains the headers and CMake configuration.")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/joinframework/dconv")

set(CPACK_DEB_COMPONENT_INSTALL ON)
set(CPACK_COMPONENTS_ALL dev)
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")

set(CPACK_DEBIAN_DEV_PACKAGE_NAME "lib${PROJECT_NAME}-dev")
set(CPACK_DEBIAN_DEV_PACKAGE_SECTION "libdevel")
set(CPACK_DEBIAN_DEV_PACKAGE_ARCHITECTURE "all")

include(CPack)
16 changes: 10 additions & 6 deletions dconv/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
cmake_minimum_required(VERSION 3.22.1)

set(PUBLIC_HEADER_DIRS
include
)

set(PUBLIC_HEADERS
include/dconv/probe.hpp
include/dconv/diyfp.hpp
Expand All @@ -14,9 +10,17 @@ set(PUBLIC_HEADERS
)

add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(${PROJECT_NAME} INTERFACE ${PUBLIC_HEADER_DIRS})
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
target_include_directories(${PROJECT_NAME} INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_20)
set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADERS}")
install(TARGETS ${PROJECT_NAME} PUBLIC_HEADER DESTINATION include/dconv)
install(TARGETS ${PROJECT_NAME}
EXPORT dconvTargets
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dconv COMPONENT dev
)

if(DCONV_ENABLE_TESTS)
add_subdirectory(tests)
Expand Down
Loading