[CMake] Recursively include target include directories only

Robert Dailey rcdailey.lists at gmail.com
Thu Jun 18 21:56:03 EDT 2015


On Thu, Jun 18, 2015 at 4:24 PM, Dan Liew <dan at su-root.co.uk> wrote:
> Hi,
>
> On 18 June 2015 at 12:16, Robert Dailey <rcdailey.lists at gmail.com> wrote:
>> On Thu, Jun 18, 2015 at 12:02 PM, Dan Liew <dan at su-root.co.uk> wrote:
>>>> Can you explain what you mean by "strong" and "weak" symbols?
>>>
>>>
>>> Google is your friend
>>>
>>> https://en.wikipedia.org/wiki/Weak_symbol
>>>
>>> http://stackoverflow.com/questions/2290587/gcc-style-weak-linking-in-visual-studio
>>
>> Normally Google is my friend, but today it hates me. Because no such
>> feature exists for MSVC that I saw.
>
> The stackoverflow suggests it is possible for MSVC.
>
> Thinking about it some more I think what I'm suggesting is the wrong
> approach. If you're writing C++ code you should avoid coupling your
> classes to allow dependency injection (i.e. you pick how classes are
> coupled at run time not at compile time). If your classes are written
> with dependency injection in mind then you don't need the weak symbol
> stuff I was talking about.

I managed to find MSVC information outside of the SO question (No, I
never skimmed through it sufficiently to find any information directly
there on it). Apparently MSVC will prioritize symbols in .OBJ files
over those found in .LIB without any warnings or errors. So only
special case logic is needed for GCC on Linux (the #pragma weak
<symbol> format).

I agree with the principle of runtime dependency injection. It's
necessary when mocking across library boundaries. However, my two main
concerns:

1) Complexity overhead (Objects will now become more complex to
construct, as dependencies must be fulfilled externally). This appears
to be a common concern with dependency injection, however factories
and reasonable defaults normally will help counter the issue.
2) Compile time polymorphism for dependency injection (i.e. templates)
may not be an option. Template classes are not compiled into static
libs, so there may even be a way to do this. However slightly related
to #1, it forces a class to become a template when it otherwise would
not need to be one (remedy would be an alias serving a default
template argument).

I think I can make this work, thanks to the fine suggestions here.
Much appreciated guys.


More information about the CMake mailing list