[CMake] swig and LINK_DIRECTORIES

Alan W. Irwin irwin at beluga.phys.uvic.ca
Fri Feb 9 14:10:28 EST 2007


On 2007-02-09 11:30-0700 Karl Merkley wrote:

> I have a file that I am swigging that needs to be linked with files that 
> reside someplace else on the OS.  How can I get the UseSWIG to look for the 
> libraries in the correct  place?
>
> Below is a truncated CMakeLists.txt  that approximates what I am trying to 
> do.
>
> PROJECT(nurbs)
>
> FIND_PACKAGE(SWIG REQUIRED)
> INCLUDE(${SWIG_USE_FILE})
> FIND_PACKAGE(PythonLibs REQUIRED)
>
> INCLUDE(UseACIS.cmake)
>
> SET SOURCE_FILE_PROPERTIES(nurbs.i PROPERTIES CPLUSPLUS ON OBJECT_DEPENDS 
> nurbs.hpp)
> SWIG_ADD_MODULE(nurbs python nurbs.i nurbs.hpp)
>
> LINK_DIRECTORIES( ${ACIS_LIBRARY_DIR})  #this doesn't work!
>
> SWIG_LINK_LIBRARIES(nurbs ${PYTHON_LIBRARIES}  ${ACIS_LIBS})

SWIG_LINK_LIBRARIES is essentially the same as TARGET_LINK_LIBRARIES.
So use exactly the same rules as you would in the
TARGET_LINK_LIBRARIES case to locate external libraries.  That is, use
FIND_LIBRARY to find the absolute path+filename of the required libraries,
and TARGET_LINK_LIBRARIES and SWIG_LINK_LIBRARIES will know how to set
up the linking -L and -l options from that absolute location.

Print out ${ACIS_LIBS} to debug this.  It should be in an absolute path
form, e.g., /usr/lib/libacis.so.  If it is not, fix it.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the Yorick front-end to PLplot (yplot.sf.net); the
Loads of Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


More information about the CMake mailing list