Salome HOME
SALOME 9.1.0 Windows version
[tools/libbatch.git] / src / Python / CMakeLists.txt
index 0fa38531e6c98e2fa0061e85188d4df771ff4900..81aecffa79cfbd1302fc449b3cb9c07e53d62066 100644 (file)
@@ -1,23 +1,23 @@
-#  Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-2015  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
+# 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 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.
+# 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
+# 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
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
 INCLUDE(UseSWIG)
@@ -26,9 +26,12 @@ INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS})
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
 
 SET(SWIG_SRC_FILE libBatch_Swig.i)
-SET(SWIG_LB_DPYS
+
+SET(SWIG_EXTAR_DEPS 
     libBatch_Swig_exception.i
     libBatch_Swig_typemap.i 
+    )
+SET(SWIG_LB_DPYS
     ../Core/Defines.hxx
     ../Core/Constants.hxx
     ../Core/Job.hxx
@@ -39,17 +42,22 @@ SET(SWIG_LB_DPYS
     ../Core/BatchManagerCatalog.hxx
     ../Core/FactBatchManager.hxx
     )
+IF(${CMAKE_VERSION} VERSION_LESS "3.8.0") 
+  SET_SOURCE_FILES_PROPERTIES(${SWIG_SRC_FILE} PROPERTIES CPLUSPLUS ON
+                                                        SWIG_FLAGS "-py3")
+  # 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_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})
+  SET(SWIG_MODULE_libbatch_EXTRA_DEPS ${SWIG_EXTAR_DEPS} ${SWIG_LB_DPYS})
+  SWIG_ADD_MODULE(libbatch python ${SWIG_SRC_FILE})
+ELSE()
+  SET(CMAKE_SWIG_FLAGS "-py3")
+  SET_PROPERTY(SOURCE ${SWIG_SRC_FILE} PROPERTY CPLUSPLUS ON)
+  SET(SWIG_MODULE_libbatch_EXTRA_DEPS ${SWIG_EXTAR_DEPS})
+  SWIG_ADD_LIBRARY(libbatch LANGUAGE python SOURCES ${SWIG_LB_DPYS} ${SWIG_SRC_FILE})
+ENDIF()
 SWIG_LINK_LIBRARIES(libbatch batch ${PYTHON_LIBRARIES})
-
 INSTALL(TARGETS ${SWIG_MODULE_libbatch_REAL_NAME} DESTINATION ${LIBBATCH_PYTHONPATH})
 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libbatch.py
         DESTINATION ${LIBBATCH_PYTHONPATH})