[CMake] Cmake + Matlab mex
Wojciech Jarosz
wjarosz at ucsd.edu
Mon Oct 16 19:54:43 EDT 2006
Brad King wrote:
> FIND_PACKAGE(Matlab)
> INCLUDE_DIRECTORIES(${MATLAB_INCLUDE_DIR})
> ADD_LIBRARY(mymex MODULE mymex.c)
> TARGET_LINK_LIBRARIES(mymex ${MATLAB_LIBRARIES})
>
> See also "bin/cmake --help-module FindMatlab".
>
> It looks like the matlab module is a bit out of date so let us know if
> you have problems.
>
> -Brad
>
I think maybe I didn't explain my question well enough.
It seems that your suggestion would allow me to compile a c/cpp file
against the matlab mex library, 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?
Thanks,
-wojciech
More information about the CMake
mailing list