aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/ports/boost-math/build-old-libs.patch
blob: 9fb7881c6042b65274aaf003493b31dcec286bef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4e6c492..a910097 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -59,3 +59,106 @@ elseif(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
   install(DIRECTORY "include/" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
 
 endif()
+
+option(BOOST_MATH_BUILD_WITH_LEGACY_FUNCTIONS "" OFF)
+if(BOOST_MATH_BUILD_WITH_LEGACY_FUNCTIONS)
+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_link_libraries(boost_math_tr1${type} PUBLIC Boost::config)
+  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_link_libraries(boost_math_c99${type} PUBLIC Boost::config)
+  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_14)
+  target_compile_features(boost_math_c99${type} PUBLIC cxx_std_14)
+  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()
+endif()
+