project (libBatch)
-cmake_minimum_required (VERSION 2.4)
+cmake_minimum_required (VERSION 2.8)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules/)
find_package (PThread REQUIRED)
find_package (Local)
ENDIF (BUILD_LOCAL_SUBMISSION)
IF (BUILD_PYTHON_WRAPPING)
- FIND_PACKAGE(Python)
+ FIND_PACKAGE(PythonInterp)
+ SET(PythonLibs_FIND_VERSION ${PYTHON_VERSION_STRING})
+ FIND_PACKAGE(PythonLibs)
FIND_PACKAGE(SWIG)
ENDIF (BUILD_PYTHON_WRAPPING)
+++ /dev/null
-# Copyright (C) 2007-2012 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
-#
-
-# We use a custom FindPYTHON.cmake because the one shipped with cmake doesn't search
-# properly for the version number.
-
-IF (NOT Python_FIND_QUIETLY)
- MESSAGE(STATUS "Looking for Python...")
-ENDIF (NOT Python_FIND_QUIETLY)
-
-IF(WIN32 AND NOT CMAKE_BUILD_TYPE STREQUAL Release)
- FIND_PROGRAM(PYTHON_DEBUG python_d)
- mark_as_advanced(PYTHON_DEBUG)
-ENDIF(WIN32 AND NOT CMAKE_BUILD_TYPE STREQUAL Release)
-
-IF (PYTHON_DEBUG)
- SET(PYTHON_EXECUTABLE ${PYTHON_DEBUG} CACHE STRING "Python interpreter")
-ELSE (PYTHON_DEBUG)
- IF(MSVC AND NOT CMAKE_BUILD_TYPE STREQUAL Release)
- MESSAGE(STATUS "Warning! Python debug executable not found. To build Swig module, you will need to install it or compile in Release mode")
- ELSE(MSVC AND NOT CMAKE_BUILD_TYPE STREQUAL Release)
- FIND_PROGRAM(PYTHON_EXECUTABLE python DOC "Python interpreter")
- ENDIF(MSVC AND NOT CMAKE_BUILD_TYPE STREQUAL Release)
-ENDIF (PYTHON_DEBUG)
-
-IF (PYTHON_EXECUTABLE)
- IF (NOT Python_FIND_QUIETLY)
- MESSAGE(STATUS "Python executable: ${PYTHON_EXECUTABLE}")
- ENDIF (NOT Python_FIND_QUIETLY)
-
- EXECUTE_PROCESS(
- COMMAND ${PYTHON_EXECUTABLE} -c "import sys; sys.stdout.write(sys.version[:3])"
- OUTPUT_VARIABLE PYTHON_VERSION
- )
-
- IF (NOT Python_FIND_QUIETLY)
- MESSAGE(STATUS "Python version: ${PYTHON_VERSION}")
- ENDIF (NOT Python_FIND_QUIETLY)
-
- EXECUTE_PROCESS(
- COMMAND ${PYTHON_EXECUTABLE} -c "import sys; import distutils.sysconfig; sys.stdout.write(distutils.sysconfig.get_python_inc())"
- OUTPUT_VARIABLE PYTHON_DETECTED_INCLUDE_DIR
- )
-
- SET(PYTHON_HEADER Python.h)
- FIND_PATH(PYTHON_INCLUDE_DIRS ${PYTHON_HEADER}
- PATHS ${PYTHON_DETECTED_INCLUDE_DIR}
- DOC "Python include directories")
-
- IF (NOT Python_FIND_QUIETLY)
- IF (PYTHON_INCLUDE_DIRS)
- MESSAGE(STATUS "Python include directories: ${PYTHON_INCLUDE_DIRS}")
- ELSE (PYTHON_INCLUDE_DIRS)
- MESSAGE(STATUS "Could not find Python include directories (looked for file ${PYTHON_HEADER} in directory ${PYTHON_DETECTED_INCLUDE_DIR})")
- ENDIF (PYTHON_INCLUDE_DIRS)
- ENDIF (NOT Python_FIND_QUIETLY)
-
- FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/findpythonlib.py
- "import sys\n"
- "import os\n"
- "import distutils.sysconfig\n"
- "libdir = distutils.sysconfig.get_config_var('LIBDIR')\n"
- "if libdir is None:\n"
- " prefix = distutils.sysconfig.get_config_var('prefix')\n"
- " libdir = prefix + ';' + os.path.join(prefix, 'lib') + ';' + os.path.join(prefix, 'libs')\n"
- "sys.stdout.write(libdir)"
- )
-
- EXECUTE_PROCESS(
- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/findpythonlib.py
- OUTPUT_VARIABLE PYTHON_DETECTED_LIB_DIRS
- )
-
- IF(WIN32)
- STRING(REPLACE "." "" PYTHON_VERSION_WITHOUT_DOT ${PYTHON_VERSION})
- IF(PYTHON_DEBUG)
- SET(LIB_NAME python${PYTHON_VERSION_WITHOUT_DOT}_d)
- ELSE(PYTHON_DEBUG)
- SET(LIB_NAME python${PYTHON_VERSION_WITHOUT_DOT})
- ENDIF(PYTHON_DEBUG)
- ELSE(WIN32)
- SET(LIB_NAME python${PYTHON_VERSION})
- ENDIF(WIN32)
-
- FIND_LIBRARY(PYTHON_LIBRARIES ${LIB_NAME} ${PYTHON_DETECTED_LIB_DIRS} DOC "Python libraries")
-
- IF (NOT Python_FIND_QUIETLY)
- IF (PYTHON_LIBRARIES)
- MESSAGE(STATUS "Python libraries: ${PYTHON_LIBRARIES}")
- ELSE (PYTHON_LIBRARIES)
- MESSAGE(STATUS "Could not find Python libraries (looked for library ${LIB_NAME} in directory ${PYTHON_DETECTED_LIB_DIRS})")
- ENDIF (PYTHON_LIBRARIES)
- ENDIF (NOT Python_FIND_QUIETLY)
-
-ENDIF (PYTHON_EXECUTABLE)
-
-IF(PYTHON_EXECUTABLE AND PYTHON_LIBRARIES AND PYTHON_INCLUDE_DIRS)
- SET(Python_FOUND True)
-ENDIF(PYTHON_EXECUTABLE AND PYTHON_LIBRARIES AND PYTHON_INCLUDE_DIRS)
-
-IF (Python_FOUND)
-
- IF (NOT Python_FIND_QUIETLY)
- MESSAGE(STATUS "OK, working Python installation found")
- ENDIF (NOT Python_FIND_QUIETLY)
-
-ELSE (Python_FOUND)
-
- IF (Python_FIND_REQUIRED)
- MESSAGE(FATAL_ERROR "No working Python installation found")
- ELSE (Python_FIND_REQUIRED)
- IF (NOT Python_FIND_QUIETLY)
- MESSAGE(STATUS "No working Python installation found")
- ENDIF (NOT Python_FIND_QUIETLY)
- ENDIF (Python_FIND_REQUIRED)
-
-ENDIF (Python_FOUND)
+++ /dev/null
-# Copyright (C) 2007-2012 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
-#
-
-# We use a custom FindSWIG.cmake because the one shipped with cmake doesn't search
-# properly in the $PATH env var.
-
-IF (NOT SWIG_FIND_QUIETLY)
- MESSAGE(STATUS "Looking for SWIG...")
-ENDIF (NOT SWIG_FIND_QUIETLY)
-
-FIND_PROGRAM(SWIG_EXECUTABLE NAMES swig swig-1.3 DOC "SWIG executable")
-
-SET(SWIG_FOUND ${SWIG_EXECUTABLE})
-
-IF (SWIG_FOUND)
-
- IF (NOT SWIG_FIND_QUIETLY)
- MESSAGE(STATUS "Found SWIG: ${SWIG_EXECUTABLE}")
- ENDIF (NOT SWIG_FIND_QUIETLY)
-
-ELSE (SWIG_FOUND)
-
- IF (SWIG_FIND_REQUIRED)
- MESSAGE(FATAL_ERROR "SWIG not found")
- ELSE (SWIG_FIND_REQUIRED)
- IF (NOT SWIG_FIND_QUIETLY)
- MESSAGE(STATUS "SWIG not found")
- ENDIF (NOT SWIG_FIND_QUIETLY)
- ENDIF (SWIG_FIND_REQUIRED)
-
-ENDIF (SWIG_FOUND)
ENDIF (BUILD_LOCAL_SUBMISSION)
IF (BUILD_PYTHON_WRAPPING)
- IF (Python_FOUND AND SWIG_FOUND)
+ IF (PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND AND SWIG_FOUND)
MESSAGE(STATUS "Python wrapping ..................... Yes")
- ELSE (Python_FOUND AND SWIG_FOUND)
+ ELSE (PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND AND SWIG_FOUND)
MESSAGE(STATUS "Python wrapping ............... Not found")
- ENDIF (Python_FOUND AND SWIG_FOUND)
+ ENDIF (PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND AND SWIG_FOUND)
ELSE (BUILD_PYTHON_WRAPPING)
MESSAGE(STATUS "Python wrapping ........... Not requested")
ENDIF (BUILD_PYTHON_WRAPPING)
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-# These macros are used to create the lists of source files and header files in global variables.
-# If we move to cmake 2.6, this can be done more cleanly with the PARENT_SCOPE option.
-MACRO(APPEND_TO_GLOBAL_VAR VAR)
- SET(${VAR} ${${VAR}} ${ARGN} CACHE INTERNAL "")
-ENDMACRO(APPEND_TO_GLOBAL_VAR)
-
MACRO(APPEND_CLASSES_TO_SRC_FILES)
FOREACH(CLASS ${ARGV})
- APPEND_TO_GLOBAL_VAR(SRC_FILES_BUILD ${CLASS}.cxx)
+ LIST(APPEND SRC_FILES ${CLASS}.cxx)
ENDFOREACH(CLASS ${ARGV})
+ SET(SRC_FILES ${SRC_FILES} PARENT_SCOPE)
ENDMACRO(APPEND_CLASSES_TO_SRC_FILES)
MACRO(APPEND_CLASSES_TO_HDR_FILES)
FOREACH(CLASS ${ARGV})
- APPEND_TO_GLOBAL_VAR(HDR_FILES_BUILD ${CLASS}.hxx)
+ LIST(APPEND HDR_FILES ${CLASS}.hxx)
ENDFOREACH(CLASS ${ARGV})
+ SET(HDR_FILES ${HDR_FILES} PARENT_SCOPE)
ENDMACRO(APPEND_CLASSES_TO_HDR_FILES)
IF (MSVC)
add_subdirectory (Vishnu)
ENDIF (NOT WIN32)
-# Make a copy of the built value and clear the built value for the next run of cmake
-SET(SRC_FILES ${SRC_FILES_BUILD} CACHE INTERNAL "")
-SET(SRC_FILES_BUILD CACHE INTERNAL "")
-
-SET(HDR_FILES ${HDR_FILES_BUILD} CACHE INTERNAL "")
-SET(HDR_FILES_BUILD CACHE INTERNAL "")
-
-
add_library(batch SHARED ${SRC_FILES})
include_directories(${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/Core)
INSTALL(TARGETS batch DESTINATION lib)
INSTALL(FILES ${HDR_FILES} DESTINATION include/libbatch)
-IF (BUILD_PYTHON_WRAPPING AND Python_FOUND AND SWIG_FOUND)
+IF (BUILD_PYTHON_WRAPPING AND PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND AND SWIG_FOUND)
add_subdirectory (Python)
-ENDIF (BUILD_PYTHON_WRAPPING AND Python_FOUND AND SWIG_FOUND)
+ENDIF (BUILD_PYTHON_WRAPPING AND PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND AND SWIG_FOUND)
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(FILES ${CMAKE_CURRENT_BINARY_DIR}/libbatch.py
DESTINATION lib/python${PYTHON_VERSION}/site-packages)