Hi Eric.

Many thanks for your reply.

On Mon, Sep 10, 2012 at 9:49 AM, Eric Noulard <eric.noul...@gmail.com> wrote:
> 2012/9/10 Petr Kmoch <petr.km...@gmail.com>:
>> Hi all.
>>
>> I'm on Windows, and I need a DLL composed of multiple static
>> libraries, any of which can define dllexport functions not otherwise
>> referenced in the DLL. The problem is that the Visual Studio linker
>> does not provide flags to link an entire static library (i.e. there is
>> no equivalent to ld's --whole-archive). I tried /OPT:NOREF, it didn't
>> help.
>>
>> The only solution I can think of is to link all of the static
>> library's object files instead of the library itself (I verified
>> manually that this works). I cannot put source files into the DLL
>> directly, because the DLL is C and the static lib(s) are Fortran.
>
> Why can't you do that?
> I do not use fortran since a long time ago but I do not see why you can't do
>
> add_library(mymixedllib foo.c blah.f90)

Because I need the Fortran VS project to be a .vfproj, and that only
works for pure-Fortran targets.

>
>
>> My question is thus: is there a way to retrieve the list of a target's
>> object files from cmake?
>
> Since CMake 2.8.9 you can build "OBJECT" library,
> see:
> cmake --help-command add_library
>
> [...]
>          add_library(<name> OBJECT <src>...)
>
>        creates a special "object library" target.  An object library compiles
>        source files but does not archive or link their object files into a
>        library.  Instead other targets created by add_library or
>        add_executable may reference the objects using an expression of the
>        form $<TARGET_OBJECTS:objlib> as a source, where "objlib" is the
>        object library name.  For example:
>
>          add_library(... $<TARGET_OBJECTS:objlib> ...)
>          add_executable(... $<TARGET_OBJECTS:objlib> ...)
>
>        will include objlib's object files in a library and an executable
>        along with those compiled from their own sources.
> [...]

A hundred thanks! That's precisely what I need. On to ask for an
upgrade our company-wide cmake installation, then.

Petr
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to