Hey Folks,<br><br>I'm new to cmake and am in the process of converting a Linux based project over to use it. The project I'm converting includes a lot of Matlab mex extensions. I've done a good deal of internet research (both archives of this list and Google) and I've yet to really garner a good sense of the best way to approach this.<br>
<br>For the uninitiated, Matlab mex extensions are snippets of C compiled against some headers and libraries provided by Matlab to produce a loadable shared library. Compilation of these extensions can be kicked off by either running commands within Matlab (forget it!) or via an external shell script that behaves somewhat like gcc. They do some fairly weird stuff (they give the loadable libraries platform based filename extensions, among other things.) Some more adventurous folks appear to have reverse engineered this shell script and have implemented it in cmake, but that seems like a lot of work. So a few quick questions:<br>
<br>1) If there's anyone out there with Matlab mex inside CMake builds experience, what is the best route for implementing this? Hacking the functionality of mex.sh into a CMake script or configuring CMake to run mex.sh to do the compilation?<br>
<br>2) Suppose I wanted to go ahead and use mex.sh? I suspect I'd need to use ADD_CUSTOM_TARGET and ADD_CUSTOM_COMMAND, but I've been unsuccessful as of yet to get them to do much.... (here's a quick excerpt of what I've tried, it prints "foo built" but AFAIK nothing is happening) Can someone help steer me in the right direction on this?<br>
<br>ADD_CUSTOM_COMMAND( <br> OUTPUT foo.mexa64 <br> COMMAND mex <br> ARGS ${CMAKE_CURRENT_SOURCE_DIR}/foo.c<br> DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/foo.c<br> COMMENT "get_analog_state"<br>
)<br><br>ADD_CUSTOM_TARGET(foo ALL echo<br> DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/foo.c<br> )<br><br>Thanks in advance for any help!<br><br>--adam<br><br><br><br>