[CMake] transitive dependencies (again)

Tom Kacvinsky tom.kacvinsky at vectorcast.com
Tue Dec 15 09:28:31 EST 2015


On Mon, Dec 14, 2015 at 3:36 PM, iosif neitzke
<iosif.neitzke+cmake at gmail.com> wrote:
> If you can build Ada sources first, you might wish to make that a
> standalone project that is consumed downstream natively as an Imported
> Library.  Do you generate the import library from a .def file, or via
> some other means?
>

Via a def file.  I first call gnatdll to make the DLL, then call
MSVC's lib tool to create the import library from a def file.

I pored through the cmake configuration removing everything that the
would appear to give a transitivedependency, yet the dependencies
linger.  I'll keep digging, this didn't happen before so something
must have changed in the configuration when I merged against master
for our code base.


> On Mon, Dec 14, 2015 at 9:59 AM, Tom Kacvinsky
> <tom.kacvinsky at vectorcast.com> wrote:
>> Hi Petr,
>>
>>
>> On Mon, Dec 14, 2015 at 10:53 AM, Petr Kmoch <petr.kmoch at gmail.com> wrote:
>>> Hi Tom,
>>>
>>> linking the static archive into the DLL should not be done by
>>> add_dependencies(), but by target_link_libraries(). There, you can
>>> explicitly list the archive as PRIVATE so that it does not become a part of
>>> the linking interface of the DLL:
>>>
>>> add_library(staticArchive STATIC ...)
>>>
>>> add_library(theDLL SHARED ...)
>>>
>>> target_link_libraries(theDLL PRIVATE staticArchive)
>>>
>>
>> Thanks for the tip.   I'll try it out.  I hope it works as I am not
>> using the MSVC tool chain
>> to build the DLL (i.e., not using add_library and target_link_libraries).
>>
>> I sent a separate reply detailing what I am using to build the DLL.
>>>
>>> On Mon, Dec 14, 2015 at 3:34 PM, Tom Kacvinsky
>>> <tom.kacvinsky at vectorcast.com> wrote:
>>>>
>>>> I am getting link errors because cmake is adding transitive
>>>> dependencies.  I am building a DLL which depends on a static archive
>>>> (and is marked as such with add_dependencies), but when I link an
>>>> executable that depends on the DLL, both libraries (import library for
>>>> the DLL and static archive) are specified on the link. leading to
>>>> duplicate symbol errors as the symbol are exported form the DLL and
>>>> defined in the static archive.
>>>>
>>>> How do I work around this?  This is the one thing that has frustrated
>>>> me over the last couple of years - I have never received an answer
>>>> telling me how to turn off transitive dependencies.
>>>>
>>>> Sorry for the minor rant.
>>>>
>>>> Regards,
>>>>
>>>> Tom
>>>> --
>>>>
>>>> Powered by www.kitware.com
>>>>
>>>> Please keep messages on-topic and check the CMake FAQ at:
>>>> http://www.cmake.org/Wiki/CMake_FAQ
>>>>
>>>> Kitware offers various services to support the CMake community. For more
>>>> information on each offering, please visit:
>>>>
>>>> CMake Support: http://cmake.org/cmake/help/support.html
>>>> CMake Consulting: http://cmake.org/cmake/help/consulting.html
>>>> CMake Training Courses: http://cmake.org/cmake/help/training.html
>>>>
>>>> Visit other Kitware open-source projects at
>>>> http://www.kitware.com/opensource/opensource.html
>>>>
>>>> Follow this link to subscribe/unsubscribe:
>>>> http://public.kitware.com/mailman/listinfo/cmake
>>>
>>>
>> --
>>
>> Powered by www.kitware.com
>>
>> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Kitware offers various services to support the CMake community. For more information on each offering, please visit:
>>
>> CMake Support: http://cmake.org/cmake/help/support.html
>> CMake Consulting: http://cmake.org/cmake/help/consulting.html
>> CMake Training Courses: http://cmake.org/cmake/help/training.html
>>
>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/cmake
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake


More information about the CMake mailing list