[CMake] FindPerlLibs.cmake and FindSwig.cmake outdated!

Axel Roebel Axel.Roebel at ircam.fr
Sat Dec 9 17:43:22 EST 2006


On Thursday 07 December 2006 22:57, Axel Roebel wrote:
> > 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
>
> yes in fact I didn't read that file.

I have now read all the stuff in the readme I find that the handling of REQUIRED and QUIETKY flags was still not correct in FindSWIG.cmake
Apparently this is a copy and paste error and many of the Find packages
are not dealing with these flags correctly.

The FindBoost.cmake for example does the same as the last version of the FindSWIG.cmake

IF(NOT Boost_FOUND)
  IF(NOT Boost_FIND_QUIETLY)
    MESSAGE(STATUS "Boost was not found. ${BOOST_DIR_MESSAGE}")
  ELSE(NOT Boost_FIND_QUIETLY)
    IF(Boost_FIND_REQUIRED)
      MESSAGE(FATAL_ERROR "Boost was not found. ${BOOST_DIR_MESSAGE}")
    ENDIF(Boost_FIND_REQUIRED)
  ENDIF(NOT Boost_FIND_QUIETLY)
ENDIF(NOT Boost_FOUND)

This boils down to having a fatal error only if the QUIET flag was given
together with the REQUIRED flag, which I suppose was not intended.

In FindVTK.cmake we see

  IF(NOT VTK_FIND_QUIETLY)
    MESSAGE(FATAL_ERROR ${VTK_DIR_MESSAGE})
  ELSE(NOT VTK_FIND_QUIETLY)
    IF(VTK_FIND_REQUIRED)
      MESSAGE(FATAL_ERROR ${VTK_DIR_MESSAGE})
    ENDIF(VTK_FIND_REQUIRED)
  ENDIF(NOT VTK_FIND_QUIETLY)

which means we always get a fatal error which is also not what the readme suggests.

I updated the FindSWIG.cmake to do

IF(NOT SWIG_FOUND)
  IF(NOT SWIG_FIND_QUIETLY)
    IF(SWIG_FIND_REQUIRED)
      MESSAGE(FATAL_ERROR "SWIG was not found. Please specify Swig executable location")
    ELSE(SWIG_FIND_REQUIRED)
      MESSAGE(STATUS "SWIG was not found. Please specify Swig executable location")
    ENDIF(SWIG_FIND_REQUIRED)
  ENDIF(NOT SWIG_FIND_QUIETLY)
ENDIF(NOT SWIG_FOUND)

which seems me to do what the readme suggests with the interpretation that
QUIET takes precedence over REQUIRED.


Alain Irwin wrote:
> Therefore, I would replace
>
> MESSAGE(STATUS "using swig ${SWIG_DIR}")
>
> with
>
> MESSAGE(STATUS "using ${SWIG_EXECUTABLE} with SWIG_DIR =  ${SWIG_DIR}")

Because every project maintainer will probably have its own desires (from Tristan who wants nothing
to Alan who wants more) I removed all positive status messages in the last version.

The calling CMakeLists.txt can output the desired
information using the result variables much more flexible then the FindSWIG.cmake could 
do.

Cheers,


-- 
Axel Roebel
IRCAM Analysis/Synthesis Team
Phone: ++33-1-4478 4845 | Fax: ++33-1-4478 1540


More information about the CMake mailing list