[CMake] Proper way to export a library

Matthew Woehlke matthew.woehlke at kitware.com
Thu Oct 31 15:40:43 EDT 2013


On 2013-10-31 14:46, Hendrik Sattler wrote:
> Matthew Woehlke  schrieb:
>> On 2013-10-31 05:26, Cyrille Faucheux wrote:
>>> On the library I'm currently working on, with Visual Studio, I have
>>> to declare some compile definition in order to get the proper
>>> "__declspec(dllimport)" or "__declspec(dllexport)" defined (or not
>>> defined when compiling/using a static version of this library).
>>
>> This sounds like you're doing it wrong.
>
> Not really as you can only cover the export import with this case but not static vs. dynamic linking to that library with the same header file.
> That it's usually solved with a define when linking statically

Ah, yes, I forgot. You are right, you either need to pass a define that 
you are built static or else have it defined or not in a generated header.

Is it just the MYPROJECT_STATIC that you need to pass as a define? That 
would indeed be a good candidate for t_c_d(PUBLIC). (I got the - 
erroneous? - impression you were actually passing e.g. 
-DMY_ABI=__dllspec(dllimport)...)

-- 
Matthew



More information about the CMake mailing list