[CMake] Windows, export lits (.def files) and automation

Tom Kacvinsky tom.kacvinsky at vectorcast.com
Fri Mar 27 13:17:20 EDT 2015


I have read the material concerning how to make a DLL on Windows with
exported symbols and it make sense.  However, I would like to avoid
use of __declspec(dllexport) if at all possible.  I know this is not
the recommended cmake way, but I am afrid that introducing
__declspec(dllexport) would lead to a maintenance nightmare (broken
builds because exports weren't added, merges silently removing the
exports, etc...)

I found this:

http://stackoverflow.com/questions/225432/export-all-symbols-when-creating-a-dll

which explains how to automate the creation of a .def file I could use
for making a DLL.

And I also found documentation on the PRE_LINK option when generating a library.

So what I was thinking is I could compile the code via an OBJECT
library (vs. STATIC or SHARED),
make a custom command to generate the .def file given the
correpsonding object files, and then set up a target to generate the
DLL that combines the object files and .def file.

That's the train of thought, anyway.  What I would need to know is the
cmake magic to glue all these pieces together.

Has any one done this and have tips on how to do so?

Thanks,

Tom


More information about the CMake mailing list