@@ -93,6 +93,40 @@ fn look_in_scipoptdir_and_conda_env() -> Option<bindgen::Builder> {
9393 return None ;
9494}
9595
96+ fn try_system_include_paths ( ) -> Option < bindgen:: Builder > {
97+ println ! ( "cargo:warning=Searching for SCIP in standard system directories" ) ;
98+
99+ // Common system include paths
100+ let search_paths = vec ! [
101+ "/usr/include" ,
102+ "/usr/local/include" ,
103+ "/opt/local/include" , // MacPorts
104+ "/opt/homebrew/include" , // Homebrew ARM Mac
105+ "/usr/local/opt/scip/include" , // Homebrew Intel Mac
106+ ] ;
107+
108+ for base_path in search_paths {
109+ let base = PathBuf :: from ( base_path) ;
110+ let scip_h = base. join ( "scip" ) . join ( "scip.h" ) ;
111+ let scipdefplugins_h = base. join ( "scip" ) . join ( "scipdefplugins.h" ) ;
112+
113+ if scip_h. exists ( ) && scipdefplugins_h. exists ( ) {
114+ println ! ( "cargo:warning=Found SCIP headers in {}" , base_path) ;
115+
116+ return Some (
117+ bindgen:: Builder :: default ( )
118+ . header ( scip_h. to_str ( ) . unwrap ( ) )
119+ . header ( scipdefplugins_h. to_str ( ) . unwrap ( ) )
120+ . parse_callbacks ( Box :: new ( bindgen:: CargoCallbacks ) )
121+ . clang_arg ( format ! ( "-I{}" , base_path) )
122+ ) ;
123+ }
124+ }
125+
126+ println ! ( "cargo:warning=Could not find SCIP headers in standard system directories" ) ;
127+ None
128+ }
129+
96130fn main ( ) -> Result < ( ) , Box < dyn Error > > {
97131 let builder = if is_bundled_feature_enabled ( ) {
98132 download_scip ( ) ;
@@ -107,29 +141,20 @@ fn main() -> Result<(), Box<dyn Error>> {
107141 if builder. is_some ( ) {
108142 builder. unwrap ( )
109143 } else {
110- println ! ( "cargo:warning=SCIP was not found in SCIPOPTDIR or in Conda environemnt " ) ;
144+ println ! ( "cargo:warning=SCIP was not found in SCIPOPTDIR or in Conda environment " ) ;
111145 println ! ( "cargo:warning=Looking for SCIP in system libraries" ) ;
112146
113- let headers_dir_path = "headers/" ;
114- let headers_dir = PathBuf :: from ( headers_dir_path) ;
115- let scip_header_file = PathBuf :: from ( & headers_dir)
116- . join ( "scip" )
117- . join ( "scip.h" )
118- . to_str ( )
119- . unwrap ( )
120- . to_owned ( ) ;
121- let scipdefplugins_header_file = PathBuf :: from ( & headers_dir)
122- . join ( "scip" )
123- . join ( "scipdefplugins.h" )
124- . to_str ( )
125- . unwrap ( )
126- . to_owned ( ) ;
127-
128- bindgen:: Builder :: default ( )
129- . header ( scip_header_file)
130- . header ( scipdefplugins_header_file)
131- . parse_callbacks ( Box :: new ( bindgen:: CargoCallbacks ) )
132- . clang_arg ( format ! ( "-I{}" , headers_dir_path) )
147+ // Try common system include paths
148+ try_system_include_paths ( ) . unwrap_or_else ( || {
149+ panic ! (
150+ "Could not find SCIP installation.\n \
151+ Please either:\n \
152+ - Set SCIPOPTDIR environment variable to point to your SCIP installation\n \
153+ - Install SCIP system-wide (headers in /usr/include or /usr/local/include)\n \
154+ - Use --features bundled to download and use a bundled version\n \
155+ - Use --features from-source to build SCIP from source"
156+ )
157+ } )
133158 }
134159 } ;
135160
0 commit comments