Skip to content

Commit 2089f3c

Browse files
committed
Pass compiler flags directly to scons as build arguments
The error persists: "Checking for C++ header file cmath... no" Root cause: Setting ENV variables wasn't sufficient because scons has its own configuration system that doesn't automatically pick up environment variables properly. Solution: Pass compiler flags directly to scons as command-line arguments using its cc_flags and cxx_flags parameters: 1. cc_flags/cxx_flags accept compiler flag strings 2. Include -isysroot to point to SDK 3. Include -stdlib=libc++ for standard library 4. Explicitly add C++ header path: -I<SDK>/usr/include/c++/v1 This directly tells Cantera's scons build system where to find standard C++ headers like <cmath>, bypassing any environment variable issues. This is the approach used by other Homebrew formulas that build with scons on macOS.
1 parent 2145319 commit 2089f3c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

packaging/homebrew/mfc.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,20 @@ def install
3838
# Install Cantera build dependencies (including scons)
3939
system venv/"bin/pip", "install", "cython", "numpy", "ruamel.yaml", "packaging", "scons"
4040

41-
# Configure Cantera build
42-
# Set compiler environment variables for scons
43-
ENV["CC"] = ENV.cc
44-
ENV["CXX"] = ENV.cxx
45-
ENV["CFLAGS"] = "-isysroot#{MacOS.sdk_path}"
46-
ENV["CXXFLAGS"] = "-isysroot#{MacOS.sdk_path}"
47-
41+
# Configure Cantera build - pass compiler and SDK paths to scons
42+
# Build flags that include SDK path and standard C++ include directories
43+
sdk_path = MacOS.sdk_path
44+
cxx_flags = "-isysroot#{sdk_path} -stdlib=libc++ -I#{sdk_path}/usr/include/c++/v1"
45+
4846
# Run scons with the venv's Python so it can find installed packages
4947
system venv/"bin/python", "-m", "SCons", "build",
5048
"python_package=y",
5149
"f90_interface=n",
5250
"system_sundials=y",
5351
"system_yamlcpp=y",
5452
"system_fmt=n",
53+
"cc_flags=#{cxx_flags}",
54+
"cxx_flags=#{cxx_flags}",
5555
"extra_inc_dirs=#{Formula["sundials"].opt_include}:#{Formula["yaml-cpp"].opt_include}",
5656
"extra_lib_dirs=#{Formula["sundials"].opt_lib}:#{Formula["yaml-cpp"].opt_lib}",
5757
"prefix=#{libexec}/cantera",

0 commit comments

Comments
 (0)