[CMake] Project being (unnecessarily) relinked

Mike Jackson imikejackson at gmail.com
Tue Sep 11 07:41:28 EDT 2007



On Sep 11, 2007, at 3:03 AM, Jesper Eskilson wrote:

>> 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.


Say you have  another project that produces a library called  
libBar.dll and that library is located in C:\Libs then you can refer  
to that library in CMake directly. In other words, the cmake code you  
have is absolutely correct:

Target_link_Libraries(Foo Bar)

with the following caveat: libBar.dll MUST be in a known directory  
that the linker will look in. You can make sure of this by adding the  
following cmake code above the "target_link_libraries" code:

  LINK_DIRECTORIES ("C:\Libs")


  ---- Here is the documentation for the command ---------
[mjackson at Thor:mjackson]$ cmake --help LINK_DIRECTORIES
   LINK_DIRECTORIES
        Specify directories in which to search for libraries.

          LINK_DIRECTORIES(directory1 directory2 ...)

        Specify the paths in which the linker should search for  
libraries.

Hope that helps.
-- 
Mike Jackson   Senior Research Engineer
Innovative Management & Technology Services



More information about the CMake mailing list