While compiling mex
files with nvcc
I have struggled to pass compiler options specific to CUDA to the nvcc
compiler, as mex
doesn't recognize them.
I found some old posts about passing compiler flags and some newer ones,
but the questions are quite user-specific, and the mex
compiler has changed over the years, so I cant figure out what to do.
So, my specific question: What should I do to make mex
pass compiler flags to nvcc
?
A bit more generic: What should one do to make mex
pass compiler flags to another compiler?
If working with the newest compiling way where the options are in an xml file, one can hardcode the default compile flags in there. For example mine looks like:
COMPILER="nvcc"
COMPFLAGS="-gencode=arch=compute_20,code=sm_20 -gencode=arch=compute_30,code=sm_30 -gencode=arch=compute_35,code=sm_35 -gencode=arch=compute_50,code=\"sm_50,compute_50\" --compiler-options=/c,/GR,/W3,/EHs,/nologo,/MD"
COMPDEFINES="--compiler-options=/D_CRT_SECURE_NO_DEPRECATE,/D_SCL_SECURE_NO_DEPRECATE,/D_SECURE_SCL=0,$MATLABMEX"
MATLABMEX="/DMATLAB_MEX_FILE"
OPTIMFLAGS="--compiler-options=/O2,/Oy-,/DNDEBUG"
INCLUDE="-I"$MATLABROOT\extern\include" -I"$MATLABROOT\simulink\include""
DEBUGFLAGS="--compiler-options=/Z7"
One can change the defaults modifiying COMPFLAGS