From b2fe675a8388a700d40e418eb8653a91fdbd33f0 Mon Sep 17 00:00:00 2001 From: barate Date: Fri, 4 Sep 2009 08:39:28 +0000 Subject: [PATCH] Added m4 macro and CMake module to check for libBatch --- CMakeLists.txt | 2 + CMakeModules/FindPBS.cmake | 2 +- doc/CMakeLists.txt | 2 +- misc/CMakeLists.txt | 24 ++++++++ misc/FindLibBatch.cmake | 58 +++++++++++++++++++ misc/check_libbatch.m4 | 115 +++++++++++++++++++++++++++++++++++++ 6 files changed, 201 insertions(+), 2 deletions(-) create mode 100644 misc/CMakeLists.txt create mode 100644 misc/FindLibBatch.cmake create mode 100644 misc/check_libbatch.m4 diff --git a/CMakeLists.txt b/CMakeLists.txt index c7b8b08..4da4d10 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,6 +62,8 @@ IF (Makeinfo_FOUND) add_subdirectory (doc) ENDIF (Makeinfo_FOUND) +add_subdirectory (misc) + SET(CPACK_GENERATOR TGZ) SET(CPACK_SOURCE_GENERATOR TGZ ZIP) SET(CPACK_PACKAGE_VERSION_MAJOR 1) diff --git a/CMakeModules/FindPBS.cmake b/CMakeModules/FindPBS.cmake index e5a7cf8..3e2e3e6 100644 --- a/CMakeModules/FindPBS.cmake +++ b/CMakeModules/FindPBS.cmake @@ -25,7 +25,7 @@ IF (NOT PBS_FIND_QUIETLY) ENDIF (NOT PBS_FIND_QUIETLY) FIND_PATH(PBS_INCLUDE_DIR pbs_ifl.h) -FIND_LIBRARY(PBS_LIBRARY pbs) +FIND_LIBRARY(PBS_LIBRARY NAMES pbs torque) IF (PBS_INCLUDE_DIR AND PBS_LIBRARY) SET(PBS_FOUND True) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 880821d..3ca8f31 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -29,4 +29,4 @@ ADD_CUSTOM_TARGET(doc ALL FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Batch) -INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Batch DESTINATION share/doc) +INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Batch/ DESTINATION share/Batch/doc) diff --git a/misc/CMakeLists.txt b/misc/CMakeLists.txt new file mode 100644 index 0000000..a24cf50 --- /dev/null +++ b/misc/CMakeLists.txt @@ -0,0 +1,24 @@ +# Copyright (C) 2007-2009 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or +# email : webmaster.salome@opencascade.com + +INSTALL(FILES check_libbatch.m4 FindLibBatch.cmake + DESTINATION share/Batch/misc) diff --git a/misc/FindLibBatch.cmake b/misc/FindLibBatch.cmake new file mode 100644 index 0000000..d748f7e --- /dev/null +++ b/misc/FindLibBatch.cmake @@ -0,0 +1,58 @@ +# Copyright (C) 2007-2009 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or +# email : webmaster.salome@opencascade.com + +# FindLibBatch +# This module can be used to find libBatch and set the associated variables in +# a project based on CMake. You can copy this file in your own project and +# eventually modify it according to your own needs. +#----------------------------------------------------------------------------- + +IF (NOT LibBatch_FIND_QUIETLY) + MESSAGE(STATUS "Looking for libBatch...") +ENDIF (NOT LibBatch_FIND_QUIETLY) + +FIND_PATH(LIBBATCH_INCLUDE_DIR Batch/Batch_BatchManager.hxx) +FIND_LIBRARY(LIBBATCH_LIBRARY Batch) + +IF (LIBBATCH_INCLUDE_DIR AND LIBBATCH_LIBRARY) + SET(LibBatch_FOUND True) +ENDIF (LIBBATCH_INCLUDE_DIR AND LIBBATCH_LIBRARY) + +IF (LibBatch_FOUND) + + IF (NOT LibBatch_FIND_QUIETLY) + MESSAGE(STATUS "Found libBatch:") + MESSAGE(STATUS "libBatch include directory: ${LIBBATCH_INCLUDE_DIR}") + MESSAGE(STATUS "libBatch library: ${LIBBATCH_LIBRARY}") + ENDIF (NOT LibBatch_FIND_QUIETLY) + +ELSE (LibBatch_FOUND) + + IF (LibBatch_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "libBatch not found") + ELSE (LibBatch_FIND_REQUIRED) + IF (NOT LibBatch_FIND_QUIETLY) + MESSAGE(STATUS "libBatch not found") + ENDIF (NOT LibBatch_FIND_QUIETLY) + ENDIF (LibBatch_FIND_REQUIRED) + +ENDIF (LibBatch_FOUND) diff --git a/misc/check_libbatch.m4 b/misc/check_libbatch.m4 new file mode 100644 index 0000000..52a95f3 --- /dev/null +++ b/misc/check_libbatch.m4 @@ -0,0 +1,115 @@ +dnl Copyright (C) 2007-2009 CEA/DEN, EDF R&D, OPEN CASCADE +dnl +dnl Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +dnl CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +dnl +dnl This library is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU Lesser General Public +dnl License as published by the Free Software Foundation; either +dnl version 2.1 of the License. +dnl +dnl This library is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl Lesser General Public License for more details. +dnl +dnl You should have received a copy of the GNU Lesser General Public +dnl License along with this library; if not, write to the Free Software +dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +dnl +dnl See http://www.salome-platform.org/ or +dnl email : webmaster.salome@opencascade.com +dnl + +# CHECK_LIBBATCH +# This macro can be used to find libBatch and set the associated variables in +# a project based on autoconf. You can copy this file in your own project and +# eventually modify it according to your own needs. +# ---------------------------------------------------------------------------- + +AC_DEFUN([CHECK_LIBBATCH],[ + +AC_MSG_NOTICE(Checking for libBatch library) + +AC_SUBST(LIBBATCH_INCLUDES) +AC_SUBST(LIBBATCH_LIBS) + +LIBBATCH_INCLUDES="" +LIBBATCH_LIBS="" + +libbatch_ok=no + +AC_ARG_WITH([libbatch], + [AS_HELP_STRING([--with-libbatch=DIR], + [root directory path of libBatch installation])], + [LIBBATCH_DIR="$withval"], + [LIBBATCH_DIR=""]) + +if test "x$LIBBATCH_DIR" = "x" ; then + # no --with-libbatch option used + if test "x$LIBBATCH_ROOT_DIR" != "x" ; then + # LIBBATCH_ROOT_DIR environment variable defined + LIBBATCH_DIR=$LIBBATCH_ROOT_DIR + fi +fi + +LOCAL_INCLUDES="" +LOCAL_LIBS="" + +if test "x$LIBBATCH_DIR" != "x" ; then + LOCAL_INCLUDES="-I$LIBBATCH_DIR/include" + if test "x$LIBBATCH_DIR" = "x/usr" ; then + LOCAL_LIBS="-lBatch" + else + LOCAL_LIBS="-L$LIBBATCH_DIR/lib -lBatch" + fi +else + LOCAL_INCLUDES="-I/usr/include" + LOCAL_LIBS="-lBatch" +fi + +# libBatch headers + +CPPFLAGS_old="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS $LOCAL_INCLUDES" +AC_CHECK_HEADER(Batch/Batch_BatchManager.hxx, + libbatch_ok="yes", + libbatch_ok="no") +CPPFLAGS="$CPPFLAGS_old" + + +if test "x$libbatch_ok" = "xyes" ; then + # libBatch library + + LIBS_old=$LIBS + LIBS="$LIBS $LOCAL_LIBS" + # Can't use AC_SEARCH_LIBS or AC_CHECK_LIB here because + # they don't work with C++ namespaces + # AC_SEARCH_LIBS(Batch::BatchManagerCatalog::getInstance,Batch, + # libbatch_ok="yes",libbatch_ok="no") + AC_MSG_CHECKING( + [for library containing Batch::BatchManagerCatalog::getInstance]) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + namespace Batch { + class BatchManagerCatalog { + public: static void getInstance(); + }; + } + ]], + [using namespace Batch; + BatchManagerCatalog::getInstance();])], + [libbatch_ok="yes"], + [libbatch_ok="no"]) + AC_MSG_RESULT($libbatch_ok) + + LIBS=$LIBS_old +fi + +if test "x$libbatch_ok" = "xyes" ; then + LIBBATCH_INCLUDES="$LOCAL_INCLUDES" + LIBBATCH_LIBS="$LOCAL_LIBS" +fi + +AC_MSG_RESULT(for libBatch: $libbatch_ok) + +]) -- 2.39.2