[Kalzium] FindOpenBabel2

Alexander Neundorf neundorf at kde.org
Thu Jun 8 21:11:11 CEST 2006


Namd,

On Thursday 08 June 2006 19:07, Carsten Niehaus wrote:
> moin
>
> Yesterday and today I tried to make cmake and OpenBabel2 frieds... Without
> success.
>
> obconversation.h is a file that is shipped by OpenBabel2, amoung with other
> files:
>
> ls /usr/loccarsten at helium:~$ ls /usr/local/include/openbabel-2.0/openbabel/
> babelconfig.h  data.h         math            obiter.h         reaction.h
> base.h         dlhandler.h    matrix.h        obmolecformat.h  ring.h
> bitvec.h       fingerprint.h  molchrg.h       obutil.h         rotamer.h
> bondtyper.h    generic.h      mol.h           parsmart.h       rotor.h
> chains.h       grid.h         obconversion.h  patty.h          typer.h
> chiral.h       inchi_api.h    oberror.h       phmodel.h
>
> The attached file doesn't work for me and I don't even know where to start
> now...

...at the cmake man page and enter message(STATUS ...) for debugging :-)

You entered "FindOpenBabel2.cmake" when the script asked you for the name, so 
you got funny names like FINDOPENBABEL2.CMAKE_LIBRARIES etc.
Just try it again and enter "OpenBabel2" when asked for the name.
Here's what I did and the created file is attached. The 
generate_findpackage_file also needed some fine tuning.

hammer:~/src/kde4-svn/KDE/kdesdk/scripts/cmake$ ./generate_findpackage_file
Name of package: OpenBabel2
pkgconfig package name [e.g. "libxml-2.0", leave empty to skip pkgconfig]:
Look for header (e.g. "jpeglib.h" or "libxml/xpath.h"): 
openbabel/obconversation.h
Include subdir (e.g. "libxml2", empty to skip ): openbabel-2.0
Look for library (e.g. "jpeg" or "xml2"): openbabel
Done, generated FindOpenBabel2.cmake

The only slightly tricky part is the "Include subdir", this is for subdirs 
which are located under standard include dirs, but which are not used for 
including. E.g. you only write
#include <openbabel/obconversation.h>
so openbabel-2.0/ has to be appended to all standard include dirs when cmake 
searches for the header.

Bye
Alex

P.S. sorry, no time this weekend
-- 
Work: alexander.neundorf AT jenoptik.com - http://www.jenoptik-los.de
Home: neundorf AT kde.org                - http://www.kde.org
      alex AT neundorf.net               - http://www.neundorf.net
-------------- next part --------------
# - Try to find OpenBabel2
# Once done this will define
#
#  OPENBABEL2_FOUND - system has OpenBabel2
#  OPENBABEL2_INCLUDE_DIR - the OpenBabel2 include directory
#  OPENBABEL2_LIBRARIES - Link these to use OpenBabel2
#  OPENBABEL2_DEFINITIONS - Compiler switches required for using OpenBabel2
#


FIND_PATH(OPENBABEL2_INCLUDE_DIR NAMES openbabel/obconversation.h
  PATHS
  /usr/include
  /usr/local/include
  PATH_SUFFIXES openbabel-2.0
)

FIND_LIBRARY(OPENBABEL2_LIBRARIES NAMES openbabel
  PATHS
  /usr/lib
  /usr/local/lib
)

IF(OPENBABEL2_INCLUDE_DIR AND OPENBABEL2_LIBRARIES)
   SET(OPENBABEL2_FOUND TRUE)
ENDIF(OPENBABEL2_INCLUDE_DIR AND OPENBABEL2_LIBRARIES)

IF(OPENBABEL2_FOUND)
  IF(NOT OpenBabel2_FIND_QUIETLY)
    MESSAGE(STATUS "Found OpenBabel2: ${OPENBABEL2_LIBRARIES}")
  ENDIF(NOT OpenBabel2_FIND_QUIETLY)
ELSE(OPENBABEL2_FOUND)
  IF(OpenBabel2_FIND_REQUIRED)
    MESSAGE(FATAL_ERROR "Could not find OpenBabel2")
  ENDIF(OpenBabel2_FIND_REQUIRED)
ENDIF(OPENBABEL2_FOUND)

# show the OPENBABEL2_INCLUDE_DIR and OPENBABEL2_LIBRARIES variables only in the advanced view
MARK_AS_ADVANCED(OPENBABEL2_INCLUDE_DIR OPENBABEL2_LIBRARIES )



More information about the Kalzium mailing list