@@ -28,9 +28,6 @@ const WITH_LIBXML: &str = "OFF";
28
28
/// Whether to build with Expat XML parser support
29
29
const WITH_EXPAT : & str = "ON" ;
30
30
31
- /// Whether to use static runtime libraries (enabled on Windows only)
32
- const WITH_STATIC_RUNTIME : & str = "ON" ;
33
-
34
31
/// Main build script function that orchestrates the build process
35
32
///
36
33
/// This function:
@@ -68,8 +65,8 @@ fn main() -> miette::Result<()> {
68
65
// Build the C++ wrapper code and bindings
69
66
let mut b = autocxx_build:: Builder :: new ( rs_file, & [ lib_root, & sbml_include] ) . build ( ) ?;
70
67
71
- // Ensure C++17 is used for compilation
72
- b. flag_if_supported ( "-std=c++17" ) . compile ( "libsbml " ) ;
68
+ // Ensure C++20 is used for compilation
69
+ b. flag_if_supported ( "-std=c++17" ) . compile ( "sbmlrs " ) ;
73
70
74
71
Ok ( ( ) )
75
72
}
@@ -87,13 +84,15 @@ fn main() -> miette::Result<()> {
87
84
/// * `miette::Result<String>` - Build directory path on success, error on failure
88
85
fn build_and_link_libsbml ( dep_build : & str ) -> miette:: Result < String > {
89
86
let dst = if cfg ! ( target_os = "windows" ) {
87
+ println ! ( "cargo:warning=Building libSBML for Windows" ) ;
90
88
// In order to build for windows, we need to carefully tell CMake
91
89
// where to find the libraries and headers for libexpat and zlib.
92
90
// This is necessary because the libraries are not installed in the
93
91
// system directories by default. Unlinke MacOS and Linux kernels
94
92
cmake:: Config :: new ( LIBSBML_PATH )
95
- . define ( "CMAKE_BUILD_TYPE" , "Release" )
96
- . define ( "WITH_STATIC_RUNTIME" , WITH_STATIC_RUNTIME )
93
+ . static_crt ( true )
94
+ . profile ( "Release" )
95
+ . define ( "WITH_STATIC_RUNTIME" , "ON" )
97
96
. define ( "WITH_LIBXML" , WITH_LIBXML )
98
97
. define ( "WITH_EXPAT" , WITH_EXPAT )
99
98
//
@@ -118,12 +117,13 @@ fn build_and_link_libsbml(dep_build: &str) -> miette::Result<String> {
118
117
. define ( "BUILD_SHARED_LIBS" , "OFF" )
119
118
. build ( )
120
119
} else {
120
+ println ! ( "cargo:warning=Building libSBML for MacOS/Linux" ) ;
121
121
// When building for MacOS and Linux, we can just use the system libraries
122
122
cmake:: Config :: new ( LIBSBML_PATH )
123
- . define ( "WITH_STATIC_RUNTIME" , WITH_STATIC_RUNTIME )
123
+ . profile ( "Release" )
124
+ . define ( "WITH_STATIC_RUNTIME" , "OFF" )
124
125
. define ( "WITH_LIBXML" , WITH_LIBXML )
125
126
. define ( "WITH_EXPAT" , WITH_EXPAT )
126
- . define ( "LIBSBML_USE_STRICT_INCLUDES" , "True" )
127
127
. build ( )
128
128
} ;
129
129
@@ -151,16 +151,22 @@ fn build_and_link_libsbml(dep_build: &str) -> miette::Result<String> {
151
151
/// # Returns
152
152
/// * `miette::Result<String>` - Build directory path on success, error on failure
153
153
fn build_and_link_sbml_deps ( ) -> miette:: Result < String > {
154
+ println ! ( "cargo:warning=Building libSBML dependencies" ) ;
155
+
154
156
// Build the dependencies for libSBML
155
157
// We hard-code to EXPAT and ZLIB for now, but in the future this should
156
158
// be made more flexible.
157
159
let dst = cmake:: Config :: new ( LIBSBML_DEPENDENCY_DIR )
158
- . define ( "WITH_EXPAT" , "True" )
159
- . define ( "WITH_LIBXML" , "False" )
160
- . define ( "WITH_ZLIB" , "True" )
161
- . define ( "WITH_BZIP2" , "False" )
162
- . define ( "WITH_CHECK" , "False" )
163
- . define ( "BUILD_SHARED_LIBS" , "False" )
160
+ . static_crt ( true )
161
+ . profile ( "Release" )
162
+ . define ( "WITH_STATIC_RUNTIME" , "ON" )
163
+ . define ( "EXPAT_MSVC_STATIC_CRT" , "ON" )
164
+ . define ( "WITH_EXPAT" , "ON" )
165
+ . define ( "WITH_LIBXML" , "OFF" )
166
+ . define ( "WITH_ZLIB" , "ON" )
167
+ . define ( "WITH_BZIP2" , "OFF" )
168
+ . define ( "WITH_CHECK" , "OFF" )
169
+ . define ( "BUILD_SHARED_LIBS" , "OFF" )
164
170
. build ( ) ;
165
171
166
172
// Configure cargo to link against the built libraries
0 commit comments