vcpkg/ports/boost-math/build-old-libs.patch
Alexander Neumann bcf3d00d21
[Boost] use cmake build (#32309)
~~arm64-windows: boost-context builds are blocked by a cmake bug (see
https://gitlab.kitware.com/cmake/cmake/-/issues/24317)~~

closes #32274
closes https://github.com/Neumann-A/my-vcpkg-triplets/issues/5

Questions:
- [x] ~~Move cmake files to `share/cmake/<name>` ?~~ Not doing it
because it is just using `vcpkg_cmake_config_fixup()`
- [x] Fix weak dependencies (uwp|emscripten|android|arm)?
- [x] Fix library names on !x64 (currently hardcoded to x64 or x86;
failure in aricpp since it forces FindBoost module mode.)
- [x] ~~Fix arm64-windows boost-context builds -> requires CMake
(3.19.2?) update due to bug how the assembler is invoked.~~ (-> CI
baseline for now)

TODO:
- [x] adjust generate ports script
- [x] #37457

---------

Co-authored-by: Cheney-Wang <850426846@qq.com>
2024-04-29 15:27:41 -04:00

110 lines
3.2 KiB
Diff

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7e7790271c..cd08a77e4a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -41,6 +41,104 @@ else()
endif()
+include(CheckCXXSourceCompiles)
+set(CMAKE_REQUIRED_LIBRARIES Boost::config)
+set(CMAKE_REQUIRED_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/include")
+check_cxx_source_compiles("#include <${CMAKE_CURRENT_SOURCE_DIR}/config/has_long_double_support.cpp> \n int main() { return 0;}" BOOST_MATH_HAS_LONG_DOUBLE)
+unset(CMAKE_REQUIRED_LIBRARIES)
+unset(CMAKE_REQUIRED_INCLUDES)
+
+set(C99_SOURCES
+ acosh
+ asinh
+ atanh
+ cbrt
+ copysign
+ erfc
+ erf
+ expm1
+ fmax
+ fmin
+ fpclassify
+ hypot
+ lgamma
+ llround
+ log1p
+ lround
+ nextafter
+ nexttoward
+ round
+ tgamma
+ trunc
+)
+
+set(TR1_SOURCES
+ assoc_laguerre
+ assoc_legendre
+ beta
+ comp_ellint_1
+ comp_ellint_2
+ comp_ellint_3
+ cyl_bessel_i
+ cyl_bessel_j
+ cyl_bessel_k
+ cyl_neumann
+ ellint_1
+ ellint_2
+ ellint_3
+ expint
+ hermite
+ laguerre
+ legendre
+ riemann_zeta
+ sph_bessel
+ sph_legendre
+ sph_neumann
+)
+
+list(TRANSFORM C99_SOURCES PREPEND "src/tr1/" ) # OUTPUT_VARIABLE <output variable>])
+list(TRANSFORM TR1_SOURCES PREPEND "src/tr1/" )
+
+list(TRANSFORM C99_SOURCES APPEND "f.cpp" OUTPUT_VARIABLE C99_SOURCESf)
+list(TRANSFORM TR1_SOURCES APPEND "f.cpp" OUTPUT_VARIABLE TR1_SOURCESf)
+
+set(types "" f)
+
+if(BOOST_MATH_HAS_LONG_DOUBLE)
+ list(TRANSFORM C99_SOURCES APPEND "l.cpp" OUTPUT_VARIABLE C99_SOURCESl)
+ list(TRANSFORM TR1_SOURCES APPEND "l.cpp" OUTPUT_VARIABLE TR1_SOURCESl)
+ list(APPEND types l)
+endif()
+
+list(TRANSFORM C99_SOURCES APPEND ".cpp")
+list(TRANSFORM TR1_SOURCES APPEND ".cpp")
+
+foreach(type IN LISTS types)
+ add_library(boost_math_tr1${type} ${TR1_SOURCES${type}})
+ target_include_directories(boost_math_tr1${type} PRIVATE src/tr1)
+ target_include_directories(boost_math_tr1${type} PRIVATE include)
+ add_library(boost_math_c99${type} ${C99_SOURCES${type}})
+ target_include_directories(boost_math_c99${type} PRIVATE src/tr1)
+ target_include_directories(boost_math_c99${type} PRIVATE include)
+ if(BUILD_SHARED_LIBS)
+ target_compile_definitions(boost_math_tr1${type} PUBLIC BOOST_MATH_TR1_DYN_LINK=1)
+ target_compile_definitions(boost_math_c99${type} PUBLIC BOOST_MATH_TR1_DYN_LINK=1)
+ if(MSVC)
+ target_compile_definitions(boost_math_tr1${type} PRIVATE "BOOST_SYMBOL_EXPORT=__declspec(dllexport)" BOOST_ALL_NO_LIB)
+ target_compile_definitions(boost_math_c99${type} PRIVATE "BOOST_SYMBOL_EXPORT=__declspec(dllexport)" BOOST_ALL_NO_LIB)
+ endif()
+ endif()
+ target_compile_features(boost_math_tr1${type} PUBLIC cxx_std_11)
+ target_compile_features(boost_math_c99${type} PUBLIC cxx_std_11)
+ if(DARWIN)
+ target_compile_definitions(boost_math_tr1${type} PRIVATE _DARWIN_C_SOURCE)
+ target_compile_definitions(boost_math_c99${type} PRIVATE _DARWIN_C_SOURCE)
+ endif()
+ boost_install_target(TARGET boost_math_tr1${type} VERSION ${BOOST_SUPERPROJECT_VERSION})
+ boost_install_target(TARGET boost_math_c99${type} VERSION ${BOOST_SUPERPROJECT_VERSION})
+endforeach()
+
+
# Only enable tests when we're the root project
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)