[CMake] Cmake + Matlab mex

Matt McCormick matt at mmmccormick.com
Thu Jul 9 14:10:24 EDT 2009


> ..., but what I want to do is compile a file 
> for use in Matlab using the mex compiler. I can do this by hand by 
> executing the following in a shell:
> 
> $ mex foo.cpp
> 
> This would produce a foo.mexglx binary which matlab would be able to use.
> 
> This is great if your foo.cpp is self-contained, however my foo.cpp 
> depends on libraries and include files which I generate in my CMake 
> build. Manually what I would do to handle this is:
> 
> $ mex -I/my/include/path -L/my/library/path -lmylib ... foo.cpp
> 
> I would like to make a CMake target which does the command above, taking 
> into account any library or include dependencies I specify in my 
> CMakeLists.txt. Is this possible?
> 

I have implemented this behavior.  Please see 

http://www.cmake.org/Wiki/CMake:MatlabMex

Kick the tires.
I have tried this on Linux and WindowsXP, and it seems works in these cases, at
least on my system.






More information about the CMake mailing list