[Insight-users] Re: Directory search for linking libraries

Luis Ibanez luis.ibanez@kitware.com
Thu, 01 May 2003 16:30:54 -0400


Hi Aloys,

You can put your library in any directory.

Just make sure that the directory you select
is in the list of directories of the CMake
command:


LINK_DIRECTORIES(
   directory1
   directory2
   ...
)


You can make your CMakeLists.txt more portable
if you ask the user to provide the full location
of the library at configuration time. In this
case you can do something like:


FIND_LIBRARY(NRUTILS_LIBRARY NAMES nrutils
       PATHS /usr/lib /usr/local/lib /usr/share/lib
     )


This is probably the most convenient way of locating
your library. After "NAMES" you put all the common
names given to your library, "nrutils" will do it so far.
After "PATHS" you put all the directories that are candidates
to be searched.  CMAke will visit those directories looking
for the library. If the library is still not found, the
user can specify the real location from CMake interface
(ccmake in unix, CMakeSetup in windows) during the
configuration process.


Regards


   Luis


---------------------------------
duboisda@tele.ucl.ac.be wrote:
>    Hi Luis,
> 
>         thanks for your fast answer. Do you know in wich directory I have
> to place my file libnrutils.a ?
> 
>            thanks,
> 
>           aloys
> 
> 
> 
> On Thu, 01 May 2003 14:05:18 -0400
> Luis Ibanez <luis.ibanez@kitware.com> wrote:
> 
> 
>>Hi Aloys
>>
>>
>>Just add the following line to your
>>CMakeLists.txt file
>>
>>   TARGET_LINK_LIBRARIES(myExecutable myLibrary)
>>
>>in your case
>>
>>   TARGET_LINK_LIBRARIES(myExecutable   nrutils  )
>>
>>It is quite likely that your CMakeLists.txt
>>file already has a TARGET_LINK_LIBRARIES
>>command, in which case, you just add the
>>name of your library to the list.
>>
>>The basic structure of this CMake command is:
>>
>>   TARGET_LINK_LIBRARIES( executable lib1 lib2 lib3 ... libN)
>>
>>It will probably end up being something like
>>
>>   TARGET_LINK_LIBRARIES(myExecutable ITKCommon ITKIO nrutils )
>>
>>
>>Regards
>>
>>
>>   Luis
>>
>>
>>
>>-------------------------
>>
>>duboisda@tele.ucl.ac.be wrote:
>>
>>> Hi,
>>>
>>>     I want to link Itk and a static library we created. We have some
>>>files .c compiled in .o and we created a .a file named libnrutils.a .
>>>What have I to do in the CMake file to use this library in my
>>>project?
>>>
>>>           thanks for your help,
>>>
>>>      aloys
>>>_______________________________________________
>>>Insight-users mailing list
>>>Insight-users@public.kitware.com
>>>http://public.kitware.com/mailman/listinfo/insight-users
>>>
>>
>>
>>
>>_______________________________________________
>>Insight-users mailing list
>>Insight-users@public.kitware.com
>>http://public.kitware.com/mailman/listinfo/insight-users
>>
> 
> 
> 
>