]> SALOME platform Git repositories - tools/libbatch.git/commitdiff
Salome HOME
CMake updates
authorbarate <barate>
Tue, 15 Jan 2013 16:18:08 +0000 (16:18 +0000)
committerbarate <barate>
Tue, 15 Jan 2013 16:18:08 +0000 (16:18 +0000)
CMakeLists.txt
CMakeModules/FindPython.cmake [deleted file]
CMakeModules/FindSWIG.cmake [deleted file]
CMakeModules/Summary.cmake
src/CMakeLists.txt
src/Python/CMakeLists.txt

index fefef0ba7e5a646e7bb3c3d6fe18a999b99d9366..9a73af706316d659f15bf8ffab426d73562d3e6b 100644 (file)
@@ -22,7 +22,7 @@
 
 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)
@@ -40,7 +40,9 @@ IF (BUILD_LOCAL_SUBMISSION)
     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)
 
diff --git a/CMakeModules/FindPython.cmake b/CMakeModules/FindPython.cmake
deleted file mode 100644 (file)
index a6a3c82..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-#  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)
diff --git a/CMakeModules/FindSWIG.cmake b/CMakeModules/FindSWIG.cmake
deleted file mode 100644 (file)
index 87d95a8..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-#  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)
index 3953944f94a46414319fa4295112bc32b46e10ef..8914ed811d94502c9877341d079929db098f8c8d 100644 (file)
@@ -30,11 +30,11 @@ ELSE (BUILD_LOCAL_SUBMISSION)
 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)
index d334b162f962b7d67b695b476eb6642cd329affa..69ccb0e44e504813e33e2c772e2c158f05024b68 100644 (file)
 #  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)
@@ -62,14 +58,6 @@ IF (NOT WIN32)
     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)
@@ -86,6 +74,6 @@ ENDIF (WIN32)
 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)
index 6f5dfe0420ecc0f4a14864f5527340f750186e20..8e901b9eac6be1a1f3e0a49907bffdee11e58b18 100644 (file)
@@ -31,6 +31,7 @@ SET_SOURCE_FILES_PROPERTIES(${SWIG_SRC_FILE} PROPERTIES CPLUSPLUS ON
 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)