Skip to content

Commit

Permalink
Merge pull request #304 from bluescarni/pr/new_version_number
Browse files Browse the repository at this point in the history
Bump to 1.0.0, semantic versioning
  • Loading branch information
bluescarni authored Nov 25, 2023
2 parents 7bf0d70 + 176a929 commit 6434a2d
Show file tree
Hide file tree
Showing 48 changed files with 176 additions and 129 deletions.
20 changes: 10 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ if(NOT CMAKE_BUILD_TYPE)
FORCE)
endif()

project(mp++ VERSION 0.27 LANGUAGES CXX C)
project(mp++ VERSION 1.0.0 LANGUAGES CXX C)

# Setup the mp++ ABI version number.
set(MPPP_ABI_VERSION 15)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/yacma")

Expand Down Expand Up @@ -277,8 +280,8 @@ if(MPPP_BUILD_STATIC_LIBRARY)
else()
# Setup of the mp++ shared library.
add_library(mp++ SHARED "${MPPP_SRC_FILES}")
set_property(TARGET mp++ PROPERTY VERSION "14.0")
set_property(TARGET mp++ PROPERTY SOVERSION 14)
set_property(TARGET mp++ PROPERTY VERSION "${MPPP_ABI_VERSION}.0")
set_property(TARGET mp++ PROPERTY SOVERSION ${MPPP_ABI_VERSION})
set_property(TARGET mp++ PROPERTY DEFINE_SYMBOL "mppp_EXPORTS")
set_target_properties(mp++ PROPERTIES CXX_VISIBILITY_PRESET hidden)
set_target_properties(mp++ PROPERTIES VISIBILITY_INLINES_HIDDEN TRUE)
Expand Down Expand Up @@ -455,13 +458,10 @@ install(FILES
install(EXPORT mp++_export NAMESPACE mp++:: DESTINATION "${MPPP_INSTALL_LIBDIR}/cmake/mp++")
# Take care of versioning.
include(CMakePackageConfigHelpers)
# NOTE: SameMinorVersion available only
# since CMake 3.11.
if(${CMAKE_VERSION} VERSION_LESS "3.11.0")
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/mp++-config-version.cmake" COMPATIBILITY SameMajorVersion)
else()
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/mp++-config-version.cmake" COMPATIBILITY SameMinorVersion)
endif()
# NOTE: since we use semantic versioning, the correct setting here is SameMajorVersion: it requires equality
# in the major version, but higher minor versions will be considered compatible. So, if mp++ 2.0.0 is requested
# and 2.1.0 is found, then all is good. However, the reverse will lead to a failure.
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/mp++-config-version.cmake" COMPATIBILITY SameMajorVersion)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/mp++-config-version.cmake" DESTINATION "${MPPP_INSTALL_LIBDIR}/cmake/mp++")

# This is just a simple counter variable, internal use only.
Expand Down
27 changes: 27 additions & 0 deletions config.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#define MPPP_VERSION_STRING "@mp++_VERSION@"
#define MPPP_VERSION_MAJOR @mp++_VERSION_MAJOR@
#define MPPP_VERSION_MINOR @mp++_VERSION_MINOR@
#define MPPP_VERSION_PATCH @mp++_VERSION_PATCH@
#define MPPP_ABI_VERSION @MPPP_ABI_VERSION@
#cmakedefine MPPP_GMP_HAVE_MPN_DIVEXACT_1
@MPPP_ENABLE_MPFR@
#cmakedefine MPPP_MPFR_HAVE_MPFR_GET_Q
Expand All @@ -35,6 +37,31 @@
// clang-format on
// End of defines instantiated by CMake.

// Setup of the ABI versioning and tagging
// machinery.

#if defined(__GNUC__) || defined(__clang__)

#define MPPP_ABI_TAG_ATTR __attribute__((abi_tag))

#else

#define MPPP_ABI_TAG_ATTR

#endif

// clang-format off
#define MPPP_BEGIN_NAMESPACE \
namespace mppp \
{ \
inline namespace v@MPPP_ABI_VERSION@ MPPP_ABI_TAG_ATTR \
{

#define MPPP_END_NAMESPACE \
} \
}
// clang-format on

// Compiler configuration.

#if defined(__clang__) || defined(__GNUC__) || defined(__INTEL_COMPILER)
Expand Down
7 changes: 7 additions & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ Changelog
1.0.0 (unreleased)
------------------

New
~~~

- mp++'s ABI is now versioned
(`#304 <https://github.com/bluescarni/mppp/pull/304>`__).
- mp++ now uses semantic versioning.

Fix
~~~

Expand Down
13 changes: 10 additions & 3 deletions doc/definitions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,24 @@ Macros and definitions
.. c:macro:: MPPP_VERSION_STRING
This definition expands to a string literal containing the full version of the mp++ library
(e.g., for version 0.6 this macro expands to ``"0.6"``).
(e.g., for version 1.2.3 this macro expands to ``"1.2.3"``).

.. c:macro:: MPPP_VERSION_MAJOR
This definition expands to an integral literal corresponding to the major mp++ version (e.g.,
for version 0.6, this macro expands to ``0``).
for version 1.2.3, this macro expands to ``1``).

.. c:macro:: MPPP_VERSION_MINOR
This definition expands to an integral literal corresponding to the minor mp++ version (e.g.,
for version 0.6, this macro expands to ``6``).
for version 1.2.3, this macro expands to ``2``).

.. c:macro:: MPPP_VERSION_PATCH
.. versionadded:: 1.0.0

This definition expands to an integral literal corresponding to the patch mp++ version (e.g.,
for version 1.2.3, this macro expands to ``3``).

.. c:macro:: MPPP_WITH_QUADMATH
Expand Down
2 changes: 1 addition & 1 deletion doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ at `this link <https://doi.org/10.5281/zenodo.1043579>`__.
not yet available in mp++'s stable releases.

.. toctree::
:maxdepth: 2
:maxdepth: 1

installation.rst
tutorial.rst
Expand Down
1 change: 1 addition & 0 deletions doc/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Before perusing the C++ reference, users are encouraged to first go through the
.. toctree::
:maxdepth: 1

versioning.rst
definitions.rst
namespaces.rst
exceptions.rst
Expand Down
6 changes: 6 additions & 0 deletions doc/versioning.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Versioning
==========

Beginning with version 1.0.0, mp++ adopts `semantic versioning <https://semver.org/>`__.

ABI compatibility is guaranteed only between patch versions.
10 changes: 4 additions & 6 deletions include/mp++/complex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@

#endif

namespace mppp
{
MPPP_BEGIN_NAMESPACE

// Detect real-valued interoperable types
// for complex.
Expand Down Expand Up @@ -3199,7 +3198,7 @@ inline rational<SSize> &rational<SSize>::operator=(const complex &c)
return *this = static_cast<rational<SSize>>(c);
}

} // namespace mppp
MPPP_END_NAMESPACE

#if defined(MPPP_WITH_BOOST_S11N)

Expand Down Expand Up @@ -3229,8 +3228,7 @@ struct formatter<mppp::complex> : mppp::detail::to_string_formatter {

#include <nlohmann/json.hpp>

namespace mppp
{
MPPP_BEGIN_NAMESPACE

inline nlohmann::json mime_bundle_repr(const complex &c)
{
Expand All @@ -3241,7 +3239,7 @@ inline nlohmann::json mime_bundle_repr(const complex &c)
return bundle;
}

} // namespace mppp
MPPP_END_NAMESPACE

#endif

Expand Down
10 changes: 4 additions & 6 deletions include/mp++/complex128.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@

#endif

namespace mppp
{
MPPP_BEGIN_NAMESPACE

// Re-define in the mppp namespace the __complex128 type
// (using another name). This allows us to avoid having
Expand Down Expand Up @@ -1310,7 +1309,7 @@ inline MPPP_CONSTEXPR_14 real128 &real128::operator=(const complex128 &x)
return *this = static_cast<real128>(x);
}

} // namespace mppp
MPPP_END_NAMESPACE

#if defined(MPPP_WITH_BOOST_S11N)

Expand Down Expand Up @@ -1340,8 +1339,7 @@ struct formatter<mppp::complex128> : mppp::detail::to_string_formatter {

#include <nlohmann/json.hpp>

namespace mppp
{
MPPP_BEGIN_NAMESPACE

inline nlohmann::json mime_bundle_repr(const complex128 &c)
{
Expand All @@ -1352,7 +1350,7 @@ inline nlohmann::json mime_bundle_repr(const complex128 &c)
return bundle;
}

} // namespace mppp
MPPP_END_NAMESPACE

#endif

Expand Down
5 changes: 2 additions & 3 deletions include/mp++/concepts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@

#include <mp++/detail/type_traits.hpp>

namespace mppp
{
MPPP_BEGIN_NAMESPACE

// Type trait to check if T is a C++ integral type, including possibly __(u)int128_t.
// NOTE: mppp::detail::is_integral, for consistency with std::is_integral, will be true also for cv qualified
Expand Down Expand Up @@ -122,6 +121,6 @@ MPPP_CONCEPT_DECL string_type = is_string_type<T>::value;

#endif

} // namespace mppp
MPPP_END_NAMESPACE

#endif
5 changes: 2 additions & 3 deletions include/mp++/detail/fmt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@

#include <mp++/config.hpp>

namespace mppp
{
MPPP_BEGIN_NAMESPACE

namespace detail
{
Expand Down Expand Up @@ -56,6 +55,6 @@ struct to_string_formatter {

} // namespace detail

} // namespace mppp
MPPP_END_NAMESPACE

#endif
8 changes: 5 additions & 3 deletions include/mp++/detail/gmp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@

#include <gmp.h>

#include <mp++/config.hpp>

#if __GNU_MP_VERSION < 5

#error Minimum supported GMP version is 5.

#endif

namespace mppp
{
MPPP_BEGIN_NAMESPACE

namespace detail
{
Expand Down Expand Up @@ -98,6 +99,7 @@ struct mpf_raii {
mpf_struct_t m_mpf;
};
} // namespace detail
} // namespace mppp

MPPP_END_NAMESPACE

#endif
5 changes: 2 additions & 3 deletions include/mp++/detail/integer_literals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
#include <mp++/detail/gmp.hpp>
#include <mp++/detail/utils.hpp>

namespace mppp
{
MPPP_BEGIN_NAMESPACE

namespace detail
{
Expand Down Expand Up @@ -416,6 +415,6 @@ MPPP_DECLARE_INTEGRAL_UDL(3)

} // namespace literals

} // namespace mppp
MPPP_END_NAMESPACE

#endif
7 changes: 4 additions & 3 deletions include/mp++/detail/mpc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@

#include <mpc.h>

namespace mppp
{
#include <mp++/config.hpp>

MPPP_BEGIN_NAMESPACE

// The MPC structure underlying mpc_t.
using mpc_struct_t = std::remove_extent<::mpc_t>::type;

} // namespace mppp
MPPP_END_NAMESPACE

#endif
7 changes: 4 additions & 3 deletions include/mp++/detail/mpfr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

#include <mpfr.h>

#include <mp++/config.hpp>

#if MPFR_VERSION_MAJOR < 3

#error Minimum supported MPFR version is 3.
Expand All @@ -28,8 +30,7 @@

#endif

namespace mppp
{
MPPP_BEGIN_NAMESPACE

// Minimum precision for a real.
constexpr ::mpfr_prec_t real_prec_min()
Expand Down Expand Up @@ -82,6 +83,6 @@ struct mpfr_raii {

} // namespace detail

} // namespace mppp
MPPP_END_NAMESPACE

#endif
7 changes: 4 additions & 3 deletions include/mp++/detail/parse_complex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@

#include <array>

namespace mppp
{
#include <mp++/config.hpp>

MPPP_BEGIN_NAMESPACE

namespace detail
{
Expand All @@ -21,6 +22,6 @@ std::array<const char *, 4> parse_complex(const char *);

} // namespace detail

} // namespace mppp
MPPP_END_NAMESPACE

#endif
5 changes: 2 additions & 3 deletions include/mp++/detail/rational_literals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@

#include <mp++/integer.hpp>

namespace mppp
{
MPPP_BEGIN_NAMESPACE

inline namespace literals
{
Expand All @@ -32,6 +31,6 @@ MPPP_DECLARE_RATIONAL_UDL(3)

} // namespace literals

} // namespace mppp
MPPP_END_NAMESPACE

#endif
Loading

0 comments on commit 6434a2d

Please sign in to comment.