[CMake] Adding a Visual Studio 10 specific flag

Yuri Timenkov yuri at timenkov.ru
Fri Jul 15 06:45:11 EDT 2011


Hi Amir,

Although It's better to hear answer from CMake authors I could try to give
you some clues.

If your project is completely managed by CMake, it's better to employ target
property. So, you should add one to property definition map (in
cmTarget.cxx), say "MS_USE_LIBRARY_DEPENDENCY_INPUTS".

And then, use it to generate appropriate statements. It's reasonable to use
it only for VS2010, so you should look at
cmVisualStudio10TargetGenerator.cxx (at the end of WriteLinkOptions
function), where LinkLibraryDependencies is currently added. Just add
another if branch, checking if property is set and add there
<UseLibraryDependencyInputs> tag. Check for property may look like:

if ( this->Target->GetPropertyAsBool("MS_USE_LIBRARY_DEPENDENCY_INPUTS") )


Alternatively you can use different approach: set such property on static
libraries, and then (in the same place, in
cmVisualStudio10TargetGenerator.cxx ) check if target depends on static
library with this property set. See
cmGlobalVisualStudio8Generator::NeedLinkLibraryDependencies
(cmGlobalVisualStudio8Generator.cxx) for reference.

As you can see, it should be quite easy from technical point of view, but
you have to make hard architectural decision :). May be there is a way to
implement it without properties.

Regards,
Yuri

On Wed, Jul 13, 2011 at 10:21 PM, Amir Mohammadkhani-Aminabadi <
amir at mohammadkhani.eu> wrote:

> Hi Yuri,
>
> thanks for the feedback,
>
>
>  These flags used by CMake internally to properly handle dependencies (as I
>> can tell from source code). LinkLibraryDependencies is turned on when your
>> target depends on target added wihth include_external_msproject. As for
>> UseLibraryDependencyInputs - you can't set this flag with CMake.
>>
>
> Sadly I'm more interested in the UseLibraryDependencyInputs because this
> one makes or breaks the result when compiled as static lib.
> The other solution, besides refactoring the code, is to compile as DLL.
> This problem has only surfaced with MSVC10 and did not
> happen with previous versions. While I realize the problem should be dealt
> with in other ways eventually I'd like to try and fix the cmake
> build for MSVC10 without too many changes.
>
> Could you suggest a mechanism how this could be set? Has there been similar
> problems with other environments?
> I'd gladly implement the feature if you could point me into the right
> direction. From a quick study of the cmake
> code I got the impression that cmake does not deal with flags that have no
> command line equivalent.
>
>
> cheers
> amir
>
> ______________________________**_________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/**
> opensource/opensource.html<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<http://www.cmake.org/Wiki/CMake_FAQ>
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/**listinfo/cmake<http://www.cmake.org/mailman/listinfo/cmake>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110715/ea280396/attachment-0001.htm>


More information about the CMake mailing list