[CMake] Project being (unnecessarily) relinked

Jesper Eskilson jesper at eskilson.se
Tue Sep 11 03:03:24 EDT 2007


Bill Hoffman wrote:
> Jesper Eskilson wrote:
>> Matthew Smith wrote:
>>> Jesper Eskilson wrote:
>>>
>>>>
>>>> I'm still very much interested in an answer to this question.
>>>
>>> Regarding suppressing unnecessary relinking, I had a similar problem
>>> in my application (QTM) in which it was relinked at "make install"
>>> stage, often to a different version of Qt to the one I had chosen to
>>> link it to at build stage.  I included the following code, and the
>>> problem was solved:
>>>
>>> SET_TARGET_PROPERTIES( ${PROGNAME} PROPERTIES
>>> INSTALL_RPATH_USE_LINK_PATH TRUE )
>>
>> My problem appears on Windows with Visual Studio *only*. I though RPATH
>> was a Linux/Unix-issue only.
> RPATH is not your problem, and windows should not relink each time.  

Yes, exactly. That's what I'm trying to say.

> You need to figure out what is making it re-link, some file must be
> changing with each build.

I've checked the file tree between each build, and it's nothing that simple.

This is what I previously wrote about my analysis of the problem:

> I think I've located the problem. The project in question uses
> target_link_library() in a possibly non-kosher way:
> 
> target_link_library(Foo Bar.lib)
> 
> That is, the top-level target Foo should include "Bar.lib" on its
> command line. This seems to work insofar that it actually performs
> the link correctly, but for some reason it always relinks as well.
> 
> A related question: if I include an external project in my solution
> using
> 
> include_external_msproject(Bar ../../Bar/Bar.vcproj)
> 
> can I later refer to this project using
> 
> target_link_libraries(Foo Bar)
> 
> More generally, what is the correct way to specify that a CMake
> target should be linked with some external library?

It is this last question I would like to get an answer to.

--
/Jesper


-- 
/Jesper


More information about the CMake mailing list