[Insight-users] build of cableswig - how to specify the SWIG Lib directory?

Darren Weber darren.weber.lists at gmail.com
Mon May 18 14:38:56 EDT 2009


Hi Gaëtan,

Thanks for pointing out the prior bug about porting cableswig to Debian.  As
I've discovered previously, Debian is quick to adopt and resolve porting
issues, more so than most other open-source porting systems; so it's no
surprise someone on Debian has picked up this issue already.  It looks like
the diff file attached to that bug report could be used to patch the cvs
checkout.

Before I leap off that cliff, it would be best to have an authoritative
perspective on that patch and whether it is the "right" or preferred
solution to this installation problem for a stand-alone cableswig port.

Here is the diff from that bug report:

##############BEGIN DIFF
diff -u -r cableswig-0.1.0+cvs20080107.orig/SWIG/CMakeLists.txt
cableswig-0.1.0+cvs20080107.new/SWIG/CMakeLists.txt
--- cableswig-0.1.0+cvs20080107.orig/SWIG/CMakeLists.txt    2007-01-10
10:31:37.000000000 -0600
+++ cableswig-0.1.0+cvs20080107.new/SWIG/CMakeLists.txt    2008-01-07
22:54:23.000000000 -0600
@@ -25,6 +25,10 @@
 SET(SWIG_CXX "\"${CMAKE_CXX_COMPILER}\"")
 SET(SWIG_PLATFORM "\"${CMAKE_SYSTEM}-${CMAKE_C_COMPILER}\"")

+# Install support library.
+SET(SWIG_LIB_INSTALL
+  ${CMAKE_INSTALL_PREFIX}/${CableSwig_INSTALL_ROOT}lib/CableSwig/SWIGLib)
+
 INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFiles.cmake)
 INCLUDE (${CMAKE_ROOT}/Modules/CheckLibraryExists.cmake)

@@ -158,7 +162,4 @@
 CONFIGURE_FILE(${SWIG_SOURCE_DIR}/SWIGConfig.cmake.in
   ${SWIG_BINARY_DIR}/SWIGConfig.cmake @ONLY IMMEDIATE)

-# Install support library.
-SET(SWIG_LIB_INSTALL
-  ${CMAKE_INSTALL_PREFIX}/${CableSwig_INSTALL_ROOT}lib/CableSwig/SWIGLib)
 SUBDIRS(Lib)
Only in cableswig-0.1.0+cvs20080107.new/SWIG: CMakeLists.txt~
##############END DIFF


The CMakeLists.txt file from the CVS (date 20090514) is attached.  This is
NOT the same file used to generate the diff above, it is the "current" cvs
file that I'm using at the moment for the MacPorts port (we need some kind
of date tag to ensure the port is identical and working for a particular
checkout).  Note these lines in this CMakeLists.txt:

##############BEGIN snips from cableswig-cvs-20090514/SWIG/CMakeLists.txt
  6 SET(-swig_lib- ${SWIG_SOURCE_DIR}/Lib)
...
 22 SET(SWIG_LIBDIR "${CMAKE_INSTALL_PREFIX}/lib")
 23 SET(LIBDIR "\"${SWIG_LIBDIR}\"")
 24 SET(SWIG_LIB "\"${SWIG_SOURCE_DIR}/Lib\"")
...
118 SET(SWIG_MODULES_PATH ${SWIG_SOURCE_DIR}/CMake)
...
148 SET(SWIG_EXECUTABLE
"${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/swig")
149 SET(SWIG_LIB_DIR "${SWIG_SOURCE_DIR}/Lib")
150 SET(SWIG_COMMON_INCLUDES "${SWIG_LIB_DIR}")
...
155 # Prepare find/use files
156 SET(SWIG_USE_FILE ${SWIG_SOURCE_DIR}/UseSWIG.cmake)
157 SET(SWIG_USING_SWIG ${SWIG_SOURCE_DIR}/CMake/UsingSwig.cmake)
158 CONFIGURE_FILE(${SWIG_SOURCE_DIR}/SWIGConfig.cmake.in
159   ${SWIG_BINARY_DIR}/SWIGConfig.cmake @ONLY IMMEDIATE)
160
161 # Install support library.
162 SET(SWIG_LIB_INSTALL
163
${CMAKE_INSTALL_PREFIX}/${CableSwig_INSTALL_ROOT}lib/CableSwig/SWIGLib)
164 SUBDIRS(Lib)
##############END cableswig-20090514/SWIG/CMakeLists.txt


So, the diff in the bug report will not apply directly to this cvs version
of the CMakeLists.txt file.  Now, there are numerous variables that appear
to define something related to the SWIG library location.  A simple solution
is to identify THE variable that will be most effective in setting the
SWIGLib search path for the cswig binary so that it will look for the
library below the INSTALL_PREFIX/lib path (i.e.:
INSTALL_PREFIX/lib/CableSwig/SWIGLib).  If that variable can be set using a
-D option to cmake, the problem could be resolved easily.  Without an
intimate knowledge of cableswig, I cannot determine how to resolve the
problem.

Take care,
Darren




2009/5/17 Gaëtan Lehmann <gaetan.lehmann at jouy.inra.fr>

>
> Hi Darren,
>
> Could it be related to http://www.itk.org/Bug/view.php?id=6224 ?
>
> Gaëtan
>
>
> Le 16 mai 09 à 04:32, Darren Weber a écrit :
>
>
>
>> Hi Luis,
>>
>> Thanks for pointing out the tutorial, nice tip.  I do have a successful
>> build, but it seems that I need something more than a vanilla build and
>> install.  I apologize in advance for this long email, but there's no other
>> way than this to explain the situation.  I may need a patch to somehow
>> change how the cswig binary finds the SWIGLib directory.
>>
>> I'm a registered MacPorts developer and my focus is on porting kitware
>> tools into the MacPorts system (see http://www.macports.org/).  I got
>> involved in this so that I can document the dependencies and the build
>> configuration in a functional system for OSX software distribution that will
>> replicate a given installation on any compatible OSX system, with MacPorts
>> installed.
>>
>> In order to use MacPorts, all the configuration details are saved in a
>> Portfile in the MacPorts svn, i.e.:
>> http://svn.macports.org/repository/macports/
>>
>> The Portfiles are pseudo tcl scripts.  The content is fairly easy to read
>> too, even if you don't know tcl.  For example, this is the Portfile I've
>> been working on for vtk 5.4.0:
>>
>> http://svn.macports.org/repository/macports/trunk/dports/graphics/vtk-devel/Portfile
>> Similarly, this is the Portfile for itk 3.12.0 (still a work in progress):
>>
>> http://svn.macports.org/repository/macports/trunk/dports/graphics/InsightToolkit/Portfile
>> Also, here is a recent commit on a cableswig Portfile (a work in
>> progress):
>>
>> http://svn.macports.org/repository/macports/trunk/dports/devel/cableswig/Portfile
>>
>> One thing to understand about MacPorts is that all the configuration and
>> builds occur in a *temporary* workspace and the 'make install' is directed
>> to a *temporary* DESTDIR within the workspace.  Once all the files are
>> installed in the DESTDIR, the MacPorts system scans and logs all the files,
>> then "installs" them to a software repository.  The final "activation" is
>> actually a process of hardlinks from the CMAKE_INSTALL_PATH to this software
>> repository.  A library or application can be "deactivated" by simply
>> removing the hard links and it can be immediately re-activated by creating
>> the hard links again.  It's a neat system that includes dependency
>> resolution and it's sweet when it all works well.
>>
>> Note that the cmake variables have been updated to the following (which
>> must be defined using the command line cmake with -D options for variables;
>> ${prefix} is '/opt/local'):
>>
>> configure.args-append \
>>    -DBISON_YACC:FILEPATH=${prefix}/bin/bison \
>>    -DCMAKE_BUILD_TYPE:STRING=Release \
>>    -DCMAKE_INSTALL_PREFIX:PATH=${prefix} \
>>    -DCMAKE_OSX_SYSROOT=${universal_sysroot} \
>>    -DCMAKE_SKIP_RPATH:BOOL=OFF \
>>    -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
>>    -DCSWIG_USE_SYSTEM_GCCXML:BOOL=ON \
>>    -DSWIG_BUILD_EXAMPLES:BOOL=OFF \
>>    -DBUILD_TESTING:BOOL=OFF
>>
>>
>> Here's a summary of the build and installation to the DESTDIR (everything
>> works):
>>
>> [... snip the build details ...]
>>
>> Install the project...
>> /opt/local/bin/cmake -P cmake_install.cmake
>> -- Install configuration: "Release"
>> -- Installing:
>> /opt/local/var/macports/build/_Users_dweber_ports_devel_cableswig/work/destroot/opt/local/lib/CableSwig/CableSwigConfig.cmake
>> -- Installing:
>> /opt/local/var/macports/build/_Users_dweber_ports_devel_cableswig/work/destroot/opt/local/lib/CableSwig/SWIGLib/_std_deque.i
>> ...[snip a few files]...
>>
>>
>> [ dweber at X ~/ports/devel/cableswig ]$ ll work/destroot/opt/local/bin/
>> total 1.8M
>> -rwxr-xr-x 1 root admin 445K 2009-05-15 18:42 cableidx*
>> -rwxr-xr-x 1 root admin 1.4M 2009-05-15 18:43 cswig*
>>
>> [ dweber at X ~/ports/devel/cableswig ]$ ll
>> work/destroot/opt/local/lib/CableSwig/
>> total 4.0K
>> -rw-r--r--  1 root admin 314 2009-05-15 18:37 CableSwigConfig.cmake
>> drwxr-xr-x 21 root admin 714 2009-05-15 18:43 SWIGLib/
>> [ dweber at X ~/ports/devel/cableswig ]$ ll
>> work/destroot/opt/local/lib/CableSwig/SWIGLib/
>> total 96K
>> -rw-r--r--  1 root admin 4.1K 2003-04-09 10:34 _std_deque.i
>> -rw-r--r--  1 root admin  659 2004-02-18 06:45 allkw.swg
>> -rw-r--r--  1 root admin 2.9K 2004-02-18 06:45 carrays.i
>> -rw-r--r--  1 root admin 2.5K 2004-02-18 06:45 cdata.i
>> -rw-r--r--  1 root admin 2.2K 2004-02-18 06:45 cmalloc.i
>> -rw-r--r--  1 root admin 7.3K 2004-06-15 08:26 common.swg
>> -rw-r--r--  1 root admin 6.2K 2003-04-09 10:34 constraints.i
>> -rw-r--r--  1 root admin 3.6K 2004-02-18 06:45 cpointer.i
>> -rw-r--r--  1 root admin   78 2003-04-09 10:34 cstring.i
>> -rw-r--r--  1 root admin 8.6K 2004-02-18 06:45 exception.i
>> drwxr-xr-x 14 root admin  476 2009-05-15 18:43 java/
>> -rw-r--r--  1 root admin 2.0K 2004-02-18 06:45 math.i
>> -rw-r--r--  1 root admin  115 2003-04-09 10:34 pointer.i
>> drwxr-xr-x 33 root admin 1.1K 2009-05-15 18:43 python/
>> -rw-r--r--  1 root admin  118 2003-04-09 10:34 std_deque.i
>> -rw-r--r--  1 root admin  276 2004-02-18 06:45 stl.i
>> -rw-r--r--  1 root admin  13K 2004-02-18 06:45 swig.swg
>> -rw-r--r--  1 root admin   74 2004-02-18 06:45 swigrun.i
>> drwxr-xr-x 15 root admin  510 2009-05-15 18:43 tcl/
>>
>>
>>
>> From here on, MacPorts takes over the "installation" and "activation".
>> This is essentially a two step process: (a) the entire installation is
>> "installed" into a software repository in /opt/local/var/macports/software/,
>> then (b) the files in that repository are "activated" by hard links to
>> ${prefix} locations.  After that, the temporary build tree is removed,
>> including the DESTDIR.
>>
>>
>> ####################BEGIN MACPORTS INSTALL and ACTIVATE
>>
>> [ dweber at X ~/ports/devel/cableswig ]$ sudo port -d install cableswig
>>
>> --->  Installing cableswig @20090514_0
>> DEBUG: Executing org.macports.install (cableswig)
>> DEBUG: installing directory:
>> /opt/local/var/macports/software/cableswig/20090514_0/opt
>> DEBUG: installing directory:
>> /opt/local/var/macports/software/cableswig/20090514_0/opt/local
>> DEBUG: installing directory:
>> /opt/local/var/macports/software/cableswig/20090514_0/opt/local/bin
>> DEBUG: installing file:
>> /opt/local/var/macports/software/cableswig/20090514_0/opt/local/bin/cableidx
>> DEBUG: installing file:
>> /opt/local/var/macports/software/cableswig/20090514_0/opt/local/bin/cswig
>> DEBUG: installing directory:
>> /opt/local/var/macports/software/cableswig/20090514_0/opt/local/lib
>> DEBUG: installing directory:
>> /opt/local/var/macports/software/cableswig/20090514_0/opt/local/lib/CableSwig
>> DEBUG: installing file:
>> /opt/local/var/macports/software/cableswig/20090514_0/opt/local/lib/CableSwig/CableSwigConfig.cmake
>> DEBUG: installing directory:
>> /opt/local/var/macports/software/cableswig/20090514_0/opt/local/lib/CableSwig/SWIGLib
>> DEBUG: installing file:
>> /opt/local/var/macports/software/cableswig/20090514_0/opt/local/lib/CableSwig/SWIGLib/_std_deque.i
>> DEBUG: installing file:
>> /opt/local/var/macports/software/cableswig/20090514_0/opt/local/lib/CableSwig/SWIGLib/allkw.swg
>> DEBUG: installing file:
>> /opt/local/var/macports/software/cableswig/20090514_0/opt/local/lib/CableSwig/SWIGLib/carrays.i
>> .
>> .
>> [snipped]
>> .
>> .
>> DEBUG: installing file:
>> /opt/local/var/macports/software/cableswig/20090514_0/opt/local/lib/CableSwig/SWIGLib/tcl/tcl8kw.swg
>> DEBUG: installing file:
>> /opt/local/var/macports/software/cableswig/20090514_0/opt/local/lib/CableSwig/SWIGLib/tcl/tclsh.i
>> DEBUG: installing file:
>> /opt/local/var/macports/software/cableswig/20090514_0/opt/local/lib/CableSwig/SWIGLib/tcl/typemaps.i
>> DEBUG: installing file:
>> /opt/local/var/macports/software/cableswig/20090514_0/opt/local/lib/CableSwig/SWIGLib/tcl/wish.i
>> DEBUG: Executing org.macports.activate (cableswig)
>>
>> --->  Activating cableswig @20090514_0
>> DEBUG: activating directory: /
>> DEBUG: activating directory: /opt
>> DEBUG: activating directory: /opt/local
>> DEBUG: activating directory: /opt/local/bin
>> DEBUG: activating file: /opt/local/bin/cableidx
>> DEBUG: activating file: /opt/local/bin/cswig
>> DEBUG: activating directory: /opt/local/lib
>> DEBUG: activating directory: /opt/local/lib/CableSwig
>> DEBUG: activating file: /opt/local/lib/CableSwig/CableSwigConfig.cmake
>> DEBUG: activating directory: /opt/local/lib/CableSwig/SWIGLib
>> DEBUG: activating file: /opt/local/lib/CableSwig/SWIGLib/_std_deque.i
>> DEBUG: activating file: /opt/local/lib/CableSwig/SWIGLib/allkw.swg
>> DEBUG: activating file: /opt/local/lib/CableSwig/SWIGLib/carrays.i
>> DEBUG: activating file: /opt/local/lib/CableSwig/SWIGLib/cdata.i
>> .
>> .
>> [snipped]
>> .
>> .
>> DEBUG: activating file: /opt/local/lib/CableSwig/SWIGLib/tcl/std_vector.i
>> DEBUG: activating file: /opt/local/lib/CableSwig/SWIGLib/tcl/swigtcl8.swg
>> DEBUG: activating file: /opt/local/lib/CableSwig/SWIGLib/tcl/tcl8.swg
>> DEBUG: activating file: /opt/local/lib/CableSwig/SWIGLib/tcl/tcl8kw.swg
>> DEBUG: activating file: /opt/local/lib/CableSwig/SWIGLib/tcl/tclsh.i
>> DEBUG: activating file: /opt/local/lib/CableSwig/SWIGLib/tcl/typemaps.i
>> DEBUG: activating file: /opt/local/lib/CableSwig/SWIGLib/tcl/wish.i
>>
>> --->  Cleaning cableswig
>> DEBUG: Executing org.macports.clean (cableswig)
>>
>> --->  Removing build directory for cableswig
>> DEBUG: Removing directory:
>> /opt/local/var/macports/build/_Users_dweber_ports_devel_cableswig
>> DEBUG: delete:
>> /opt/local/var/macports/build/_Users_dweber_ports_devel_cableswig
>> DEBUG: Removing symlink: /Users/dweber/ports/devel/cableswig/work
>> DEBUG: delete: /Users/dweber/ports/devel/cableswig/work
>>
>> ####################END MACPORTS INSTALL and ACTIVATE
>>
>>
>> So far so good, everything appears to work.  Now, for the run-time
>> failure, cswig is looking for SWIGLib in the *source* path, not the
>> installation library path in /opt/local/lib/CableSwig/SWIGLib:
>>
>> [ dweber at X ~/ports/devel/cableswig ]$ ls -l /opt/local/bin/cswig
>> -rwxr-xr-x 2 root admin 1.4M 2009-05-15 18:43 /opt/local/bin/cswig*
>> [ dweber at X ~/ports/devel/cableswig ]$ which cswig
>> /opt/local/bin/cswig
>> [ dweber at X ~/ports/devel/cableswig ]$ cswig
>> Cannot find SWIG Lib directory.  Checked:
>>
>>  /opt/local/var/macports/build/_Users_dweber_ports_devel_cableswig/work/cableswig-20090514/SWIG/Lib
>> [ dweber at X ~/ports/devel/cableswig ]$ ls
>> /opt/local/lib/CableSwig/SWIGLib/
>> _std_deque.i  carrays.i  cmalloc.i   constraints.i  cstring.i    java/
>> pointer.i  std_deque.i  swig.swg   tcl/
>> allkw.swg     cdata.i    common.swg  cpointer.i     exception.i  math.i
>>  python/    stl.i        swigrun.i
>>
>>
>> In looking at the CMakeLists.txt files, I wonder what controls the SWIGLib
>> path setting, e.g.:
>>
>> LINK_DIRECTORIES( "${LIBRARY_OUTPUT_PATH}" )
>> LINK_DIRECTORIES( "${EXECUTABLE_OUTPUT_PATH}" )
>>
>> Near the end of CMakeLists.txt file in the section "# Settings for the
>> install tree." we have:
>>
>> SET(CableSwig_DEFAULT_LIB_CONFIG
>> ${CMAKE_INSTALL_PREFIX}/${CableSwig_INSTALL_ROOT}lib/CableSwig/SWIGLib)
>>
>> This seems to control the location of the installation for SWIGLib, but
>> not how cswig links to it (after installation).
>>
>> Again, sorry about the long explanation; there it is.  Will it be possible
>> to get this working as a stand-alone installation?  It seems that cableswig
>> is primarily designed to build and run within the Insight build, rather than
>> as a stand-alone binary.  To provide the latter, I wonder if it's possible
>> to identify a configuration variable to change how cswig links to or finds
>> the SWIGLib path?
>>
>> Kind regards,
>> Darren
>>
>>
>>
>>
>>
>> On Fri, May 15, 2009 at 4:13 AM, Luis Ibanez <luis.ibanez at kitware.com>
>> wrote:
>> Hi Darren,
>>
>> You may find useful to look at the Tutorial:
>>
>> http://farsight-toolkit.org/wiki/FARSIGHT_Tutorials/Building_Software/Building_CableSwig
>>
>> Please let us know if you still find any problems.
>>
>>
>>   Thanks
>>
>>
>>      Luis
>>
>>
>> --------------------
>> Darren Weber wrote:
>>
>> A source build and binary install for cswig fails with:
>>
>> [ dweber at X ~/ports ]$ cswig
>> Cannot find SWIG Lib directory.  Checked:
>>
>>  /opt/local/var/macports/build/_Users_dweber_ports_devel_cableswig/work/cableswig-20090514/SWIG/Lib
>> [ dweber at X ~/ports ]$
>> [ dweber at X ~/ports ]$ otool -L /opt/local/bin/cswig
>> /opt/local/bin/cswig:
>>   /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version
>> 7.4.0)
>>   /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version
>> 1.0.0)
>>   /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version
>> 111.1.3)
>>
>>
>> This build of cableswig must use a DESTDIR on the install and the final
>> installation is actually moved from that DESTDIR into a ${prefix} location
>> (actually /opt/local in this case).  The final location for the SWIG Lib is
>> actually /opt/local/lib/CableSwig/SWIGLib/.
>>
>> How can we specify this SWIG Lib directory during the build configuration?
>>  Is it a cmake variable or is it a CMakeList.txt setting?
>>
>> Thanks in advance,
>> Darren
>>
>>
>> ------------------------------------------------------------------------
>>
>> _____________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.itk.org/mailman/listinfo/insight-users
>>
>> _____________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.itk.org/mailman/listinfo/insight-users
>>
>
> --
> Gaëtan Lehmann
> Biologie du Développement et de la Reproduction
> INRA de Jouy-en-Josas (France)
> tel: +33 1 34 65 29 66    fax: 01 34 65 29 09
> http://voxel.jouy.inra.fr  http://www.mandriva.org
> http://www.itk.org  http://www.clavier-dvorak.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090518/8f6c6a1f/attachment-0001.htm>


More information about the Insight-users mailing list