Skip to content

Commit

Permalink
Merge pull request #314 from bluescarni/pr/boost_cmake_update
Browse files Browse the repository at this point in the history
Update the CMake code for locating Boost
  • Loading branch information
bluescarni authored Jul 21, 2024
2 parents cf49ca2 + 4dc6481 commit afc2aa4
Show file tree
Hide file tree
Showing 21 changed files with 78 additions and 37 deletions.
29 changes: 17 additions & 12 deletions .github/workflows/gh_actions_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,55 +7,60 @@ on:
branches:
- master
jobs:
osx_11:
runs-on: macos-11
osx_13_x86:
runs-on: macos-13
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Build
run: bash tools/gha_osx.sh
osx_14_arm64:
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- name: Build
run: bash tools/gha_osx.sh
conda_asan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Build
run: bash tools/gha_conda_asan.sh
conda_ubsan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Build
run: bash tools/gha_conda_ubsan.sh
conda_tsan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Build
run: bash tools/gha_conda_tsan.sh
conda_debuggmp:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Build
run: bash tools/gha_debuggmp.sh
windows_2022:
runs-on: windows-2022
steps:
- uses: actions/checkout@v3
- name: Add msbuild to PATH
uses: microsoft/[email protected]
- uses: conda-incubator/setup-miniconda@v2
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: "3.10"
channels: conda-forge
channel-priority: strict
- uses: ilammy/msvc-dev-cmd@v1
- name: Build
shell: pwsh
run: |
conda install -y cmake mpir mpfr 'libflint<3' arb mpc fmt libboost-devel
mkdir build
cd build
cmake ../ -G "Visual Studio 17 2022" -A x64 -DCMAKE_CXX_STANDARD=20 -DMPPP_GMP_INCLUDE_DIR=C:\Miniconda\envs\test\Library\include -DMPPP_GMP_LIBRARY=C:\Miniconda\envs\test\Library\lib\mpir.lib -DMPPP_BUILD_TESTS=yes -DBoost_NO_BOOST_CMAKE=yes -DMPPP_WITH_BOOST_S11N=yes -DMPPP_WITH_FMT=yes -DMPPP_WITH_MPFR=yes -DMPPP_WITH_MPC=yes -DMPPP_WITH_ARB=yes -DMPPP_ENABLE_IPO=yes
cmake ../ -G "Visual Studio 17 2022" -A x64 -DCMAKE_CXX_STANDARD=20 -DMPPP_BUILD_TESTS=yes -DMPPP_WITH_BOOST_S11N=yes -DMPPP_WITH_FMT=yes -DMPPP_WITH_MPFR=yes -DMPPP_WITH_MPC=yes -DMPPP_WITH_ARB=yes -DMPPP_ENABLE_IPO=yes
cmake --build . --config Release -j2
copy Release\mp++.dll test\Release\
ctest -j4 -V -C Release
Expand Down
15 changes: 13 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if(NOT CMAKE_BUILD_TYPE)
FORCE)
endif()

project(mp++ VERSION 1.0.2 LANGUAGES CXX C)
project(mp++ VERSION 1.0.3 LANGUAGES CXX C)

# Setup the mp++ ABI version number.
set(MPPP_ABI_VERSION 15)
Expand Down Expand Up @@ -411,7 +411,18 @@ endif()
# Optional dependency on Boost s11n.
set(_MPPP_MIN_BOOST_VERSION "1.60")
if(MPPP_WITH_BOOST_S11N)
find_package(Boost ${_MPPP_MIN_BOOST_VERSION} REQUIRED COMPONENTS serialization)
# NOTE: we look for Boost in CONFIG mode first, as that has become the official supported way
# of locating Boost in recent Boost/CMake versions. If we fail, we try again in
# MODULE mode as last resort.
find_package(Boost ${_MPPP_MIN_BOOST_VERSION} QUIET COMPONENTS serialization CONFIG)
if(NOT ${Boost_FOUND})
message(STATUS "Boost not found in CONFIG mode, retrying in MODULE mode.")
find_package(Boost ${_MPPP_MIN_BOOST_VERSION} QUIET MODULE COMPONENTS serialization)
endif()
if(NOT ${Boost_FOUND})
message(FATAL_ERROR "Could not locate Boost in either CONFIG or MODULE mode.")
endif()
message(STATUS "Found Boost version ${Boost_VERSION}.")
target_link_libraries(mp++ PUBLIC Boost::serialization Boost::disable_autolinking)
endif()

Expand Down
10 changes: 8 additions & 2 deletions cmake/yacma/YACMACompilerLinkerSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ if(NOT _YACMACompilerLinkerSettingsRun)
# Configuration bits specific for GCC.
if(YACMA_COMPILER_IS_GNUCXX)
_YACMA_CHECK_ENABLE_CXX_FLAG(-fdiagnostics-color=auto)
_YACMA_CHECK_ENABLE_CXX_FLAG(-Woverloaded-virtual)
# New in GCC 9.
_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Waddress-of-packed-member)
endif()
Expand Down Expand Up @@ -109,7 +110,6 @@ if(NOT _YACMACompilerLinkerSettingsRun)
_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wc99-designator)
_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wreorder-init-list)
_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wsizeof-pointer-div)
_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wsizeof-array-div)
_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wxor-used-as-pow)
_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wfinal-dtor-non-final-class)
# New warnings in clang 11.
Expand All @@ -122,13 +122,19 @@ if(NOT _YACMACompilerLinkerSettingsRun)
# NOTE: this is a new flag in Clang 13 which seems to give
# incorrect warnings for UDLs.
_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wno-reserved-identifier)
_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Warray-bounds-pointer-arithmetic)
# New warnings in clang 14.
_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Warray-parameter)
endif()

# Common configuration for GCC, clang and Intel.
if(YACMA_COMPILER_IS_CLANGXX OR YACMA_COMPILER_IS_INTELXX OR YACMA_COMPILER_IS_GNUCXX)
_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wall)
_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wextra)
_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wnon-virtual-dtor)
# NOTE: this flag has been superseded by "-Wdelete-non-virtual-dtor"
# (enabled by "-Wall"). See:
# https://gcc.gnu.org/pipermail/gcc-cvs/2022-November/374730.html
# _YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wnon-virtual-dtor)
# NOTE: this flag is a bit too chatty, let's disable it for the moment.
#_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wnoexcept)
_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wlogical-op)
Expand Down
14 changes: 14 additions & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
Changelog
=========

1.0.3 (unreleased)
------------------

Fix
~~~

- Fix compilation failure with fmt 11
(`#314 <https://github.com/bluescarni/mppp/pull/314>`__).
- Fix warnings in the build system when using recent
versions of Boost/CMake
(`#314 <https://github.com/bluescarni/mppp/pull/314>`__).
- Fix compiler warnings on recent MSVC versions
(`#314 <https://github.com/bluescarni/mppp/pull/314>`__).

1.0.2 (2023-12-22)
------------------

Expand Down
2 changes: 1 addition & 1 deletion include/mp++/complex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3169,7 +3169,7 @@ inline namespace literals

#define MPPP_DECLARE_COMPLEX_UDL(prec) \
template <char... Chars> \
inline complex operator"" _icr##prec() \
inline complex operator""_icr##prec() \
{ \
return complex{real{real_kind::zero, prec}, detail::real_literal_impl<Chars...>(prec)}; \
}
Expand Down
8 changes: 6 additions & 2 deletions include/mp++/detail/fmt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,18 @@ struct to_string_formatter {
}

// LCOV_EXCL_START
#if FMT_VERSION < 100000

// NOTE: strangely enough, fmt::throw_format_error() was promoted
// to the public API in fmt 10 and then promptly deprecated.
#if FMT_VERSION < 100000 || FMT_VERSION >= 110000
throw std::invalid_argument("Invalid format");
#else
fmt::throw_format_error("Invalid format");
#endif
// LCOV_EXCL_STOP

return it;

// LCOV_EXCL_STOP
}

template <typename T, typename FormatContext>
Expand Down
2 changes: 1 addition & 1 deletion include/mp++/detail/integer_literals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ inline namespace literals

#define MPPP_DECLARE_INTEGRAL_UDL(n) \
template <char... Chars> \
inline integer<n> operator"" _z##n() \
inline integer<n> operator""_z##n() \
{ \
return detail::integer_literal_impl<n, Chars...>(); \
}
Expand Down
2 changes: 1 addition & 1 deletion include/mp++/detail/rational_literals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ inline namespace literals

#define MPPP_DECLARE_RATIONAL_UDL(n) \
template <char... Chars> \
inline rational<n> operator"" _q##n() \
inline rational<n> operator""_q##n() \
{ \
return rational<n>{detail::integer_literal_impl<n, Chars...>()}; \
}
Expand Down
2 changes: 1 addition & 1 deletion include/mp++/detail/real_literals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ inline namespace literals

#define MPPP_DECLARE_REAL_UDL(prec) \
template <char... Chars> \
inline real operator"" _r##prec() \
inline real operator""_r##prec() \
{ \
return detail::real_literal_impl<Chars...>(prec); \
}
Expand Down
8 changes: 4 additions & 4 deletions include/mp++/integer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,14 +423,14 @@ constexpr int integral_sign(T n)
// On compilers other than MSVC, this just returns the input value.
template <typename T>
inline auto make_uai(T *ptr) ->
#if defined(_MSC_VER)
#if defined(_MSC_VER) && _MSC_VER < 1930
decltype(stdext::make_unchecked_array_iterator(ptr))
#else
decltype(ptr)
#endif
{
return
#if defined(_MSC_VER)
#if defined(_MSC_VER) && _MSC_VER < 1930
stdext::make_unchecked_array_iterator(ptr);
#else
ptr;
Expand Down Expand Up @@ -1357,8 +1357,8 @@ class integer
: integer(c.imag() == 0
? c.real()
: throw std::domain_error(
"Cannot construct an integer from a complex C++ value with a non-zero imaginary part of "
+ detail::to_string(c.imag())))
"Cannot construct an integer from a complex C++ value with a non-zero imaginary part of "
+ detail::to_string(c.imag())))
{
}

Expand Down
11 changes: 10 additions & 1 deletion mp++-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,16 @@ endif()
set(mp++_WITH_MPC @MPPP_WITH_MPC@)

if(@MPPP_WITH_BOOST_S11N@)
find_package(Boost @_MPPP_MIN_BOOST_VERSION@ REQUIRED COMPONENTS serialization)
# NOTE: we look for Boost in CONFIG mode first, as that has become the official supported way
# of locating Boost in recent Boost/CMake versions. If we fail, we try again in
# MODULE mode as last resort.
find_package(Boost @_MPPP_MIN_BOOST_VERSION@ QUIET COMPONENTS serialization CONFIG)
if(NOT ${Boost_FOUND})
find_package(Boost @_MPPP_MIN_BOOST_VERSION@ QUIET MODULE COMPONENTS serialization)
endif()
if(NOT ${Boost_FOUND})
message(FATAL_ERROR "Could not locate Boost in either CONFIG or MODULE mode.")
endif()
endif()
set(mp++_WITH_BOOST_S11N @MPPP_WITH_BOOST_S11N@)

Expand Down
1 change: 0 additions & 1 deletion tools/circleci_conda_arm64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ cmake ../ -G Ninja \
-DCMAKE_CXX_STANDARD=20 \
-DCMAKE_BUILD_TYPE=Debug \
-DMPPP_BUILD_TESTS=yes \
-DBoost_NO_BOOST_CMAKE=yes \
-DMPPP_WITH_BOOST_S11N=yes \
-DMPPP_WITH_FMT=yes \
-DMPPP_WITH_MPFR=yes \
Expand Down
1 change: 0 additions & 1 deletion tools/circleci_conda_coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ cmake ../ -G Ninja \
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_BUILD_TYPE=Debug \
-DMPPP_BUILD_TESTS=yes \
-DBoost_NO_BOOST_CMAKE=yes \
-DMPPP_WITH_MPFR=yes \
-DMPPP_WITH_MPC=yes \
-DMPPP_WITH_ARB=yes \
Expand Down
1 change: 0 additions & 1 deletion tools/circleci_conda_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ cmake ../ -G Ninja \
-DCMAKE_INSTALL_PREFIX=$deps_dir \
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_BUILD_TYPE=Debug \
-DBoost_NO_BOOST_CMAKE=yes \
-DMPPP_WITH_BOOST_S11N=yes \
-DMPPP_WITH_FMT=yes \
-DMPPP_WITH_MPFR=yes \
Expand Down
1 change: 0 additions & 1 deletion tools/circleci_conda_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ cmake ../ -G Ninja \
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_BUILD_TYPE=Release \
-DMPPP_BUILD_TESTS=yes \
-DBoost_NO_BOOST_CMAKE=yes \
-DMPPP_WITH_BOOST_S11N=yes \
-DMPPP_WITH_FMT=yes \
-DMPPP_WITH_MPFR=yes \
Expand Down
1 change: 0 additions & 1 deletion tools/gha_conda_asan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ cmake ../ -G Ninja \
-DCMAKE_CXX_STANDARD=20 \
-DCMAKE_BUILD_TYPE=Debug \
-DMPPP_BUILD_TESTS=yes \
-DBoost_NO_BOOST_CMAKE=yes \
-DMPPP_WITH_BOOST_S11N=yes \
-DMPPP_WITH_FMT=yes \
-DMPPP_WITH_MPFR=yes \
Expand Down
1 change: 0 additions & 1 deletion tools/gha_conda_tsan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ cmake ../ -G Ninja \
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_BUILD_TYPE=Debug \
-DMPPP_BUILD_TESTS=yes \
-DBoost_NO_BOOST_CMAKE=yes \
-DMPPP_WITH_BOOST_S11N=yes \
-DMPPP_WITH_FMT=yes \
-DMPPP_WITH_MPFR=yes \
Expand Down
1 change: 0 additions & 1 deletion tools/gha_conda_ubsan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ cmake ../ -G Ninja \
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_BUILD_TYPE=Debug \
-DMPPP_BUILD_TESTS=yes \
-DBoost_NO_BOOST_CMAKE=yes \
-DMPPP_WITH_BOOST_S11N=yes \
-DMPPP_WITH_FMT=yes \
-DMPPP_WITH_MPFR=yes \
Expand Down
2 changes: 1 addition & 1 deletion tools/gha_debuggmp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ unset CFLAGS
unset CXXFLAGS

# Download and compile locally GMP in debug mode.
GMP_VERSION="6.2.1"
GMP_VERSION="6.3.0"
wget https://github.com/esa/manylinux_x86_64_with_deps/raw/master/gmp-${GMP_VERSION}.tar.bz2 -O gmp.tar.bz2
tar xjvf gmp.tar.bz2
cd gmp-${GMP_VERSION}
Expand Down
1 change: 0 additions & 1 deletion tools/gha_osx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ cmake ../ -G Ninja \
-DCMAKE_CXX_STANDARD=20 \
-DCMAKE_BUILD_TYPE=Debug \
-DMPPP_BUILD_TESTS=yes \
-DBoost_NO_BOOST_CMAKE=yes \
-DMPPP_WITH_BOOST_S11N=yes \
-DMPPP_WITH_FMT=yes \
-DMPPP_WITH_MPFR=yes \
Expand Down
2 changes: 1 addition & 1 deletion tools/travis_ubuntu_ppc64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ mkdir build
cd build

# GCC build.
cmake ../ -DCMAKE_PREFIX_PATH=$deps_dir -DCMAKE_CXX_STANDARD=17 -DCMAKE_BUILD_TYPE=Debug -DMPPP_BUILD_TESTS=YES -DBoost_NO_BOOST_CMAKE=ON -DMPPP_WITH_BOOST_S11N=yes -DMPPP_WITH_FMT=yes -DMPPP_WITH_QUADMATH=yes -DMPPP_WITH_MPFR=yes -DMPPP_WITH_MPC=yes -DMPPP_WITH_ARB=yes -DMPPP_TEST_PYBIND11=yes -DPYBIND11_PYTHON_VERSION=3.8
cmake ../ -DCMAKE_PREFIX_PATH=$deps_dir -DCMAKE_CXX_STANDARD=17 -DCMAKE_BUILD_TYPE=Debug -DMPPP_BUILD_TESTS=YES -DMPPP_WITH_BOOST_S11N=yes -DMPPP_WITH_FMT=yes -DMPPP_WITH_QUADMATH=yes -DMPPP_WITH_MPFR=yes -DMPPP_WITH_MPC=yes -DMPPP_WITH_ARB=yes -DMPPP_TEST_PYBIND11=yes -DPYBIND11_PYTHON_VERSION=3.8
make -j1 VERBOSE=1
# Run the tests.
ctest -V -j2
Expand Down

0 comments on commit afc2aa4

Please sign in to comment.