View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0004145CMakeModulespublic2006-12-05 17:532008-01-10 16:23
Reporteraxel.roebel 
Assigned ToBill Hoffman 
PrioritylowSeveritymajorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0004145: 2.4.5!!! FindSWIG.cmake assumes strange install locations
DescriptionCurrent swig

configure; make, make install

procedure installs swig files
in /usr/local/share/swig/1.3.31
FindSWIG looks in

FIND_PATH(SWIG_DIR
  swig.swg
  /usr/share/swig1.3
  /usr/lib/swig1.3
  /usr/local/share/swig1.3)

???

The whole SWIG macro relies on non standard
directory locations so the swig installation is not found on most of the systems.

The attached version is completely backwards compatible but uses the swig executable
command line help to detect the installation directory. The initial version of the detection system s maintained and the executable is used only in case the initial version fails.

Axel
TagsNo tags attached.
Attached Files? file icon FindSWIG.cmake [^] (2,430 bytes) 1969-12-31 19:00
? file icon FindSWIG.cmake-2 [^] (2,069 bytes) 1969-12-31 19:00
? file icon FindSWIG.cmake-3 [^] (2,296 bytes) 1969-12-31 19:00
? file icon FindSWIG.cmake-4 [^] (2,261 bytes) 1969-12-31 19:00
? file icon FindSWIG.cmake-5 [^] (2,262 bytes) 1969-12-31 19:00
? file icon FindSWIG.cmake-6 [^] (2,263 bytes) 1969-12-31 19:00

 Relationships

  Notes
(0005890)
Bill Hoffman (manager)
2006-12-06 09:48

It is not as bad as it looks. Please see the documentaion for FIND_PATH, FIND_PROGRAM, etc. They all search in standard system locations automatically. Places like /usr/bin and /usr/local/bin are searched in addition to the places listed in the FIND_* command. But using the swig command is a good idea.
(0005892)
axel.roebel (reporter)
2006-12-06 11:21

Unfortunately it IS as bad as it is looks ;-)
swig.swg is not a binary and it is never located in
a */bin directory neither is it in */lib.
It is normally in

INSTALLPATH/swig/version number/

which as long as FIND_PATH is not looking
recursivly (which according to the doc it doesn't),
will never be found using the path
used in FIND_PATH and Co.

The only thing you can reasonably
rely on is that people put the swig executable
they want to use in their PATH. (on unix that is)



(0005893)
axel.roebel (reporter)
2006-12-06 11:23

BTW you should probably update your bug website to include 2.4.5 as an option to report bugs ;-)
(0005894)
axel.roebel (reporter)
2006-12-06 11:29

And I wonder what the search for SWIGConfig.cmake
happens to do in the FindSWIG.cmake

According to the doc of FIND_PACKAGE
this does not make sense to me.
Because I think SWIG_DIR should have been
set by the project and should not be searched for

Is this a proper use of FIND_PACKAGE
that we should keep?
(0005895)
Bill Hoffman (manager)
2006-12-06 11:37

That is what PATH_SUFFIXES is for.
PATH_SUFFIXES can be used to give sub directories that will be appended to the search paths.

FIND_PROGRAM(swig PATH_SUFFIXES swig/1.3 swig1.3)

For example in python we do this:
 PATH_SUFFIXES
   python2.5/config
   python2.4/config
   python2.3/config
   python2.2/config
   python2.1/config
   python2.0/config
   python1.6/config
   python1.5/config

(0005899)
Tristan Carel (reporter)
2006-12-06 13:45

SWIG_DIR is properly found on Linux Debian thanks to the EXECUTE_PROCESS!!!

But it doesn't on Windows because of the strange thing I told you:
$ which swig
/cygdrive/c/Program Files/swigwin-1.3.31/swig
$ swig -swiglib
c:\Program Files\swigwin-1.3.31\Lib
C:/msys/1.0/local/share/swig/1.3.31
$

I have to apply the following patch on your file:

--- 4145-FindSWIG.cmake 2006-12-06 12:08:01.195527600 -0500
+++ c:/Program Files/CMake 2.4/share/cmake-2.4/Modules/FindSWIG.cmake 2006-12-06 13:35:51.258027600 -0500
@@ -34,8 +34,8 @@
   IF(NOT "${SWIG_EXECUTABLE}" STREQUAL "SWIG_EXECUTABLE-NOTFOUND")
     SET(SWIG ${SWIG_EXECUTABLE})
     EXECUTE_PROCESS(COMMAND ${SWIG} -swiglib OUTPUT_VARIABLE SWIG_DIR_TMP)
- STRING(REGEX REPLACE "[\n\r]" "" SWIG_DIR_TMP_NOCR ${SWIG_DIR_TMP})
- FIND_PATH(SWIG_DIR swig.swg PATHS "${SWIG_DIR_TMP_NOCR}")
+ STRING(REGEX REPLACE "[\n]" ";" SWIG_DIR_TMP_NOCR ${SWIG_DIR_TMP})
+ FIND_PATH(SWIG_DIR swig.swg PATHS ${SWIG_DIR_TMP_NOCR})
     IF(EXISTS ${SWIG_DIR})
       MESSAGE(STATUS "swig install dir -- ${SWIG_DIR}")
       SET(SWIG_FOUND 1)


It still works on Linux.

(0005905)
axel.roebel (reporter)
2006-12-07 13:38

FindSWIG.cmake-2 should take care all of all comments
made by tristan.
(0005906)
Tristan Carel (reporter)
2006-12-07 14:35

1. if the Swig executable version is changed, SWIG_DIR and SWIG_VERSION are not updated. But as there are computed thanks to a EXECUTE_PROCESS, if SWIG_EXECUTABLE changes, SWIG_DIR and SWIG_VERSION must be updated.

2. I'm maybe paranoid, but I guess all internal variables declared by a module should be prefixed by the module's name.

3. in the CMake/Modules/readme.txt, you can read:
"If the QUIET option is given to the command it will set the variable
XXX_FIND_QUIETLY to true before loading the FindXXX.cmake module."

but you use: FIND_SWIG_QUIETLY

4. Previous version only use SWIG_EXECUTABLE, there is no need to introduce a new variable SWIG.


Please see FindSWIG.cmake-3 which take care of this.
Thank you
(0005909)
axel.roebel (reporter)
2006-12-07 17:01

FindSWIG.cmake-3 works perfectly for me.
It would be nice if we could have
it in the upcoming
cmake release.
(0005934)
axel.roebel (reporter)
2006-12-09 17:35

In fact QUIET and REQUIRED flags were not yet
handled correctly because QUITE was necessary for REQUIRED to set an error.
(0005953)
Tristan Carel (reporter)
2006-12-12 11:56

It's perfect to me. I guess the file can be commited.
(0006301)
irwin (reporter)
2007-01-31 22:15

FindSWIG.cmake-4 was not quite perfect. Older swig's (e.g., Debian stable, swig-1.3.24) return their version to STDERR rather than the STDOUT used by modern swig's. Also, FindSWIG.cmake-4 has improperly nested if statements. I have corrected both issues in FindSWIG.cmake-5 (attached) which is perfect for me.
(0006472)
axel.roebel (reporter)
2007-02-20 10:12

Thanks Alan!

However, after the last change, version 5, the error message for the swig -version call would use a variable, that was no longer existing.

This is fixed in version 6.
(0007742)
Mathieu Malaterre (developer)
2007-05-31 09:02

I have merge my copy of findswig with the one from the bug tracker. My work can be found here:

http://gdcm.svn.sourceforge.net/viewvc/gdcm/Sandbox/TestSWIG/FindSWIG13.cmake?view=markup [^]

This is a very special case where people are using swig 1.1 (typically debian oldstable).

HTH
Mathieu
(0010118)
Bill Hoffman (manager)
2008-01-10 16:23

$ cvs commit -m "BUG: fix for bug 4145 much better findSwig" FindSWIG.cmake
/cvsroot/CMake/CMake/Modules/FindSWIG.cmake,v <-- FindSWIG.cmake
new revision: 1.10; previous revision: 1.9

OK, I put in the -6 version.

 Issue History
Date Modified Username Field Change
2008-01-10 16:23 Bill Hoffman Note Added: 0010118
2008-01-10 16:23 Bill Hoffman Status assigned => closed
2008-01-10 16:23 Bill Hoffman Resolution open => fixed


Copyright © 2000 - 2018 MantisBT Team