Salome HOME
Copyright update 2020
[tools/libbatch.git] / src / CMakeLists.txt
index fae507a5c59d3d88ade01332f9ac1b57c01717c5..aaf88ebf3c8774531550e816faa0beeff5575658 100644 (file)
@@ -1,90 +1,84 @@
-#  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-2020  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
 #
 
-# 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 (WIN32)
+  ADD_DEFINITIONS(/wd4251 /wd4290)  # Disable annoying Visual C++ warnings
+ENDIF (WIN32)
 
+INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR} 
+     ${PTHREAD_INCLUDE_DIR})
 
-add_subdirectory (Core)
-
-IF (BUILD_LOCAL_SUBMISSION)
-    add_subdirectory (Local)
-ENDIF (BUILD_LOCAL_SUBMISSION)
-
-add_subdirectory (LSF)
-add_subdirectory (PBS)
-add_subdirectory (SGE)
-
-# 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 "")
+ADD_SUBDIRECTORY (Core)
 
-SET(HDR_FILES ${HDR_FILES_BUILD} CACHE INTERNAL "")
-SET(HDR_FILES_BUILD CACHE INTERNAL "")
+IF (LIBBATCH_LOCAL_SUBMISSION)
+    ADD_SUBDIRECTORY (Local)
+ENDIF ()
 
+ADD_SUBDIRECTORY (CCC)
+ADD_SUBDIRECTORY (LSF)
+ADD_SUBDIRECTORY (PBS)
+ADD_SUBDIRECTORY (OAR)
+ADD_SUBDIRECTORY (COORM)
+ADD_SUBDIRECTORY (SGE)
+ADD_SUBDIRECTORY (LoadLeveler)
+ADD_SUBDIRECTORY (Slurm)
 
-add_library (Batch SHARED ${SRC_FILES})
+# Vishnu is not available for Windows
+IF (NOT WIN32)
+    ADD_SUBDIRECTORY (Vishnu)
+ENDIF (NOT WIN32)
 
-include_directories(${CMAKE_BINARY_DIR})
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Core)
+ADD_LIBRARY (batch SHARED ${SRC_FILES})
 
-target_link_libraries(Batch ${CMAKE_THREAD_LIBS_INIT})
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/Core)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/Local)
+TARGET_LINK_LIBRARIES(batch ${PTHREAD_LIBRARY})
 
 IF (WIN32)
-    target_link_libraries(Batch ws2_32)
+    TARGET_LINK_LIBRARIES(batch ws2_32)
 ENDIF (WIN32)
 
 # If necessary, activate all warnings (useful for debugging and code cleaning)
 # add_definitions(-Wall -Werror -ansi -pedantic)
 
-IF (BUILD_LSF_INTERFACE AND LSF_FOUND)
-    include_directories(${LSF_INCLUDE_DIR})
-    target_link_libraries(Batch ${LSF_LIBRARY} ${LSF_BAT_LIBRARY})
-ENDIF (BUILD_LSF_INTERFACE AND LSF_FOUND)
-
-IF (BUILD_PBS_INTERFACE AND PBS_FOUND)
-    include_directories(${PBS_INCLUDE_DIR})
-    target_link_libraries(Batch ${PBS_LIBRARY})
-ENDIF (BUILD_PBS_INTERFACE AND PBS_FOUND)
-
-INSTALL(TARGETS Batch DESTINATION lib)
-INSTALL(FILES ${HDR_FILES} DESTINATION include/Batch)
+INSTALL(TARGETS batch 
+        EXPORT LibBatchTargets 
+        DESTINATION lib)
+INSTALL(FILES ${HDR_FILES} DESTINATION include/libbatch)
 
-IF (BUILD_PYTHON_WRAPPING AND Python_FOUND AND SWIG_FOUND)
-    add_subdirectory (Python)
-ENDIF (BUILD_PYTHON_WRAPPING AND Python_FOUND AND SWIG_FOUND)
+IF (LIBBATCH_PYTHON_WRAPPING AND PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND AND SWIG_FOUND)
+    ADD_SUBDIRECTORY(Python)
+ENDIF ()