[CMake] How can I compile and link modular code into a single DLL with MSVC?
Jason Heeris
jason.heeris at gmail.com
Wed Jun 27 02:47:01 EDT 2018
On Wed, 27 Jun 2018 at 15:00, Innokentiy Alaytsev <alaitsev at gmail.com>
wrote:
> Do you create declspec declaration by hand? It may worth looking at the
> GenerateExportHeader
> <https://cmake.org/cmake/help/v3.7/module/GenerateExportHeader.html>
>
Thanks, this will probably be very useful!
> Is it the code that you use in your CMake build script or just a
> representation of the general idea?
>
It's a representation, it's not in CMake at all currently, so anything's on
the table. However, it's not a far stretch from the real build steps.
Currently the build system is in another scripting language, which
traverses the dependencies from the top-level module, listing all
dependants recursively (no duplicates). It then compiles each one into an
.obj file and finally links all the .obj files together. Rather than
subject you to that, I've added a (very fragile) "build_manual.bat" file to
that Gitlab repo. But it contains those cl.exe and link.exe commands, and
produces a DLL with a single visible function, "module3()".
The fundamental problem here is simply one of scale. For my sample project,
adding common, module1, module2 to module3's dependencies isn't hard. But
when it's a couple of dozen dependencies, some of which may change from
time to time, with different degrees of indirectness, flattening them all
out would be very time consuming. As would finding and updating all parents
when sub-sub-module deps change. Tracking direct dependencies only is far
more manageable. Hope that makes sense.
Cheers,
Jason
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180627/f56160f0/attachment.html>
More information about the CMake
mailing list