Skip to content

Commit

Permalink
use mexopt for gcc on mac
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Mar 12, 2023
1 parent 13119d5 commit a9c7cdd
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/build_all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
if [[ "$RUNNER_OS" == "Windows" ]]; then
make mex
elif [[ "$RUNNER_OS" == "macOS" ]]; then
make mex CC=gcc-10 CXX=g++-10 LDFLAGS='' MEXLINKOPT="-static-libstdc++ -static-libgcc -fopenmp" EXTRALIB="-v -lomp -I/usr/local/opt/libomp/include -L/usr/local/opt/libomp/lib"
make mex CC=gcc-10 CXX=g++-10 MEXLINKOPT="-static-libstdc++ -static-libgcc -fopenmp" EXTRALIB="-v -f mexopts_maci64_gcc.xml"
else
make mex MEXLINKOPT="-static-libstdc++ -static-libgcc -fopenmp" EXTRALIB="-v"
fi
Expand Down
101 changes: 101 additions & 0 deletions src/mexopts_maci64_gcc.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8" ?>
<config
Name="g++"
ShortName="g++"
Manufacturer="GNU"
Version="$GCC_VERSION"
Language="C++"
Priority="A"
Location="$GCC_DIR" >
<Details
CompilerExecutable="$CXX"
CompilerDefines="$DEFINES"
CompilerFlags="$CXXFLAGS"
OptimizationFlags="$CXXOPTIMFLAGS"
DebugFlags="$CXXDEBUGFLAGS"
IncludeFlags="$INCLUDE"
LinkerExecutable="$LDXX"
LinkerFlags="$LDFLAGS"
LinkerLibraries="$LINKLIBS"
LinkerOptimizationFlags="$LDOPTIMFLAGS"
LinkerDebugFlags="$LDDEBUGFLAGS"
CompilerDefineFormatter="-D%s"
LinkerLibrarySwitchFormatter="-l%s"
LinkerPathFormatter="-L%s"
/>
<vars
CC="gcc"
CXX="g++"
CMDLINE100="$CXX -c $DEFINES $INCLUDE $CXXFLAGS $OPTIM $SRC -o $OBJ"
CMDLINE200="$LDXX $LDFLAGS $LINKOPTIM $LINKEXPORT $LINKEXPORTVER $LINKEXPORTCPP $OBJS $CXXLIBS $LINKLIBS -o $EXE"
DEFINES="$MATLABMEX"
MATLABMEX="-DMATLAB_MEX_FILE "
CFLAGS="-ansi -D_GNU_SOURCE -fno-common -arch x86_64 -fexceptions -fPIC -fno-omit-frame-pointer -pthread"
CXXFLAGS="$CFLAGS -std=c++11"
INCLUDE="-I&quot;$MATLABROOT/extern/include&quot; -I&quot;$MATLABROOT/simulink/include&quot;"
CXXOPTIMFLAGS="-O2 -fwrapv -DNDEBUG"
CXXDEBUGFLAGS="-g"
LD="$CC"
LDXX="$CXX"
LDFLAGS="-Wl,-twolevel_namespace -undefined error -arch x86_64 $LDBUNDLE"
LDBUNDLE="-bundle "
LINKEXPORT="-Wl,-exported_symbols_list,&quot;$MATLABROOT/extern/lib/maci64/mexFunction.map&quot;"
LINKEXPORTVER="-Wl,-exported_symbols_list,&quot;$MATLABROOT/extern/lib/maci64/c_exportsmexfileversion.map&quot;"
LINKEXPORTCPP="-Wl,-U,_mexCreateMexFunction -Wl,-U,_mexDestroyMexFunction -Wl,-U,_mexFunctionAdapter -Wl,-exported_symbols_list,&quot;$MATLABROOT/extern/lib/maci64/cppMexFunction.map&quot;"
LINKLIBS="-L&quot;$MATLABROOT/bin/maci64&quot; -lmx -lmex -lmat -L&quot;$MATLABROOT/extern/bin/$ARCH&quot; -lMatlabDataArray -lMatlabEngine"
LDOPTIMFLAGS="-O"
LDDEBUGFLAGS="-g"
OBJEXT=".o"
LDEXT=".mexmaci64"
SETENV="CC=&quot;$CC&quot;
CXX=&quot;$CXX&quot;
CFLAGS=&quot;$CFLAGS $DEFINES&quot;
CXXFLAGS=&quot;$CXXFLAGS $DEFINES&quot;
COPTIMFLAGS=&quot;$CXXOPTIMFLAGS&quot;
CXXOPTIMFLAGS=&quot;$CXXOPTIMFLAGS&quot;
CDEBUGFLAGS=&quot;$CXXDEBUGFLAGS&quot;
CXXDEBUGFLAGS=&quot;$CXXDEBUGFLAGS&quot;
LD=&quot;$LD&quot;
LDXX=&quot;$LDXX&quot;
LDFLAGS=&quot;$LDFLAGS $LINKLIBS $LINKEXPORT&quot;
LDDEBUGFLAGS=&quot;$LDDEBUGFLAGS&quot;"
/>
<client>
<engine
LINKLIBS="$LINKLIBS -leng -L&quot;$MATLABROOT/extern/bin/$ARCH&quot; -lMatlabDataArray -lMatlabEngine"
LDBUNDLE=""
LINKEXPORT=""
LINKEXPORTVER=""
LINKEXPORTCPP=""
LDEXT=""
/>

<mbuild
CMDLINE150="$MATLABROOT/bin/maci64/macbundle $EXENAME &quot;$EXEDIR&quot;"
CMDLINE200="$LDXX $LDFLAGS $OBJS $LINKOPTIM $LINKEXPORT $CXXLIBS $LINKLIBS -o &quot;$EXEDIR$EXENAME.app/Contents/MacOS/$EXENAME&quot;"
CXXFLAGS="-fexceptions -fno-common -arch x86_64 -std=c++11"
DEFINES="-DUNIX -DX11 -DMACI64 -UMX_COMPAT_SC"
LDFLAGS="-arch x86_64 $LDTYPE $LINKEXPORT -bind_at_load"
LINKLIBS="-L&quot;$MATLABROOT/runtime/maci64&quot; -L&quot;$MATLABROOT/extern/bin/maci64&quot; -lMatlabDataArray -lMatlabCppSharedLib -lmwmclmcrrt"
INCLUDE="-I&quot;$MATLABROOT/extern/include&quot; -I&quot;$MATLABROOT/extern/include/cpp&quot;"
MATLABMEX=""
LDEXT=""
LINKEXPORT=""
LINKEXPORTVER=""
LINKEXPORTCPP=""
LDTYPE=""
/>

</client>
<locationFinder>
<GCC_DIR>
<and>
<cmdReturns name="which g++" />
<dirExists name="$$" />
</and>
</GCC_DIR>
<GCC_VERSION>
<cmdReturns name="g++ -dumpversion"/>
</GCC_VERSION>
</locationFinder>
</config>

0 comments on commit a9c7cdd

Please sign in to comment.