[CMake] Re: Making MEX file from CMAKE

David Cole david.cole at kitware.com
Fri Oct 20 08:02:00 EDT 2006


There are two options.

(1) Create a "*.def" file and add it as a source file to your target:
ADD_LIBRARY(... MODULE ... MyDefFile.def)

(2) In your source code, use __declspec(dllexport) to decorate the
function name... You can see examples of this in this VTK header file:
http://public.kitware.com/cgi-bin/viewcvs.cgi/Common/vtkWin32Header.h?rev=HEAD&view=auto

With the declspec approach in your source files, you need to be
careful to define it as dllexport when you're building your dll,
dllimport when a client is including your header file to link against
your dll and to use neither if you are building as a static library.

HTH,
David


On 10/20/06, Prename Surname <bsd.diverse at gmail.com> wrote:
> Okay, i have boiled it down to the fact that i need to define from cmake, a
> "Module definition file"
> It seems to be all this needs to be done.
> When i set i manually, it works perfectly, but can anyone help me with how i
> can set a "Module definition file" from CMAKE ? (I use VS 8.0)
>
>
> 2006/10/20, Prename Surname <bsd.diverse at gmail.com>:
> >
> > Hello. I want to use CMAKE to create mex file for matlab. But i seem to be
> doing something wrong.
> > I need to specify output as DLL. which i can use ADD_LIBRARY(... MODULE
> ...) for.
> >
> > The problem is that apparently i also need to  make sure mexFunction is an
> exported symbol in the dll.
> >
> > The mexFunction is the main function in my dll. And i dont really know how
> to make CMAKE setup visual studio 8 to do this.
> > I hope someone can help me.
> > Many regards
> >
>
>
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>
>


More information about the CMake mailing list