Salome HOME
Copyright update 2021
[tools/libbatch.git] / src / Python / CMakeLists.txt
index f6e682cf6a766b728deb154a2dac39d16434e913..bfc6ad214319ee4da84c4daff98b9928b0bf4e0f 100644 (file)
@@ -1,41 +1,67 @@
-#  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-2021  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)
 
-INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
+INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS})
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
 
 SET(SWIG_SRC_FILE libBatch_Swig.i)
-SET_SOURCE_FILES_PROPERTIES(${SWIG_SRC_FILE} PROPERTIES CPLUSPLUS ON
-                                                        SWIG_FLAGS "-shadow")
-SWIG_ADD_MODULE(libBatch_Swig python ${SWIG_SRC_FILE} Batch_PyVersatile.cxx)
-SWIG_LINK_LIBRARIES(libBatch_Swig Batch ${PYTHON_LIBRARIES})
 
-INSTALL(TARGETS ${SWIG_MODULE_libBatch_Swig_REAL_NAME} DESTINATION lib/python${PYTHON_VERSION}/site-packages)
-INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libBatch_Swig.py
-        DESTINATION lib/python${PYTHON_VERSION}/site-packages)
-INSTALL(FILES Batch_PyVersatile.hxx DESTINATION include/Batch)
+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
+    ../Core/JobId.hxx
+    ../Core/JobInfo.hxx
+    ../Core/CommunicationProtocol.hxx
+    ../Core/BatchManager.hxx
+    ../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_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES libBatch_Swig.py)
+  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})
 
-add_subdirectory(Test)
+IF (LIBBATCH_BUILD_TESTS)
+  ADD_SUBDIRECTORY(Test)
+ENDIF ()