# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-project (libbatch)
-
-cmake_minimum_required (VERSION 2.8)
-set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules/)
-
-find_package (PThread REQUIRED)
-
-SET (BUILD_LOCAL_SUBMISSION TRUE CACHE BOOL "Build classes for local submission")
-SET (BUILD_PYTHON_WRAPPING TRUE CACHE BOOL "Generate Python wrapping")
-SET (TEST_ENABLED FALSE CACHE BOOL "Enable testing")
-
-IF (TEST_ENABLED)
- ENABLE_TESTING()
-ENDIF (TEST_ENABLED)
-
-IF (BUILD_LOCAL_SUBMISSION)
- find_package (Local)
-ENDIF (BUILD_LOCAL_SUBMISSION)
-IF (BUILD_PYTHON_WRAPPING)
- FIND_PACKAGE(PythonInterp)
- IF (PYTHONINTERP_FOUND)
- get_filename_component(PYTHON_BIN_DIR "${PYTHON_EXECUTABLE}" PATH)
- get_filename_component(CMAKE_INCLUDE_PATH "${PYTHON_BIN_DIR}/../include/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}" ABSOLUTE)
- get_filename_component(CMAKE_LIBRARY_PATH "${PYTHON_BIN_DIR}/../lib" ABSOLUTE)
- ENDIF (PYTHONINTERP_FOUND)
- FIND_PACKAGE(PythonLibs ${PYTHON_VERSION_STRING} EXACT)
- FIND_PACKAGE(SWIG)
-ENDIF (BUILD_PYTHON_WRAPPING)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR)
+PROJECT(LibBatch C CXX)
-SET(CPACK_GENERATOR TGZ)
-SET(CPACK_SOURCE_GENERATOR TGZ ZIP)
-SET(CPACK_PACKAGE_VERSION_MAJOR 2)
-SET(CPACK_PACKAGE_VERSION_MINOR 0)
-SET(CPACK_PACKAGE_VERSION_PATCH 0)
-SET(CPACK_SOURCE_IGNORE_FILES /\\\\.;/CVS/;~)
-SET(CPACK_SOURCE_PACKAGE_FILE_NAME
- ${PROJECT_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
+# Versioning
+# ===========
+# Project name, upper case
+STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
+
+SET(${PROJECT_NAME_UC}_MAJOR_VERSION 2)
+SET(${PROJECT_NAME_UC}_MINOR_VERSION 0)
+SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
+SET(${PROJECT_NAME_UC}_VERSION
+ ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
+
+# Our own set of macros:
+LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)
+INCLUDE(libbatchMacros)
+
+# User options
+# ============
+SET(INSTALL_CMAKE_CONFIG_DIR share/cmake)
+SET(INSTALL_INCLUDE_DIR include)
+
+SET(LIBBATCH_LOCAL_SUBMISSION TRUE CACHE BOOL "Build classes for local submission")
+SET(LIBBATCH_PYTHON_WRAPPING TRUE CACHE BOOL "Generate Python wrapping")
+SET(LIBBATCH_TESTS FALSE CACHE BOOL "Enable testing")
+
+IF(LIBBATCH_TESTS)
+ ENABLE_TESTING()
+ENDIF()
+IF(LIBBATCH_LOCAL_SUBMISSION)
+ LIBBATCH_FIND_ALL_LOCAL_COMMANDS()
+ENDIF()
+
+# Prerequisites detection:
+# ========================
+FIND_PACKAGE(LibbatchPThread REQUIRED)
+
+IF (LIBBATCH_PYTHON_WRAPPING)
+ FIND_PACKAGE(LibbatchPython REQUIRED)
+ FIND_PACKAGE(LibbatchSWIG REQUIRED)
+
+ MESSAGE("TODO TODO check Python path win32")
+ SET(LIBBATCH_PYTHONPATH lib/python${PYTHON_VERSION}/site-packages)
+ENDIF()
-configure_file (${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
+# Configuration summary
+# =====================
+LIBBATCH_SUMMARY()
-INCLUDE(Summary)
+# Configure
+# =========
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/libbatch_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/libbatch_config.h)
+ADD_SUBDIRECTORY(src)
+ADD_SUBDIRECTORY(misc)
-add_subdirectory (src)
-add_subdirectory (misc)
+# Export logic
+# ============
+INCLUDE(CMakePackageConfigHelpers)
+# Add all targets to the build-tree export set
+EXPORT(TARGETS batch
+ FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
+
+# Create the configuration files:
+# - in the build tree:
+
+# Ensure the variables are always defined for the configure:
+SET(LIBBATCH_PYTHONPATH "${LIBBATCH_PYTHONPATH}")
+SET(PYTHON_ROOT_DIR "${PYTHON_ROOT_DIR}")
+SET(SWIG_ROOT_DIR "${SWIG_ROOT_DIR}")
+
+SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
+CONFIGURE_PACKAGE_CONFIG_FILE(misc/${PROJECT_NAME}Config.cmake.in
+ ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
+ INSTALL_DESTINATION "${INSTALL_CMAKE_CONFIG_DIR}"
+ PATH_VARS CONF_INCLUDE_DIRS INSTALL_CMAKE_CONFIG_DIR CMAKE_INSTALL_PREFIX LIBBATCH_PYTHONPATH
+ PYTHON_ROOT_DIR SWIG_ROOT_DIR)
+
+# - in the install tree:
+# Get the relative path of the include directory so
+# we can register it in the generated configuration files:
+SET(CONF_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR}")
+CONFIGURE_PACKAGE_CONFIG_FILE(misc/${PROJECT_NAME}Config.cmake.in
+ ${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake
+ INSTALL_DESTINATION "${INSTALL_CMAKE_CONFIG_DIR}"
+ PATH_VARS CONF_INCLUDE_DIRS INSTALL_CMAKE_CONFIG_DIR CMAKE_INSTALL_PREFIX LIBBATCH_PYTHONPATH
+ PYTHON_ROOT_DIR SWIG_ROOT_DIR)
+
+WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
+ VERSION ${${PROJECT_NAME_UC}_VERSION}
+ COMPATIBILITY AnyNewerVersion)
+
+# Install the CMake configuration files:
+INSTALL(FILES
+ "${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake"
+ "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
+ DESTINATION "${INSTALL_CMAKE_CONFIG_DIR}")
+
+# Install the export set for use with the install-tree
+INSTALL(EXPORT LibBatchTargets DESTINATION "${INSTALL_CMAKE_CONFIG_DIR}")
+
+# Packaging logic
+# ===============
+SET(CPACK_GENERATOR TGZ)
+SET(CPACK_SOURCE_GENERATOR TGZ ZIP)
+SET(CPACK_PACKAGE_VERSION_MAJOR ${${PROJECT_NAME}_MAJOR_VERSION})
+SET(CPACK_PACKAGE_VERSION_MINOR ${${PROJECT_NAME}_MINOR_VERSION})
+SET(CPACK_PACKAGE_VERSION_PATCH ${${PROJECT_NAME}_PATCH_VERSION})
+SET(CPACK_SOURCE_IGNORE_FILES /\\\\.;/CVS/;~;/.git/)
+SET(CPACK_SOURCE_PACKAGE_FILE_NAME ${PROJECT_NAME}-${${PROJECT_NAME}_VERSION})
INCLUDE(CPack)
-MARK_AS_ADVANCED(CMAKE_BACKWARDS_COMPATIBILITY EXECUTABLE_OUTPUT_PATH)
--- /dev/null
+# Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# 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
+#
+# Author: Adrien Bruneton
+#
+
+# PThread detection for libBatch
+#
+# !! Please read the generic detection procedure in libbatchMacros.cmake !!
+#
+SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(PThread PTHREAD_INCLUDE_DIR 1)
+MARK_AS_ADVANCED(PTHREAD_LIBRARIES PTHREAD_INCLUDE_DIR)
+
--- /dev/null
+# Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# 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
+#
+# Author: Adrien Bruneton
+#
+
+# Python libraries and interpreter detection for libBatch
+# The interpreter is found first, and if OK, the corresponding libraries are searched.
+# We ensure the version of the libraries matches the one of the interpreter.
+#
+
+# 1. Load environment or any previously detected Python
+IF(DEFINED ENV{PYTHON_ROOT_DIR})
+ FILE(TO_CMAKE_PATH "$ENV{PYTHON_ROOT_DIR}" _PYTHON_ROOT_DIR_ENV)
+ SET(_dflt_value "${_PYTHON_ROOT_DIR_ENV}")
+ELSE()
+ # will be blank if no Python was previously loaded
+ SET(_dflt_value "${PYTHON_ROOT_DIR_EXP}")
+ENDIF()
+
+# Make cache entry
+SET(PYTHON_ROOT_DIR "${_dflt_value}" CACHE PATH "Path to Python directory (interpreter and libs)")
+
+# 2. Find package - config mode first (i.e. looking for XYZ-config.cmake)
+IF(EXISTS "${PYTHON_ROOT_DIR}")
+ # Hope to find direclty a CMake config file there
+ SET(_CONF_DIR "${PYTHON_ROOT_DIR}/share/cmake")
+
+ # Try find_package in config mode with a hard-coded guess. This
+ # has the priority.
+ FIND_PACKAGE(Python CONFIG QUIET PATHS "${_CONF_DIR}")
+ MARK_AS_ADVANCED(Python_DIR)
+
+ IF (NOT PYTHON_FOUND)
+ LIST(APPEND CMAKE_PREFIX_PATH "${PYTHON_ROOT_DIR}")
+ ELSE()
+ MESSAGE(STATUS "Found Python in CONFIG mode!")
+ ENDIF()
+ENDIF()
+
+# Otherwise try the standard way (module mode, with the standard CMake Find*** macro):
+SALOME_FIND_PACKAGE(LibbatchPython PythonInterp MODULE)
+SET(_found1 ${PYTHONINTERP_FOUND})
+
+IF (PYTHONINTERP_FOUND)
+ # Now ensure we find the Python libraries matching the interpreter:
+ # This uses the variable PYTHON_EXECUTABLE
+ GET_FILENAME_COMPONENT(_python_dir "${PYTHON_EXECUTABLE}" PATH)
+ GET_FILENAME_COMPONENT(CMAKE_INCLUDE_PATH "${_python_dir}/../include/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}" ABSOLUTE)
+ GET_FILENAME_COMPONENT(CMAKE_LIBRARY_PATH "${_python_dir}/../lib" ABSOLUTE)
+ # For a Windows install, this might look more like this:
+ IF(WIN32)
+ LIST(APPEND CMAKE_LIBRARY_PATH "${_python_dir}/libs" ABSOLUTE)
+ LIST(APPEND CMAKE_INCLUDE_PATH "${_python_dir}/include" ABSOLUTE)
+ ENDIF()
+ # Override the EXACT and VERSION settings of the LibbatchPython module
+ # to force the next call to SALOME_FIND_PACKAGE() to find the exact matching
+ # version:
+ SET(_old_EXACT ${LibbatchPython_FIND_VERSION_EXACT})
+ SET(_old_VERSION "${LibbatchPython_FIND_VERSION}")
+ SET(LibbatchPython_FIND_VERSION_EXACT TRUE)
+ SET(LibbatchPython_FIND_VERSION "${PYTHON_VERSION_STRING}")
+ # Prepare call to FIND_PACKAGE(PythonLibs) and ensure priority is given to
+ # the location found for the interpreter:
+ GET_FILENAME_COMPONENT(_tmp "${_python_dir}" PATH)
+# SET(PYTHON_LIBRARY ${_tmp}/lib)
+# SET(PYTHON_INCLUDE_DIR ${_tmp}/include)
+ SALOME_FIND_PACKAGE(LibbatchPython PythonLibs MODULE)
+ # Restore variables:
+ SET(LibbatchPython_FIND_VERSION_EXACT ${_old_EXACT})
+ SET(LibbatchPython_FIND_VERSION "${_old_VERSION}")
+ENDIF()
+
+# Set the FOUND flag for LibbatchPython:
+SET(LIBBATCHPYTHON_FOUND FALSE)
+IF (_found1 AND PYTHONLIBS_FOUND)
+ SET(LIBBATCHPYTHON_FOUND TRUE)
+ENDIF()
+
+IF (LIBBATCHPYTHON_FOUND)
+ MESSAGE(STATUS "Python interpreter and Python libraries found:")
+ MESSAGE(STATUS "Python libraries: ${PYTHON_LIBRARY}")
+ MESSAGE(STATUS "Python include dir: ${PYTHON_INCLUDE_DIR}")
+
+ # 3. Set the root dir which was finally retained
+ # For Python this is the grand-parent of the
+ # include directory:
+ GET_FILENAME_COMPONENT(_tmp_ROOT_DIR "${PYTHON_INCLUDE_DIR}" PATH)
+ GET_FILENAME_COMPONENT(_tmp_ROOT_DIR "${_tmp_ROOT_DIR}" PATH)
+
+ # 4. Warn if CMake found something not located under ENV(XYZ_ROOT_DIR)
+ IF(DEFINED ENV{PYTHON_ROOT_DIR})
+ SALOME_CHECK_EQUAL_PATHS(_res "${_tmp_ROOT_DIR}" "${_PYTHON_ROOT_DIR_ENV}")
+ IF(NOT _res)
+ MESSAGE(WARNING "Python was found, but not a the path given by the "
+"environment PYTHON_ROOT_DIR! Is the variable correctly set?")
+ ELSE()
+ MESSAGE(STATUS "Python found directory matches what was specified in the PYTHON_ROOT_DIR, all good!")
+ ENDIF()
+ ENDIF()
+
+ # 5. Conflict detection
+ # 5.1 From another prerequisite using Python
+ IF(PYTHON_ROOT_DIR_EXP)
+ SALOME_CHECK_EQUAL_PATHS(_res "${_tmp_ROOT_DIR}" "${PYTHON_ROOT_DIR_EXP}")
+ IF(NOT _res)
+ MESSAGE(WARNING "Warning: Python: detected version conflicts with a previously found Python!"
+ "The two paths are " ${_tmp_ROOT_DIR} " vs " ${PYTHON_ROOT_DIR_EXP})
+ ELSE()
+ MESSAGE(STATUS "Python directory matches what was previously exposed by another prereq, all good!")
+ ENDIF()
+ ENDIF()
+
+ # 6. Finally retained variable:
+ SET(PYTHON_ROOT_DIR "${_tmp_ROOT_DIR}")
+
+ # 7. Specifics
+ ## None here
+ELSE(LIBBATCHPYTHON_FOUND)
+ MESSAGE(STATUS "Python was only partially (or not at all) found .")
+ENDIF(LIBBATCHPYTHON_FOUND)
+
--- /dev/null
+# Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# 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
+#
+# Author: Adrien Bruneton
+#
+
+# SWIG detection for libbatch
+#
+# !! Please read the generic detection procedure in libbatchMacros.cmake !!
+#
+SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(SWIG SWIG_EXECUTABLE 2)
+MARK_AS_ADVANCED(SWIG_EXECUTABLE SWIG_VERSION)
+# - Find PThread
+# This module finds an installed PThread using the variable PTHREAD_ROOT_DIR
+# as a lookup path.
+# It sets the following variables:
+# PTHREAD_FOUND - set to true if PThread is found
+# PTHREAD_INCLUDE_DIR - the directory where the include files are located
+# PTHREAD_LIBRARY - the path to PThread library
+#
+# The file "pthread.h" is looked for PTHREAD_INCLUDE_DIR.
+# Libraries are searched with following names:
+# pthread
+# On Win32:
+# pthreadVSE2 pthreadVC2
+# or in Debug mode:
+# pthreadVSE2d pthreadVC2d
+#
+
+
+#############################################################
# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
#
# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
+#############################################################
IF (NOT PThread_FIND_QUIETLY)
MESSAGE(STATUS "Looking for PThread...")
-ENDIF (NOT PThread_FIND_QUIETLY)
+ENDIF ()
IF(WIN32)
- SET(PTHREADS_ROOT_USER $ENV{PTHREADS_ROOT})
SET(PTHREADS_FIND_PATHS_OPTION NO_DEFAULT_PATH)
SET(PTHREADS_INCLUDE_TO_FIND pthread.h)
- SET(PTHREADS_INCLUDE_PATHS ${PTHREADS_ROOT_USER}/include)
+ SET(PTHREADS_INCLUDE_PATHS ${PTHREAD_ROOT_DIR}/include)
FIND_PATH(PTHREAD_INCLUDE_DIR ${PTHREADS_INCLUDE_TO_FIND}
PATHS ${PTHREADS_INCLUDE_PATHS} ${PTHREADS_FIND_PATHS_OPTION})
- SET(PTHREADS_LIB_PATHS ${PTHREADS_ROOT_USER}/lib)
- IF(CMAKE_BUILD_TYPE STREQUAL Release)
+ SET(PTHREADS_LIB_PATHS ${PTHREAD_ROOT_DIR}/lib)
+ # Default build type is assumed to be Release:
+ IF(NOT CMAKE_BUILD_TYPE STREQUAL Debug)
FIND_LIBRARY(PTHREAD_LIBRARY pthreadVSE2 pthreadVC2
PATHS ${PTHREADS_LIB_PATHS} ${PTHREADS_FIND_PATHS_OPTION})
- ELSE(CMAKE_BUILD_TYPE STREQUAL Release)
+ ELSE()
FIND_LIBRARY(PTHREAD_LIBRARY pthreadVSE2d pthreadVC2d
PATHS ${PTHREADS_LIB_PATHS} ${PTHREADS_FIND_PATHS_OPTION})
- ENDIF(CMAKE_BUILD_TYPE STREQUAL Release)
+ ENDIF()
ELSE(WIN32)
FIND_PATH(PTHREAD_INCLUDE_DIR pthread.h)
FIND_LIBRARY(PTHREAD_LIBRARY NAMES pthread)
ENDIF(WIN32)
-IF (PTHREAD_INCLUDE_DIR AND PTHREAD_LIBRARY)
- SET(PThread_FOUND True)
-ENDIF (PTHREAD_INCLUDE_DIR AND PTHREAD_LIBRARY)
-
-IF (PThread_FOUND)
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(PThread REQUIRED_VARS PTHREAD_INCLUDE_DIR PTHREAD_LIBRARY)
+IF (PTHREAD_FOUND)
IF (NOT PThread_FIND_QUIETLY)
- MESSAGE(STATUS "Found PThread:")
- MESSAGE(STATUS "PThread include directory: ${PTHREAD_INCLUDE_DIR}")
MESSAGE(STATUS "PThread library: ${PTHREAD_LIBRARY}")
ENDIF (NOT PThread_FIND_QUIETLY)
-
-ELSE (PThread_FOUND)
-
- IF (PThread_FIND_REQUIRED)
- MESSAGE(FATAL_ERROR "PThread not found")
- ELSE (PThread_FIND_REQUIRED)
- IF (NOT PThread_FIND_QUIETLY)
- MESSAGE(STATUS "PThread not found")
- ENDIF (NOT PThread_FIND_QUIETLY)
- ENDIF (PThread_FIND_REQUIRED)
-
-ENDIF (PThread_FOUND)
+ENDIF()
--- /dev/null
+# Copyright (C) 2007-2013 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
+#
+
+#
+# Set of macros to identify local shell commands for file deletion,
+# file copy, etc ... (under Windows and Unix).
+#
+MACRO(FIND_LOCAL_COMMAND VAR UNIX_COMMAND WIN32_COMMAND)
+ IF (WIN32)
+ FIND_PROGRAM(${VAR} ${WIN32_COMMAND})
+ ELSE (WIN32)
+ FIND_PROGRAM(${VAR} ${UNIX_COMMAND})
+ ENDIF (WIN32)
+ IF (${VAR})
+ MESSAGE(STATUS "${VAR} found : ${${VAR}}")
+ ELSE (${VAR})
+ MESSAGE(STATUS "${VAR} not found, local submission might not work properly")
+ ENDIF (${VAR})
+ENDMACRO(FIND_LOCAL_COMMAND)
+
+MACRO(FIND_LOCAL_COMMAND_WIN32_DEF VAR UNIX_COMMAND WIN32_DEFAULT)
+ IF (WIN32)
+ SET(${VAR} ${WIN32_DEFAULT} CACHE STRING "${VAR}")
+ MESSAGE(STATUS "${VAR} found : using '${${VAR}}' (Windows default)")
+ ELSE (WIN32)
+ FIND_LOCAL_COMMAND(${VAR} ${UNIX_COMMAND} ${WIN32_DEFAULT})
+ ENDIF (WIN32)
+ENDMACRO(FIND_LOCAL_COMMAND_WIN32_DEF)
+
+MACRO(EVAL VAR)
+ IF(${ARGN})
+ SET(${VAR} TRUE)
+ ELSE(${ARGN})
+ SET(${VAR} FALSE)
+ ENDIF(${ARGN})
+ENDMACRO(EVAL)
+
+MACRO(LIBBATCH_FIND_ALL_LOCAL_COMMANDS)
+ MESSAGE(STATUS "Looking for commands needed for local submission...")
+
+ FIND_LOCAL_COMMAND_WIN32_DEF(LIBBATCH_RM_COMMAND rm del)
+ FIND_LOCAL_COMMAND(LIBBATCH_SH_COMMAND sh cmd.exe)
+ FIND_LOCAL_COMMAND_WIN32_DEF(LIBBATCH_CP_COMMAND cp copy)
+ FIND_LOCAL_COMMAND_WIN32_DEF(LIBBATCH_MKDIR_COMMAND mkdir mkdir)
+ FIND_LOCAL_COMMAND(LIBBATCH_RSH_COMMAND rsh rsh)
+ FIND_LOCAL_COMMAND(LIBBATCH_RCP_COMMAND rcp rcp)
+ FIND_LOCAL_COMMAND(LIBBATCH_SSH_COMMAND ssh plink)
+ FIND_LOCAL_COMMAND(LIBBATCH_SCP_COMMAND scp pscp)
+
+ EVAL (HAS_SH LIBBATCH_SH_COMMAND AND LIBBATCH_CP_COMMAND AND LIBBATCH_RM_COMMAND AND LIBBATCH_MKDIR_COMMAND)
+ EVAL (HAS_RSH LIBBATCH_RSH_COMMAND AND LIBBATCH_RCP_COMMAND)
+ EVAL (HAS_SSH LIBBATCH_SSH_COMMAND AND LIBBATCH_SCP_COMMAND)
+
+ # Mark shell commands as advanced options
+ # and assign the names without the LIBBATCH_ in front:
+ SET (_cmds "RM;SH;CP;MKDIR;RSH;RCP;SSH;SCP")
+ FOREACH(_cmd ${_cmds})
+ MARK_AS_ADVANCED(LIBBATCH_${_cmd}_COMMAND)
+ SET(${_cmd}_COMMAND ${LIBBATCH_${_cmd}_COMMAND})
+ ENDFOREACH()
+ENDMACRO()
+
+#
+# Display configuration summary
+#
+MACRO(LIBBATCH_SUMMARY)
+ MESSAGE(STATUS "")
+ MESSAGE(STATUS "**************** Libbatch Summary *******")
+ MESSAGE(STATUS "")
+ IF (LIBBATCH_LOCAL_SUBMISSION)
+ MESSAGE(STATUS "Local submission .................... Yes")
+ ELSE()
+ MESSAGE(STATUS "Local submission .......... Not requested")
+ ENDIF()
+
+ IF (LIBBATCH_PYTHON_WRAPPING)
+ IF (PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND AND SWIG_FOUND)
+ MESSAGE(STATUS "Python wrapping ..................... Yes")
+ ELSE()
+ MESSAGE(STATUS "Python wrapping ............... Python libs (or Swig) not found")
+ ENDIF()
+ ELSE()
+ MESSAGE(STATUS "Python wrapping ........... Not requested")
+ ENDIF()
+
+ MESSAGE(STATUS "")
+ MESSAGE(STATUS "************** End Summary **************")
+ MESSAGE(STATUS "")
+ENDMACRO()
+
+###
+# SALOME_CHECK_EQUAL_PATHS(result path1 path2)
+# Check if two paths are identical, resolving links. If the paths do not exist a simple
+# text comparison is performed.
+# result is a boolean.
+###
+MACRO(SALOME_CHECK_EQUAL_PATHS varRes path1 path2)
+ SET("${varRes}" OFF)
+ IF(EXISTS "${path1}")
+ GET_FILENAME_COMPONENT(_tmp1 "${path1}" REALPATH)
+ ELSE()
+ SET(_tmp1 "${path1}")
+ ENDIF()
+
+ IF(EXISTS "${path2}")
+ GET_FILENAME_COMPONENT(_tmp2 "${path2}" REALPATH)
+ ELSE()
+ SET(_tmp2 "${path2}")
+ ENDIF()
+
+ IF("${_tmp1}" STREQUAL "${_tmp2}")
+ SET("${varRes}" ON)
+ ENDIF()
+# MESSAGE(${${varRes}})
+ENDMACRO()
+
+
+####
+# SALOME_FIND_PACKAGE(englobingPackageName standardPackageName modus)
+# Encapsulate the call to the standard FIND_PACKAGE(standardPackageName) passing all the options
+# given when calling the command FIND_PACKAGE(customPackageName)
+# Modus is either MODULE or CONFIG (cf standard FIND_PACKAGE() documentation).
+# This macro is to be called from within the FindCustomPackage.cmake file.
+####
+MACRO(SALOME_FIND_PACKAGE englobPkg stdPkg mode)
+ # Only bother if the package was not already found:
+ # Some old packages use the lower case version - standard should be to always use
+ # upper case:
+ STRING(TOUPPER ${stdPkg} stdPkgUC)
+ IF(NOT (${stdPkg}_FOUND OR ${stdPkgUC}_FOUND))
+ IF(${englobPkg}_FIND_QUIETLY)
+ SET(_tmp_quiet "QUIET")
+ ELSE()
+ SET(_tmp_quiet)
+ ENDIF()
+ IF(${englobPkg}_FIND_REQUIRED)
+ SET(_tmp_req "REQUIRED")
+ ELSE()
+ SET(_tmp_req)
+ ENDIF()
+ IF(${englobPkg}_FIND_VERSION_EXACT)
+ SET(_tmp_exact "EXACT")
+ ELSE()
+ SET(_tmp_exact)
+ ENDIF()
+ IF(${englobPkg}_FIND_COMPONENTS)
+ STRING(REPLACE ";" " " _tmp_compo ${${englobPkg}_FIND_COMPONENTS})
+ ELSE()
+ SET(_tmp_compo)
+ ENDIF()
+
+ # Call the root FIND_PACKAGE():
+ #MESSAGE("blabla ${englobPkg} / ${${englobPkg}_FIND_VERSION_EXACT} / ${stdPkg} ${${englobPkg}_FIND_VERSION} ${_tmp_exact} ${mode}")
+ IF(_tmp_compo)
+ FIND_PACKAGE(${stdPkg} ${${englobPkg}_FIND_VERSION} ${_tmp_exact} ${mode} ${_tmp_quiet} ${_tmp_req} COMPONENTS ${_tmp_compo})
+ ELSE()
+ FIND_PACKAGE(${stdPkg} ${${englobPkg}_FIND_VERSION} ${_tmp_exact} ${mode} ${_tmp_quiet} ${_tmp_req})
+ ENDIF()
+ ENDIF()
+ENDMACRO()
+
+####################################################################"
+# SALOME_FIND_PACKAGE_DETECT_CONFLICTS(pkg referenceVariable upCount)
+# pkg : name of the system package to be detected
+# referenceVariable: variable containing a path that can be browsed up to
+# retrieve the package root directory (xxx_ROOT_DIR)
+# upCount : number of times we have to go up from the path <referenceVariable>
+# to obtain the package root directory.
+#
+# For example: SALOME_FIND_PACKAGE_DETECT_CONFLICTS(SWIG SWIG_EXECUTABLE 2)
+#
+# Generic detection (and conflict check) procedure for package XYZ:
+# 1. Load a potential env variable XYZ_ROOT_DIR as a default choice for the cache entry XYZ_ROOT_DIR
+# If empty, load a potential XYZ_ROOT_DIR_EXP as default value (path exposed by another package depending
+# directly on XYZ)
+# 2. Invoke FIND_PACKAGE() in this order:
+# * in CONFIG mode first (if possible): priority is given to a potential
+# "XYZ-config.cmake" file
+# * then switch to the standard MODULE mode, appending on CMAKE_PREFIX_PATH
+# the above XYZ_ROOT_DIR variable
+# 3. Extract the path actually found into a temp variable _XYZ_TMP_DIR
+# 4. Warn if XYZ_ROOT_DIR is set and doesn't match what was found (e.g. when CMake found the system installation
+# instead of what is pointed to by XYZ_ROOT_DIR - happens when a typo in the content of XYZ_ROOT_DIR).
+# 5. Conflict detection:
+# * check the temp variable against a potentially existing XYZ_ROOT_DIR_EXP
+# 6. Finally expose what was *actually* found in XYZ_ROOT_DIR.
+# 7. Specific stuff: for example exposing a prerequisite of XYZ to the rest of the world for future
+# conflict detection. This is added after the call to the macro by the callee.
+#
+MACRO(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS pkg referenceVariable upCount)
+ STRING(TOUPPER ${pkg} pkg_UC)
+
+ # 1. Load environment or any previously detected root dir for the package
+ IF(DEFINED ENV{${pkg_UC}_ROOT_DIR})
+ FILE(TO_CMAKE_PATH "$ENV{${pkg_UC}_ROOT_DIR}" _${pkg_UC}_ROOT_DIR_ENV)
+ SET(_dflt_value "${_${pkg_UC}_ROOT_DIR_ENV}")
+ ELSE()
+ # will be blank if no package was previously loaded
+ SET(_dflt_value "${${pkg_UC}_ROOT_DIR_EXP}")
+ ENDIF()
+
+ # Make cache entry
+ SET(${pkg_UC}_ROOT_DIR "${_dflt_value}" CACHE PATH "Path to ${pkg_UC} directory")
+
+ # 2. Find package - config mode first (i.e. looking for XYZ-config.cmake)
+ IF(EXISTS "${${pkg_UC}_ROOT_DIR}")
+ # Hope to find direclty a CMake config file there
+ SET(_CONF_DIR "${${pkg_UC}_ROOT_DIR}/share/cmake")
+
+ # Try find_package in config mode with a hard-coded guess. This
+ # has the priority.
+ FIND_PACKAGE(${pkg} NO_MODULE QUIET PATHS "${_CONF_DIR}")
+ MARK_AS_ADVANCED(${pkg}_DIR)
+
+ IF (NOT ${pkg_UC}_FOUND)
+ LIST(APPEND CMAKE_PREFIX_PATH "${${pkg_UC}_ROOT_DIR}")
+ ELSE()
+ MESSAGE(STATUS "Found ${pkg} in CONFIG mode!")
+ ENDIF()
+ ENDIF()
+
+ # Otherwise try the standard way (module mode, with the standard CMake Find*** macro):
+ SALOME_FIND_PACKAGE("Salome${pkg}" ${pkg} MODULE)
+ #MESSAGE("dbg ${pkg_UC} / ${PTHREAD_FOUND} / ${${pkg_UC}_FOUND}")
+ # Set the "FOUND" variable for the SALOME wrapper:
+ IF(${pkg_UC}_FOUND OR ${pkg}_FOUND)
+ SET(SALOME${pkg_UC}_FOUND TRUE)
+ ELSE()
+ SET(SALOME${pkg_UC}_FOUND FALSE)
+ ENDIF()
+
+ IF (${pkg_UC}_FOUND OR ${pkg}_FOUND)
+ # 3. Set the root dir which was finally retained by going up "upDir" times
+ # from the given reference path. The variable "referenceVariable" may be a list
+ # - we take its first element.
+ # Note the double de-reference of "referenceVariable":
+ LIST(LENGTH "${${referenceVariable}}" _tmp_len)
+ IF(_tmp_len)
+ LIST(GET "${${referenceVariable}}" 0 _tmp_ROOT_DIR)
+ ELSE()
+ SET(_tmp_ROOT_DIR "${${referenceVariable}}")
+ ENDIF()
+ IF(${upCount})
+ MATH(EXPR _rge "${upCount}-1")
+ FOREACH(_unused RANGE ${_rge})
+ GET_FILENAME_COMPONENT(_tmp_ROOT_DIR "${_tmp_ROOT_DIR}" PATH)
+ ENDFOREACH()
+ ENDIF()
+
+ # 4. Warn if CMake found something not located under ENV(XYZ_ROOT_DIR)
+ IF(DEFINED ENV{${pkg_UC}_ROOT_DIR})
+ SALOME_CHECK_EQUAL_PATHS(_res "${_tmp_ROOT_DIR}" "${_${pkg_UC}_ROOT_DIR_ENV}")
+ IF(NOT _res)
+ MESSAGE(WARNING "${pkg} was found, but not at the path given by the "
+ "environment ${pkg_UC}_ROOT_DIR! Is the variable correctly set? "
+ "The two paths are: ${_tmp_ROOT_DIR} and: ${_${pkg_UC}_ROOT_DIR_ENV}")
+
+ ELSE()
+ MESSAGE(STATUS "${pkg} found directory matches what was specified in the ${pkg_UC}_ROOT_DIR variable, all good!")
+ ENDIF()
+ ELSE()
+ MESSAGE(STATUS "Environment variable ${pkg_UC}_ROOT_DIR is not defined. The system installation was found.")
+ ENDIF()
+
+ # 5. Conflict detection
+ # 5.1 From another prerequisite using the package
+ IF(${pkg_UC}_ROOT_DIR_EXP)
+ SALOME_CHECK_EQUAL_PATHS(_res "${_tmp_ROOT_DIR}" "${${pkg_UC}_ROOT_DIR_EXP}")
+ IF(NOT _res)
+ MESSAGE(WARNING "Warning: ${pkg}: detected version conflicts with a previously found ${pkg}!"
+ "The two paths are " ${_tmp_ROOT_DIR} " vs " ${${pkg_UC}_ROOT_DIR_EXP})
+ ELSE()
+ MESSAGE(STATUS "${pkg} directory matches what was previously exposed by another prereq, all good!")
+ ENDIF()
+ ENDIF()
+
+ # 6. Save the found installation
+ #
+ SET(${pkg_UC}_ROOT_DIR "${_tmp_ROOT_DIR}")
+
+ ELSE()
+ MESSAGE(STATUS "${pkg} was not found.")
+ ENDIF()
+ENDMACRO(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS)
quite poor. Remember that since the tests use connections to remote batch
systems, the first causes of failure are network and authentication errors. To
run the tests, you will first have to enable them by setting CMake variable
-TEST_ENABLED to ON. Then copy the file src/Core/Test/batchtest.conf to your
+LIBBATCH_TESTS to ON. Then copy the file src/Core/Test/batchtest.conf to your
home directory for instance. Edit this file according to your local
configuration. Set the environment variable BATCH_TEST_CONFIG_FILE to the path
to your own configuration file. To execute the autotests, just go to your build
--- /dev/null
+// Copyright (C) 2007-2013 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
+//
+
+#ifndef BATCH_CONFIG_H
+#define BATCH_CONFIG_H
+
+/* SH tools (sh, cp, rm, mkdir) found on the system */
+#cmakedefine HAS_SH
+
+/* A path to a sh-like command */
+#cmakedefine SH_COMMAND "@SH_COMMAND@"
+
+/* A path to a rm-like command */
+#cmakedefine RM_COMMAND "@RM_COMMAND@"
+
+/* A path to a cp-like command */
+#cmakedefine CP_COMMAND "@CP_COMMAND@"
+
+/* A path to a mkdir-like command */
+#cmakedefine MKDIR_COMMAND "@MKDIR_COMMAND@"
+
+/* RSH tools (rsh, rcp) found on the system */
+#cmakedefine HAS_RSH
+
+/* A path to a rsh-like command */
+#cmakedefine RSH_COMMAND "@RSH_COMMAND@"
+
+/* A path to a rcp-like command */
+#cmakedefine RCP_COMMAND "@RCP_COMMAND@"
+
+/* SSH tools (ssh, scp) found on the system */
+#cmakedefine HAS_SSH
+
+/* A path to a ssh-like command */
+#cmakedefine SSH_COMMAND "@SSH_COMMAND@"
+
+/* A path to a scp-like command */
+#cmakedefine SCP_COMMAND "@SCP_COMMAND@"
+
+#endif
INSTALL(FILES check_libbatch.m4
DESTINATION share/libbatch/misc)
-
-GET_TARGET_PROPERTY(LIBBATCH_ABS_PATH batch LOCATION)
-GET_FILENAME_COMPONENT(LIBBATCH_REAL_NAME ${LIBBATCH_ABS_PATH} NAME)
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libbatchConfig.cmake.in
- ${CMAKE_CURRENT_BINARY_DIR}/libbatchConfig.cmake @ONLY)
-
-INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libbatchConfig.cmake
- DESTINATION lib)
--- /dev/null
+# - Config file for the @PROJECT_NAME@ package
+# It defines the following variables.
+# Specific to the pacakge @PROJECT_NAME@ itself:
+# @PROJECT_NAME_UC@_INCLUDE_DIRS - include directories
+# @PROJECT_NAME_UC@_LIBRARIES - libraries to link against
+# @PROJECT_NAME_UC@_ROOT_DIR_EXP - the root path of the installation providing this CMake file
+#
+# Other stuff specific to this package:
+# 1. Some flags:
+# LIBBATCH_LOCAL_SUBMISSION - boolean indicating whether LibBatch was built with the
+# local submission support.
+# LIBBATCH_PYTHON_WRAPPING - boolean indicating whether the Python wrapping was built.
+# LIBBATCH_PYTHONPATH - (if above is True) path to the Python wrapping.
+
+###############################################################
+# Copyright (C) 2007-2013 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
+###############################################################
+
+### Initialisation performed by CONFIGURE_PACKAGE_CONFIG_FILE:
+@PACKAGE_INIT@
+
+### First the generic stuff for a standard module:
+SET(LIBBATCH_INCLUDE_DIRS "@PACKAGE_CONF_INCLUDE_DIRS@")
+
+# Load the dependencies for the libraries of @PROJECT_NAME@
+# (contains definitions for IMPORTED targets). This is only
+# imported if we are not built as a subproject (in this case targets are already there)
+IF(NOT batch AND NOT @PROJECT_NAME@_BINARY_DIR)
+ INCLUDE("@PACKAGE_INSTALL_CMAKE_CONFIG_DIR@/@PROJECT_NAME@Targets.cmake")
+ENDIF()
+
+# These are IMPORTED targets created by @PROJECT_NAME@Targets.cmake
+SET(LIBBATCH_LIBRARIES batch)
+
+# Package root dir:
+SET_AND_CHECK(LIBBATCH_ROOT_DIR_EXP "@PACKAGE_CMAKE_INSTALL_PREFIX@")
+
+#### Now the specificities
+
+# Options exported by the package:
+SET(LIBBATCH_LOCAL_SUBMISSION @LIBBATCH_LOCAL_SUBMISSION@)
+SET(LIBBATCH_PYTHON_WRAPPING @LIBBATCH_PYTHON_WRAPPING@)
+
+IF(LIBBATCH_PYTHON_WRAPPING)
+ SET_AND_CHECK(LIBBATCH_PYTHONPATH "@PACKAGE_LIBBATCH_PYTHONPATH@")
+ SET_AND_CHECK(PYTHON_ROOT_DIR_EXP "@PACKAGE_PYTHON_ROOT_DIR@")
+ SET_AND_CHECK(SWIG_ROOT_DIR_EXP "@PACKAGE_SWIG_ROOT_DIR@")
+ENDIF()
+
SET(HDR_FILES ${HDR_FILES} PARENT_SCOPE)
ENDMACRO(APPEND_CLASSES_TO_HDR_FILES)
-IF (MSVC)
- add_definitions(/wd4251 /wd4290) # Disable annoying Visual C++ warnings
-ENDIF (MSVC)
+IF (WIN32)
+ ADD_DEFINITIONS(/wd4251 /wd4290) # Disable annoying Visual C++ warnings
+ENDIF (WIN32)
-# !!! to avoid using wrong config.h file on win32 platform add include directories only in following order
-include_directories(${CMAKE_BINARY_DIR} ${PTHREAD_INCLUDE_DIR})
+INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}
+ ${PTHREAD_INCLUDE_DIR})
-add_subdirectory (Core)
+ADD_SUBDIRECTORY (Core)
-IF (BUILD_LOCAL_SUBMISSION)
- add_subdirectory (Local)
-ENDIF (BUILD_LOCAL_SUBMISSION)
+IF (LIBBATCH_LOCAL_SUBMISSION)
+ ADD_SUBDIRECTORY (Local)
+ENDIF ()
-add_subdirectory (CCC)
-add_subdirectory (LSF)
-add_subdirectory (PBS)
-add_subdirectory (OAR)
-add_subdirectory (COORM)
-add_subdirectory (SGE)
-add_subdirectory (LoadLeveler)
-add_subdirectory (Slurm)
+ADD_SUBDIRECTORY (CCC)
+ADD_SUBDIRECTORY (LSF)
+ADD_SUBDIRECTORY (PBS)
+ADD_SUBDIRECTORY (OAR)
+ADD_SUBDIRECTORY (COORM)
+ADD_SUBDIRECTORY (SGE)
+ADD_SUBDIRECTORY (LoadLeveler)
+ADD_SUBDIRECTORY (Slurm)
# Vishnu is not available for Windows
IF (NOT WIN32)
- add_subdirectory (Vishnu)
+ ADD_SUBDIRECTORY (Vishnu)
ENDIF (NOT WIN32)
-add_library(batch SHARED ${SRC_FILES})
+ADD_LIBRARY (batch SHARED ${SRC_FILES})
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Core)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Local)
-target_link_libraries(batch ${PTHREAD_LIBRARY})
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/Core)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/Local)
+TARGET_LINK_LIBRARIES(batch ${PTHREAD_LIBRARY})
IF (WIN32)
- target_link_libraries(batch ws2_32)
+ TARGET_LINK_LIBRARIES(batch ws2_32)
ENDIF (WIN32)
# If necessary, activate all warnings (useful for debugging and code cleaning)
# add_definitions(-Wall -Werror -ansi -pedantic)
-INSTALL(TARGETS batch DESTINATION lib)
+INSTALL(TARGETS batch
+ EXPORT LibBatchTargets
+ DESTINATION lib)
INSTALL(FILES ${HDR_FILES} DESTINATION include/libbatch)
-IF (BUILD_PYTHON_WRAPPING AND PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND AND SWIG_FOUND)
- add_subdirectory (Python)
-ENDIF (BUILD_PYTHON_WRAPPING AND PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND AND SWIG_FOUND)
+IF (LIBBATCH_PYTHON_WRAPPING AND PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND AND SWIG_FOUND)
+ ADD_SUBDIRECTORY(Python)
+ENDIF ()
ENDIF (HAS_SSH)
-IF (TEST_ENABLED)
- add_subdirectory(Test)
-ENDIF (TEST_ENABLED)
+IF (LIBBATCH_TESTS)
+ ADD_SUBDIRECTORY(Test)
+ENDIF ()
#include <stdlib.h>
-#include <config.h>
+#include <libbatch_config.h>
#include "CommunicationProtocol.hxx"
#ifdef HAS_RSH
#include <RunTimeException.hxx>
#endif
-#include <config.h>
+#include <libbatch_config.h>
#include "CommunicationProtocolRSH.hxx"
#include "Log.hxx"
* Author : Renaud BARATE - EDF R&D
*/
-#include <config.h>
+#include <libbatch_config.h>
#include "CommunicationProtocolSH.hxx"
#include "Utils.hxx"
* Author : Renaud BARATE - EDF R&D
*/
-#include <config.h>
+#include <libbatch_config.h>
#include "CommunicationProtocolSSH.hxx"
#include "Utils.hxx"
#include "Log.hxx"
+#include <time.h>
#ifdef WIN32
#include <time.h>
#
# Declare the configuration variable for the test scripts
-SET (TEST_CONFIG_FILE_ENV_VAR "BATCH_TEST_CONFIG_FILE" CACHE STRING
+SET (LIBBATCH_TEST_CONF_ENV_VAR "BATCH_TEST_CONFIG_FILE" CACHE STRING
"Name of the environment variable containing the configuration file name for the tests (only necessary for test target)")
# Configure the config file for the test scripts
# Set the include directories
include_directories(${CMAKE_CURRENT_BINARY_DIR})
-include_directories(${CMAKE_SOURCE_DIR}/src/Core)
+include_directories(${PROJECT_SOURCE_DIR}/src/Core)
# Build SimpleParser library
add_library (SimpleParser STATIC SimpleParser.cxx)
//
/* Environment variable containing the path of the test configuration file */
-#define TEST_CONFIG_FILE_ENV_VAR "${TEST_CONFIG_FILE_ENV_VAR}"
+#define TEST_CONFIG_FILE_ENV_VAR "${LIBBATCH_TEST_CONF_ENV_VAR}"
/* Current source directory */
#define CMAKE_CURRENT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
# set the environment variable BATCH_TEST_CONFIG_FILE to the path to your own configuration
# file.
# Note that BATCH_TEST_CONFIG_FILE is the default name for this environment variable. It can be
-# changed at compilation time by setting CMake option TEST_CONFIG_FILE_ENV_VAR.
+# changed at compilation time by setting CMake option LIBBATCH_TEST_CONF_ENV_VAR.
TEST_LOCAL_SH_HOST = "localhost" # Not used
TEST_LOCAL_SH_USER = "me" # Not used
#include <cstdio>
#include <iostream>
#include <fstream>
+#include <time.h>
#ifdef WIN32
-#include <Windows.h>
-#include <time.h>
-#include <io.h>
+# include <Windows.h>
+# include <io.h>
+# define popen _popen
+# define pclose _pclose
#else
-#include <sys/stat.h>
-#include <unistd.h>
+# include <sys/stat.h>
+# include <unistd.h>
#endif
-#include <config.h>
+#include <libbatch_config.h>
#include "Utils.hxx"
#include "RunTimeException.hxx"
-#ifdef MSVC
-#define popen _popen
-#define pclose _pclose
-#endif
-
using namespace std;
namespace Batch {
APPEND_CLASSES_TO_SRC_FILES(${CLASS_LIST})
-IF (TEST_ENABLED AND HAS_SSH)
- ADD_TEST(LSF_SSH ${CMAKE_BINARY_DIR}/src/Core/Test/Test_BatchManager LSF SSH)
-ENDIF (TEST_ENABLED AND HAS_SSH)
+IF (HAS_SSH)
+ ADD_TEST(LSF_SSH ${PROJECT_BINARY_DIR}/src/Core/Test/Test_BatchManager LSF SSH)
+ENDIF ()
APPEND_CLASSES_TO_SRC_FILES(${CLASS_LIST})
-IF (TEST_ENABLED)
- IF (HAS_SH)
- ADD_TEST(LOCAL_SH ${CMAKE_BINARY_DIR}/src/Core/Test/Test_BatchManager LOCAL SH)
- ENDIF (HAS_SH)
+IF (HAS_SH)
+ ADD_TEST(LOCAL_SH ${PROJECT_BINARY_DIR}/src/Core/Test/Test_BatchManager LOCAL SH)
+ENDIF ()
- IF (HAS_SSH)
- ADD_TEST(LOCAL_SSH ${CMAKE_BINARY_DIR}/src/Core/Test/Test_BatchManager LOCAL SSH)
- ENDIF (HAS_SSH)
+IF (HAS_SSH)
+ ADD_TEST(LOCAL_SSH ${PROJECT_BINARY_DIR}/src/Core/Test/Test_BatchManager LOCAL SSH)
+ENDIF ()
- IF (HAS_RSH)
- ADD_TEST(LOCAL_RSH ${CMAKE_BINARY_DIR}/src/Core/Test/Test_BatchManager LOCAL RSH)
- ENDIF (HAS_RSH)
-ENDIF (TEST_ENABLED)
+IF (HAS_RSH)
+ ADD_TEST(LOCAL_RSH ${PROJECT_BINARY_DIR}/src/Core/Test/Test_BatchManager LOCAL RSH)
+ENDIF ()
+
*
*/
-#include <config.h>
+#include <libbatch_config.h>
#include "BatchManager_Local.hxx"
#include "FactBatchManager_Local.hxx"
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
SET(SWIG_SRC_FILE libBatch_Swig.i)
+SET(SWIG_LB_DPYS
+ libBatch_Swig_exception.i
+ libBatch_Swig_typemap.i
+ ../Core/Defines.hxx
+ ../Core/Constants.hxx
+ ../Core/Job.hxx
+ ../Core/JobId.hxx
+ ../Core/JobInfo.hxx
+ ../Core/CommunicationProtocol.hxx
+ ../Core/BatchManager.hxx
+ ../Core/BatchManagerCatalog.hxx
+ ../Core/FactBatchManager.hxx
+ )
+
SET_SOURCE_FILES_PROPERTIES(${SWIG_SRC_FILE} PROPERTIES CPLUSPLUS ON
SWIG_FLAGS "-shadow")
+# SWIG source file and module name differ - the following needs to be
+# set to avoid unnecessary rebuilds:
+SET_SOURCE_FILES_PROPERTIES(${SWIG_SRC_FILE} PROPERTIES SWIG_MODULE_NAME libbatch)
+
+SET(SWIG_MODULE_libbatch_EXTRA_DEPS ${SWIG_LB_DPYS})
SWIG_ADD_MODULE(libbatch python ${SWIG_SRC_FILE})
SWIG_LINK_LIBRARIES(libbatch batch ${PYTHON_LIBRARIES})
SET(PYTHON_VERSION "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")
-INSTALL(TARGETS ${SWIG_MODULE_libbatch_REAL_NAME} DESTINATION lib/python${PYTHON_VERSION}/site-packages)
+INSTALL(TARGETS ${SWIG_MODULE_libbatch_REAL_NAME} DESTINATION ${LIBBATCH_PYTHONPATH})
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libbatch.py
- DESTINATION lib/python${PYTHON_VERSION}/site-packages)
-
-SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES libbatch.py)
+ DESTINATION ${LIBBATCH_PYTHONPATH})
-IF (TEST_ENABLED)
- add_subdirectory(Test)
-ENDIF (TEST_ENABLED)
+IF (LIBBATCH_TESTS)
+ ADD_SUBDIRECTORY(Test)
+ENDIF ()
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-IF (BUILD_LOCAL_SUBMISSION AND HAS_SH)
+IF (LIBBATCH_LOCAL_SUBMISSION AND HAS_SH)
# Configure the config file for the test script
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.py.in ${CMAKE_CURRENT_BINARY_DIR}/config.py)
# Add the test
ADD_TEST(Python_Local_SH ${PYTHON_EXECUTABLE} Test_Python_Local_SH.py)
-ENDIF (BUILD_LOCAL_SUBMISSION AND HAS_SH)
+ENDIF ()
import os
sys.path.append('${CMAKE_CURRENT_BINARY_DIR}/..')
-configfile = os.environ["${TEST_CONFIG_FILE_ENV_VAR}"]
+configfile = os.environ["${LIBBATCH_TEST_CONF_ENV_VAR}"]
execfile(configfile)
TEST_SOURCE_DIR = "${CMAKE_SOURCE_DIR}/src/Core/Test"
APPEND_CLASSES_TO_SRC_FILES(${CLASS_LIST})
-IF (TEST_ENABLED AND HAS_SSH)
- ADD_TEST(SLURM_SSH ${CMAKE_BINARY_DIR}/src/Core/Test/Test_BatchManager SLURM SSH)
-ENDIF (TEST_ENABLED AND HAS_SSH)
+IF (HAS_SSH)
+ ADD_TEST(SLURM_SSH ${PROJECT_BINARY_DIR}/src/Core/Test/Test_BatchManager SLURM SSH)
+ENDIF ()
APPEND_CLASSES_TO_SRC_FILES(${CLASS_LIST})
-IF (TEST_ENABLED)
- ADD_TEST(VISHNU ${CMAKE_BINARY_DIR}/src/Core/Test/Test_BatchManager VISHNU SH)
-ENDIF (TEST_ENABLED)
+IF (HAS_SSH)
+ ADD_TEST(VISHNU ${PROJECT_BINARY_DIR}/src/Core/Test/Test_BatchManager VISHNU SH)
+ENDIF ()