Commit b5f14ea0 authored by Michael Tesch's avatar Michael Tesch
Browse files

Add C++20 build support, bump to v0.7.0

parent c4a7cfa0
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ stages:
- test
- cover
- pages
- tag
- upload
- release

@@ -28,6 +29,17 @@ build:
  - if: $CI_PIPELINE_SOURCE == "merge_request_event"
  - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

# Build with C++17 to ensure backwards compatibility
build-cpp17:
  stage: build
  script:
  - dnf install -y gcc-c++ make cmake git
  - cmake -Bbuild -H. -DCMAKE_CXX_STANDARD=17 -DCMAKE_BUILD_TYPE=RelWithDebInfo
  - cmake --build build --target package
  rules:
  - if: $CI_PIPELINE_SOURCE == "merge_request_event"
  - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

# Manual pipeline - tests (triggered manually)
test:
  stage: test
@@ -85,6 +97,25 @@ pages:
    when: manual
    allow_failure: true

# Auto-tag when version in CMakeLists.txt is newer than latest git tag
auto-tag:
  stage: tag
  script:
  - dnf install -y git
  - VERSION=$(sed -n 's/.*VERSION \([0-9]*\.[0-9]*\.[0-9]*\).*/\1/p' CMakeLists.txt)
  - |
    if git ls-remote --tags origin "refs/tags/v${VERSION}" | grep -q .; then
      echo "Tag v${VERSION} already exists, skipping"
    else
      echo "Creating tag v${VERSION}"
      git tag "v${VERSION}"
      git push "https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git" "v${VERSION}"
    fi
  rules:
  - if: $CI_COMMIT_TAG
    when: never
  - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

variables:
  # Package version can only contain numbers (0-9), and dots (.).
  # Must be in the format of X.Y.Z, i.e. should match /\A\d+\.\d+\.\d+\z/ regular expresion.
+9 −13
Original line number Diff line number Diff line
@@ -54,27 +54,23 @@ Build output goes to `Build-clang/`, `Build-clangr/`, `Build-cc/`, `Build-ccr/`,

## Versioning and Releases

The version is defined in the top-level `CMakeLists.txt` (`project(cppduals VERSION X.Y.Z ...)`). GitLab CI (`.gitlab-ci.yml`) handles packaging and release creation automatically when a tag is pushed:
The version is defined in the top-level `CMakeLists.txt` (`project(cppduals VERSION X.Y.Z ...)`). GitLab CI (`.gitlab-ci.yml`) handles tagging, packaging, and release creation automatically:

- **upload** stage: creates a header-only tarball and publishes it to the GitLab package registry
- **release** stage: creates a GitLab release linked to the package
- **auto-tag** stage: when a commit lands on master, reads the version from `CMakeLists.txt` and creates a `vX.Y.Z` tag if it doesn't already exist
- **upload** stage: on tag push, creates a header-only tarball and publishes it to the GitLab package registry
- **release** stage: on tag push, creates a GitLab release linked to the package

To cut a new release:
To cut a new release, just bump the version in `CMakeLists.txt` and merge to master — CI does the rest:

```bash
# 1. Update the VERSION in CMakeLists.txt
#    project(cppduals VERSION 0.6.4 ...)
#    project(cppduals VERSION 0.7.1 ...)

# 2. Commit the version bump
git commit -am "Bump version to 0.6.4"

# 3. Tag and push — CI does the rest
git tag v0.6.4
git push origin master --tags
# 2. Commit and merge to master — CI auto-tags and releases
git commit -am "Bump version to 0.7.1"
git push origin master
```

The tag name must match the format `vX.Y.Z` (e.g. `v0.6.4`). CI uses `$CI_COMMIT_TAG` to derive the package version.

## Code Conventions

- Comment WHY, not WHAT.
+3 −4
Original line number Diff line number Diff line
@@ -3,13 +3,13 @@
#
cmake_minimum_required (VERSION 3.14)
project (cppduals
  VERSION 0.6.3
  VERSION 0.7.0
  LANGUAGES C CXX
  )
include (GNUInstallDirs)

if (NOT CMAKE_CXX_STANDARD)
  set (CMAKE_CXX_STANDARD 17 CACHE STRING "Which C++ standard to test against.")
  set (CMAKE_CXX_STANDARD 20 CACHE STRING "Which C++ standard to test against.")
endif()
message (STATUS "CXX_STANDARD: ${CMAKE_CXX_STANDARD}")
set (CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -41,8 +41,7 @@ if (CPPDUALS_STANDALONE AND
  message (STATUS "No install prefix specified; using '${CMAKE_INSTALL_PREFIX}'")
endif ()

#set_property (CACHE CMAKE_CXX_STANDARD PROPERTY STRINGS 11 14 17 20)
set_property (CACHE CMAKE_CXX_STANDARD PROPERTY STRINGS 20)
set_property (CACHE CMAKE_CXX_STANDARD PROPERTY STRINGS 17 20)

option (CPPDUALS_TESTING "Enable testing" OFF)
option (CPPDUALS_BENCHMARK "Enable benchmarking" OFF)
+10 −2
Original line number Diff line number Diff line
cppduals
========

Header-only dual number library for C++11.  The `dual<>` type can be
Header-only dual number library for C++17/C++20.  The `dual<>` type can be
used for automatic (forward) differentiation.  It can be used in
conjunction with Eigen to produced very fast vectorized computations
of real and complex matrix functions and their derivatives.
of real and complex matrix functions and their derivatives.  The last
version to support C++11/C++14 was v0.6.3.

There is a small paper on cppduals here:
[![DOI](https://joss.theoj.org/papers/10.21105/joss.01487/status.svg)](https://doi.org/10.21105/joss.01487)
@@ -280,6 +281,13 @@ thus licensed under [MPL-2](http://www.mozilla.org/MPL/2.0/FAQ.html) .
ChangeLog
=========

v0.7.0
======

- default to C++20, support C++17 and C++20.
- remove C++11/C++14 compatibility code.
- CI: add C++17 build job to ensure backwards compatibility.

v0.6.0
======

+3 −8
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@
#define CPPDUALS_DUAL

#ifndef PARSED_BY_DOXYGEN
#define _DUALS_CONSTEXPR constexpr

///// FOR LIBCPP /////
#include <cstddef>
@@ -37,8 +36,8 @@ _LIBCPP_END_NAMESPACE_STD
#endif // PARSED_BY_DOXYGEN

#if !defined(CPPDUALS_IGNORE_COMPILER_VERSION) && !defined(_WIN32)
#if __cplusplus < 201103L
  #error CPPDUALS needs at least a C++11 compliant compiler
#if __cplusplus < 201703L
  #error CPPDUALS needs at least a C++17 compliant compiler
#endif
#endif

@@ -370,12 +369,10 @@ template <class T> struct dual_traits<std::complex<dual<T>>>

namespace detail {

template<class T>
struct Void { typedef void type; };
template<class T, class U = void>
struct has_member_type : std::false_type {};
template<class T>
struct has_member_type<T, typename Void<typename T::type>::type > : std::true_type {
struct has_member_type<T, std::void_t<typename T::type>> : std::true_type {
  struct wrap {
    typedef typename T::type type;
    typedef typename T::type ReturnType;
@@ -948,7 +945,6 @@ template <typename T> int sgn(T val) {
template<class T> dual<T> log1p(const dual<T> & x) {return detail::log1p_impl(x);}
template<class T> dual<T> expm1(const dual<T> & x) {return detail::expm1_impl(x);}

#if __cpp_user_defined_literals >= 200809
/// Dual number literals in namespace duals::literals
inline namespace literals
{
@@ -978,7 +974,6 @@ constexpr dual<long double> operator""_el(unsigned long long du)
  return { 0.0l, static_cast<long double>(du) };
}
} // namespace literals
#endif

// shortcut type names
typedef dual<float> dualf;
Loading