]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Fix compilation with NumPy/SciPy.
authorrnv <rnv@opencascade.com>
Mon, 15 Feb 2016 16:24:41 +0000 (19:24 +0300)
committerrnv <rnv@opencascade.com>
Mon, 15 Feb 2016 16:28:32 +0000 (19:28 +0300)
CMakeLists.txt
cmake_files/CMakeLists.txt
cmake_files/FindSalomeNumPySciPy.cmake [new file with mode: 0644]
cmake_files/FindSalomePythonInterp.cmake
src/MEDCoupling_Swig/CMakeLists.txt
src/MEDLoader/Swig/CMakeLists.txt
src/MEDPartitioner_Swig/CMakeLists.txt
src/ParaMEDMEM_Swig/CMakeLists.txt
src/RENUMBER_Swig/CMakeLists.txt

index 22e4adb218dd6af5d522f7f6a4b409db50c701a0..7bdd64ffedfd2c24aa8a4911579b8239b62cf16e 100644 (file)
@@ -117,18 +117,11 @@ ENDIF(MEDCOUPLING_ENABLE_RENUMBER)
 IF(MEDCOUPLING_ENABLE_PYTHON)
   FIND_PACKAGE(SalomePythonInterp)
   FIND_PACKAGE(SalomePythonLibs)
+  FIND_PACKAGE(SalomeNumPySciPy)
   FIND_PACKAGE(SalomeSWIG)
   SALOME_LOG_OPTIONAL_PACKAGE(PythonInterp MEDCOUPLING_ENABLE_PYTHON)
   SALOME_LOG_OPTIONAL_PACKAGE(PythonLibs MEDCOUPLING_ENABLE_PYTHON)
   SALOME_LOG_OPTIONAL_PACKAGE(SWIG   MEDCOUPLING_ENABLE_PYTHON)
-  # Set the extra flags for SWIG for numpy and scipy
-  SET(SWIG_EXTRA_FLAGS_FOR_NUMPYANDSCIPY)
-  IF(NUMPY_FOUND)
-    SET(SWIG_EXTRA_FLAGS_FOR_NUMPYANDSCIPY "-DWITH_NUMPY")
-  ENDIF(NUMPY_FOUND)
-  IF(SCIPY_FOUND)
-    SET(SWIG_EXTRA_FLAGS_FOR_NUMPYANDSCIPY "${SWIG_EXTRA_FLAGS_FOR_NUMPYANDSCIPY};-DWITH_SCIPY")
-  ENDIF(SCIPY_FOUND)
 ENDIF(MEDCOUPLING_ENABLE_PYTHON)
 
 IF(MEDCOUPLING_BUILD_DOC)
index a44071bb06ae7d0b74a01828e3a82f95ae1e5812..1e4aeaa292367d7ab38acbfd9c6834ff586e8b34 100644 (file)
@@ -34,9 +34,9 @@ SET(admlocal_cmake_DATA
     FindSalomeMetis.cmake
     FindSalomeMPI.cmake
     FindSalomeParMetis.cmake
-#    FindSalomePython.cmake
     FindSalomePythonLibs.cmake
     FindSalomePythonInterp.cmake
+    FindSalomeNumPySciPy.cmake
     FindSalomeScotch.cmake
     FindSalomeSphinx.cmake
     FindSalomeSWIG.cmake
diff --git a/cmake_files/FindSalomeNumPySciPy.cmake b/cmake_files/FindSalomeNumPySciPy.cmake
new file mode 100644 (file)
index 0000000..f88a20b
--- /dev/null
@@ -0,0 +1,52 @@
+# Copyright (C) 2013-2015  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, or (at your option) any later version.
+#
+# 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: Roman NIKOLAEV
+#
+# Looking for an installation of NumPy and SciPy, and if found the following variables are set
+#   NUMPY_INCLUDE_DIR  - NumPy header location
+#   NUMPY_DEFINITIONS  - NumPy compiler flags
+#   SCIPY_DEFINITIONS  - SciPy compiler flags
+#   SCIPY_VERSION      - SciPy version
+#
+
+IF(SALOMEPYTHONINTERP_FOUND)   
+  # Numpy
+  EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "import numpy ; import sys ; sys.stdout.write(numpy.get_include())" OUTPUT_VARIABLE NUMPY_INCLUDE_DIR ERROR_QUIET )
+  IF(NUMPY_INCLUDE_DIR)
+    SET(NUMPY_FOUND TRUE)
+  ENDIF(NUMPY_INCLUDE_DIR)
+  IF(NUMPY_FOUND)
+    SET(NUMPY_DEFINITIONS -DWITH_NUMPY)
+    MESSAGE(STATUS "NumPy found : ${NUMPY_INCLUDE_DIR}")
+  ELSE(NUMPY_FOUND)
+    MESSAGE(STATUS "NumPy not found.")
+  ENDIF(NUMPY_FOUND)
+
+  # SciPy detection
+  EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "import scipy ; import sys ; sys.stdout.write(scipy.version.version)" OUTPUT_VARIABLE SCIPY_VERSION ERROR_QUIET )
+  IF(SCIPY_VERSION)
+    SET(SCIPY_FOUND TRUE)
+  ENDIF(SCIPY_VERSION)
+  IF(SCIPY_FOUND)
+    MESSAGE(STATUS "Scipy found : Version ${SCIPY_VERSION}")
+    SET(SCIPY_DEFINITIONS -DWITH_SCIPY)
+  ELSE(SCIPY_FOUND)
+    MESSAGE(STATUS "SciPy not found.")
+  ENDIF(SCIPY_FOUND)
+ENDIF()
\ No newline at end of file
index 9028f26ce3d21541e6b861c595515f9600397303..8b20e14cc4390f4fd1f30a977d22afedd0421ebc 100644 (file)
 #
 #  !! Please read the generic detection procedure in SalomeMacros.cmake !!
 #
-# We also look for an installation of NumPy, and if found the following variables are set
-#   NUMPY_INCLUDE_DIR  - NumPy header location
-#   NUMPY_DEFINITIONS  - compiler flag
-# and are automatically appended to PYTHON_INCLUDE_DIRS (and PYTHON_DEFINITIONS resp.)    
-#
 
 # Make sure the detection of both libs and interpreter (if both needed) occur in the correct order:
 IF(SALOMEPYTHONLIBS_FOUND AND NOT SALOMEPYTHONINTERP_FOUND)
@@ -45,32 +40,6 @@ SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(PythonInterp PYTHON_EXECUTABLE 1)
 
 IF(SALOMEPYTHONINTERP_FOUND) 
   SET(PYTHON_PYTHONPATH "${PYTHON_ROOT_DIR}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")
-  
-  ##
-  ## Specifics -- NumPy/SciPy detection
-  ##
-  
-  # Numpy
-  EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "import numpy ; import sys ; sys.stdout.write(numpy.get_include())" OUTPUT_VARIABLE NUMPY_INCLUDE_DIR ERROR_QUIET )
-  IF(NUMPY_INCLUDE_DIR)
-    SET(NUMPY_FOUND TRUE)
-  ENDIF(NUMPY_INCLUDE_DIR)
-  IF(NUMPY_FOUND)
-    SET(PYTHON_INCLUDE_DIRS ${NUMPY_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS})
-    SET(PYTHON_DEFINITIONS "${PYTHON_DEFINITIONS} -DWITH_NUMPY")
-    MESSAGE(STATUS "NumPy found : ${NUMPY_INCLUDE_DIR}")
-  ELSE(NUMPY_FOUND)
-    MESSAGE(STATUS "NumPy not found.")
-  ENDIF(NUMPY_FOUND)
-  # SciPy detection
-  EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "import scipy ; import sys ; sys.stdout.write(scipy.version.version)" OUTPUT_VARIABLE SCIPY_VERSION ERROR_QUIET )
-  IF(SCIPY_VERSION)
-    SET(SCIPY_FOUND TRUE)
-  ENDIF(SCIPY_VERSION)
-  IF(SCIPY_FOUND)
-    MESSAGE(STATUS "Scipy found : Version ${SCIPY_VERSION}")
-  ENDIF(SCIPY_FOUND)
-
   SALOME_ACCUMULATE_ENVIRONMENT(PATH ${PYTHON_EXECUTABLE})
   SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH ${PYTHON_PYTHONPATH})
 ENDIF()
index 9a026431da27b0194f214390f68b835d35170166..bfed34b687e5fbe7ee67325402ba6105d230f481 100644 (file)
 
 INCLUDE(${SWIG_USE_FILE})
 
-ADD_DEFINITIONS(${PYTHON_DEFINITIONS})
+ADD_DEFINITIONS(${PYTHON_DEFINITIONS} ${NUMPY_DEFINITIONS} ${SCIPY_DEFINITIONS})
 
 SET_SOURCE_FILES_PROPERTIES(MEDCoupling.i PROPERTIES CPLUSPLUS ON)
 SET_SOURCE_FILES_PROPERTIES(MEDCoupling.i PROPERTIES SWIG_DEFINITIONS "-shadow")
-SET(SWIG_MODULE_MEDCoupling_EXTRA_FLAGS ${SWIG_EXTRA_FLAGS_FOR_NUMPYANDSCIPY})
+SET(SWIG_MODULE_MEDCoupling_EXTRA_FLAGS "${NUMPY_DEFINITIONS};${SCIPY_DEFINITIONS}")
 
 SET (MEDCoupling_SWIG_DPYS_FILES
     MEDCouplingCommon.i
@@ -59,6 +59,7 @@ SET (MC_Swig_interf
 
 INCLUDE_DIRECTORIES(
   ${PYTHON_INCLUDE_DIRS}
+  ${NUMPY_INCLUDE_DIR}
   ${PTHREAD_INCLUDE_DIR} # pthread dependancy due to python2.7 library
   ${CMAKE_CURRENT_SOURCE_DIR}
   ${CMAKE_CURRENT_BINARY_DIR}
@@ -90,7 +91,7 @@ SWIG_LINK_LIBRARIES(MEDCoupling ${PYTHON_LIBRARIES} ${PLATFORM_LIBS} medcoupling
 
 SET_SOURCE_FILES_PROPERTIES(MEDCouplingRemapper.i PROPERTIES CPLUSPLUS ON)
 SET_SOURCE_FILES_PROPERTIES(MEDCouplingRemapper.i PROPERTIES SWIG_DEFINITIONS "-shadow")
-SET(SWIG_MODULE_MEDCouplingRemapper_EXTRA_FLAGS ${SWIG_EXTRA_FLAGS_FOR_NUMPYANDSCIPY})
+SET(SWIG_MODULE_MEDCouplingRemapper_EXTRA_FLAGS "${NUMPY_DEFINITIONS};${SCIPY_DEFINITIONS}")
 
 # _ABR_ Ensure dependency mechanism on all SWIG files and headers
 SET (SWIG_MODULE_MEDCouplingRemapper_EXTRA_DEPS ${MEDCoupling_SWIG_DPYS_FILES}
index 84888e2af8b3cdcb9d9a0716e41715cbacc642c8..2ad33efb2d89498aa4d139de7e1b5b87bd4eee0f 100644 (file)
 FIND_PACKAGE(SWIG REQUIRED)
 INCLUDE(${SWIG_USE_FILE})
 
-ADD_DEFINITIONS(${PYTHON_DEFINITIONS})
+ADD_DEFINITIONS(${PYTHON_DEFINITIONS} ${NUMPY_DEFINITIONS} ${SCIPY_DEFINITIONS})
 
 SET_SOURCE_FILES_PROPERTIES(MEDLoader.i PROPERTIES CPLUSPLUS ON)
 SET_SOURCE_FILES_PROPERTIES(MEDLoader.i PROPERTIES SWIG_DEFINITIONS "-shadow")
-SET(SWIG_MODULE_MEDLoader_EXTRA_FLAGS ${SWIG_EXTRA_FLAGS_FOR_NUMPYANDSCIPY})
+SET(SWIG_MODULE_MEDLoader_EXTRA_FLAGS "${NUMPY_DEFINITIONS};${SCIPY_DEFINITIONS}")
 
 SET (MEDLoader_SWIG_DPYS_FILES
     MEDLoaderCommon.i
@@ -33,6 +33,7 @@ SET (MEDLoader_SWIG_DPYS_FILES
 
 INCLUDE_DIRECTORIES(
   ${PYTHON_INCLUDE_DIRS}
+  ${NUMPY_INCLUDE_DIR}
   ${MEDFILE_INCLUDE_DIRS}
   ${HDF5_INCLUDE_DIRS}
   ${CMAKE_CURRENT_SOURCE_DIR}
index 78ab03066a738d1518f8f2d900d2f5863d6219d8..60dce229a7476253ff5b50d5faf01818d0eb61be 100644 (file)
 
 INCLUDE(${SWIG_USE_FILE})
 
-ADD_DEFINITIONS(${PYTHON_DEFINITIONS} ${HDF5_DEFINITIONS} ${MEDFILE_DEFINITIONS} )
+ADD_DEFINITIONS(${PYTHON_DEFINITIONS} ${HDF5_DEFINITIONS} ${MEDFILE_DEFINITIONS} ${NUMPY_DEFINITIONS} ${SCIPY_DEFINITIONS})
 
 SET_SOURCE_FILES_PROPERTIES(MEDPartitioner.i PROPERTIES CPLUSPLUS ON)
 SET_SOURCE_FILES_PROPERTIES(MEDPartitioner.i PROPERTIES SWIG_DEFINITIONS "-shadow")
-SET(SWIG_MODULE_MEDPartitioner_EXTRA_FLAGS "${SWIG_EXTRA_FLAGS_FOR_NUMPYANDSCIPY};-DWITHOUT_AUTOFIELD")
+SET(SWIG_MODULE_MEDPartitioner_EXTRA_FLAGS "${NUMPY_DEFINITIONS};${SCIPY_DEFINITIONS};-DWITHOUT_AUTOFIELD")
 
 SET (MEDPartitioner_SWIG_DPYS_FILES
     MEDPartitionerCommon.i)
@@ -31,6 +31,7 @@ SET (MEDPartitioner_SWIG_DPYS_FILES
 INCLUDE_DIRECTORIES(
   ${PYTHON_INCLUDE_DIRS}
   ${PTHREAD_INCLUDE_DIR} # pthread dependancy due to python2.7 library
+  ${NUMPY_INCLUDE_DIR}
   ${CMAKE_CURRENT_SOURCE_DIR}
   ${CMAKE_CURRENT_BINARY_DIR}
   ${HDF5_INCLUDE_DIRS}
index 3edfd4d8649cb5708a444bcd2b692eee87f619dd..fcef11f15222e9e239e1508942b6f2d3d875bb6e 100644 (file)
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
-ADD_DEFINITIONS(${PYTHON_DEFINITIONS})
+ADD_DEFINITIONS(${PYTHON_DEFINITIONS} ${NUMPY_DEFINITIONS} ${SCIPY_DEFINITIONS})
 
 FIND_PACKAGE(SWIG REQUIRED)
 INCLUDE(${SWIG_USE_FILE})
 
 SET_SOURCE_FILES_PROPERTIES(ParaMEDMEM.i PROPERTIES CPLUSPLUS ON)
 SET_SOURCE_FILES_PROPERTIES(ParaMEDMEM.i PROPERTIES SWIG_DEFINITIONS "-shadow")
-SET(SWIG_MODULE_ParaMEDMEM_EXTRA_FLAGS ${SWIG_EXTRA_FLAGS_FOR_NUMPYANDSCIPY})
+SET(SWIG_MODULE_ParaMEDMEM_EXTRA_FLAGS "${NUMPY_DEFINITIONS};${SCIPY_DEFINITIONS}")
 
 SET (ParaMEDMEM_SWIG_DPYS_FILES
     ParaMEDMEM.typemap)
 
 INCLUDE_DIRECTORIES(
   ${PYTHON_INCLUDE_DIRS}
+  ${NUMPY_INCLUDE_DIR}
   ${MEDFILE_INCLUDE_DIRS}
   ${HDF5_INCLUDE_DIRS}
   ${MPI_INCLUDE_DIRS}
index 1640b5dd5c3a7054483d4300c9540fac1eb680cd..da3b86391d68096d355fda3ccf148d6d48c24e0b 100644 (file)
 
 INCLUDE(${SWIG_USE_FILE})
 
-ADD_DEFINITIONS(${PYTHON_DEFINITIONS})
+ADD_DEFINITIONS(${PYTHON_DEFINITIONS} ${NUMPY_DEFINITIONS} ${SCIPY_DEFINITIONS})
 
 SET_SOURCE_FILES_PROPERTIES(MEDRenumber.i PROPERTIES CPLUSPLUS ON)
 SET_SOURCE_FILES_PROPERTIES(MEDRenumber.i PROPERTIES SWIG_DEFINITIONS "-shadow")
-SET(SWIG_MODULE_MEDRenumber_EXTRA_FLAGS "${SWIG_EXTRA_FLAGS_FOR_NUMPYANDSCIPY};-DWITHOUT_AUTOFIELD")
+SET(SWIG_MODULE_MEDRenumber_EXTRA_FLAGS "${NUMPY_DEFINITIONS};${SCIPY_DEFINITIONS};-DWITHOUT_AUTOFIELD")
 
 IF(Boost_FOUND)
   SET(SWIG_MODULE_MEDRenumber_EXTRA_FLAGS -DHAS_BOOST ${SWIG_MODULE_MEDRenumber_EXTRA_FLAGS})
@@ -40,6 +40,7 @@ INCLUDE_DIRECTORIES(
   ${PYTHON_INCLUDE_DIRS}
   ${PTHREAD_INCLUDE_DIR} # pthread dependancy due to python2.7 library
   ${CMAKE_CURRENT_SOURCE_DIR}
+  ${NUMPY_INCLUDE_DIR}
   ${CMAKE_CURRENT_BINARY_DIR}
   ${CMAKE_CURRENT_SOURCE_DIR}/../RENUMBER
   ${CMAKE_CURRENT_SOURCE_DIR}/../MEDCoupling_Swig