[Kalzium] Fwd: FindOpenBabel2.cmake

Carsten Niehaus cniehaus at gmx.de
Fri Mar 2 15:34:42 CET 2007


Hey, as I have no opinion about this and would simply trust Jerome here... 
Perhaps you folks could have a look?

----------  Weitergeleitete Nachricht  ----------

Subject: FindOpenBabel2.cmake
Date: Freitag, 2. März 2007 11:59
From: Jerome Pansanel <j.pansanel at pansanel.net>
To: Carsten Niehaus <cniehaus at gmx.de>

Hi Carsten,

Here's a new version of FindOpenBabel2.cmake . It has been also successfully
tested on Win32.

It checks includes, libraries and executable and set two main variables:
OPENBABEL2_FOUND (True if the header files and libraries are available)
OPENBABEL2_EXECUTABLE_FOUND (True if babel program is available)

$ENV{VAR_NAME} are also really important on windows systems.

Cheers,

Jerome

-------------------------------------------------------
-------------- 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

# Copyright (c) 2006, Carsten Niehaus, <cniehaus at gmx.de>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.

#
# Search for Open Babel2 libraries and includes
#
if (OPENBABEL2_INCLUDE_DIR AND OPENBABEL2_LIBRARIES)

  # in cache already
  set(OPENBABEL2_FOUND TRUE)

else (OPENBABEL2_INCLUDE_DIR AND OPENBABEL2_LIBRARIES)
if(NOT WIN32)
  include(UsePkgConfig)

  pkgconfig(openbabel-2.0 _obIncDir _obLinkDir _obLinkFlags _obCflags)

  # query pkg-config asking for a openbabel >= 2.1.0
  exec_program(${PKGCONFIG_EXECUTABLE} ARGS --atleast-version=2.1.0 openbabel-2.0 RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _pkgconfigDevNull )
  if(_return_VALUE STREQUAL "0")
	set(OPENBABEL_MINI_FOUND TRUE)
  endif(_return_VALUE STREQUAL "0")
  message(STATUS "OPENBABEL_MINI_FOUND <${OPENBABEL_MINI_FOUND}>")

  exec_program(${PKGCONFIG_EXECUTABLE} ARGS --variable=pkgincludedir openbabel-2.0 RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _obPkgIncDir )
  if (_obPkgIncDir)
    set(_obIncDir "${_obPkgIncDir}")
  endif (_obPkgIncDir)
endif(NOT WIN32)
  find_path(OPENBABEL2_INCLUDE_DIR openbabel/obconversion.h
    ${_obIncDir}
    /usr/local/include
    /usr/include
    ${GNUWIN32_DIR}/include
    $ENV{OPENBABEL2_INCLUDE_DIR}
  )

  find_library(OPENBABEL2_LIBRARIES NAMES openbabel
    PATHS
    ${_obLinkDir}
    /usr/lib
    /usr/local/lib
    ${GNUWIN32_DIR}/lib
    $ENV{OPENBABEL2_LIBRARIES}
  )

  if(OPENBABEL2_INCLUDE_DIR AND OPENBABEL2_LIBRARIES AND OPENBABEL_MINI_FOUND)
    set(OPENBABEL2_FOUND TRUE)
  endif(OPENBABEL2_INCLUDE_DIR AND OPENBABEL2_LIBRARIES AND OPENBABEL_MINI_FOUND)

  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)

  mark_as_advanced(OPENBABEL2_INCLUDE_DIR OPENBABEL2_LIBRARIES)

endif (OPENBABEL2_INCLUDE_DIR AND OPENBABEL2_LIBRARIES)

#
# Search for Open Babel2 executable
#
IF( OPENBABEL2_EXECUTABLE )
  # in cache already
  SET( OPENBABEL2_EXECUTABLE_FOUND TRUE )

ELSE( OPENBABEL2_EXECUTABLE )
  FIND_PROGRAM(OPENBABEL2_EXECUTABLE
               NAMES babel
               PATHS
               [HKEY_CURRENT_USER\\SOFTWARE\\OpenBabel\ 2.0.2]
               $ENV{OPENBABEL2_EXECUTABLE}
  )

  SET(OPENBABEL2_EXECUTABLE_FOUND)
  IF(OPENBABEL2_EXECUTABLE)
    SET(OPENBABEL2_EXECUTABLE_FOUND ON)

  ENDIF(OPENBABEL2_EXECUTABLE)

MESSAGE( STATUS "Open Babel Exe: ${OPENBABEL2_EXECUTABLE}" )

ENDIF( OPENBABEL2_EXECUTABLE )
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/kalzium/attachments/20070302/7491a6c3/attachment.pgp 


More information about the Kalzium mailing list