Salome HOME
CMake: simplifying Python detection mechanism.
[modules/gui.git] / CMakeLists.txt
index fc3dfc23dc3d609ffd6bfb27c0ea97f7bba8303f..317a1b3ce009524bca93f4a1807d3c0210c2aa30 100755 (executable)
@@ -1,9 +1,9 @@
-# Copyright (C) 2012-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2012-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.
+# 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
@@ -17,6 +17,8 @@
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR)
+INCLUDE(CMakeDependentOption)
+
 PROJECT(SalomeGUI C CXX)
 
 # Ensure a proper linker behavior:
@@ -28,11 +30,11 @@ CMAKE_POLICY(SET CMP0003 NEW)
 STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
 
 SET(${PROJECT_NAME_UC}_MAJOR_VERSION 7)
-SET(${PROJECT_NAME_UC}_MINOR_VERSION 3)
+SET(${PROJECT_NAME_UC}_MINOR_VERSION 7)
 SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
 SET(${PROJECT_NAME_UC}_VERSION
   ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
-SET(${PROJECT_NAME_UC}_VERSION_DEV 0)
+SET(${PROJECT_NAME_UC}_VERSION_DEV 1)
 
 # Find KERNEL
 # ===========
@@ -62,18 +64,25 @@ OPTION(SALOME_BUILD_TESTS "Build SALOME tests" ON)
 OPTION(SALOME_GUI_USE_OBSERVERS "Use study observers in GUI (advanced)" ON)
 
 # Advanced options:
+CMAKE_DEPENDENT_OPTION(SALOME_LIGHT_ONLY "Build SALOME Light only (no CORBA)" OFF
+                       "NOT SALOME_KERNEL_LIGHT_ONLY" ON)
 OPTION(SALOME_USE_VTKVIEWER "Enable VTK visualization (Mandatory in classic configurations)" ON)
-OPTION(SALOME_USE_SALOMEOBJECT "Enable Salome Object (Mandatory in classic configurations)" ON)
 OPTION(SALOME_USE_OCCVIEWER "Enable OCC visualization (Mandatory in classic configurations)" ON)
 OPTION(SALOME_USE_GLVIEWER "Enable OpenGL visualization (Mandatory in classic configurations)" ON)
 OPTION(SALOME_USE_GRAPHICSVIEW "Enable GraphicsView visualization (Mandatory in classic configurations)" ON)
+OPTION(SALOME_USE_PYVIEWER "Enable Python viewer (Mandatory in classic configurations)" ON)
 OPTION(SALOME_USE_PLOT2DVIEWER "Enable Plot2D visualization (Mandatory in classic configurations)" ON)
 OPTION(SALOME_USE_PYCONSOLE "Enable Python GUI interface (Mandatory in classic configurations)" ON)
 OPTION(SALOME_USE_QXGRAPHVIEWER "Enable QX graph visualization (Mandatory in classic configurations)" ON)
+OPTION(SALOME_USE_PVVIEWER "Enable ParaView visualization (Mandatory in classic configurations)" ON)
+CMAKE_DEPENDENT_OPTION(SALOME_USE_SALOMEOBJECT "Enable Salome Object (Mandatory in classic configurations)" ON
+                       "SALOME_LIGHT_ONLY" ON)
+OPTION(SALOME_USE_SINGLE_DESKTOP "Enable multiple document interface" ON)
 
-MARK_AS_ADVANCED(SALOME_USE_VTKVIEWER SALOME_USE_VTKVIEWER SALOME_USE_GRAPHICSVIEW)
+MARK_AS_ADVANCED(SALOME_LIGHT_ONLY SALOME_USE_VTKVIEWER SALOME_USE_GRAPHICSVIEW SALOME_USE_PVVIEWER)
 MARK_AS_ADVANCED(SALOME_USE_SALOMEOBJECT SALOME_USE_OCCVIEWER SALOME_USE_GLVIEWER SALOME_USE_PLOT2DVIEWER)
-MARK_AS_ADVANCED(SALOME_USE_PYCONSOLE SALOME_USE_QXGRAPHVIEWER)
+MARK_AS_ADVANCED(SALOME_USE_PYCONSOLE SALOME_USE_QXGRAPHVIEWER SALOME_USE_PYVIEWER)
+MARK_AS_ADVANCED(SALOME_USE_SINGLE_DESKTOP)
 
 # Prerequisites
 # =============
@@ -86,7 +95,8 @@ MARK_AS_ADVANCED(SALOME_USE_PYCONSOLE SALOME_USE_QXGRAPHVIEWER)
 ##
 
 # Various
-FIND_PACKAGE(SalomePython REQUIRED)
+FIND_PACKAGE(SalomePythonInterp REQUIRED)
+FIND_PACKAGE(SalomePythonLibs REQUIRED)
 FIND_PACKAGE(SalomePThread REQUIRED)
 FIND_PACKAGE(SalomeSWIG REQUIRED)
 FIND_PACKAGE(SalomeBoost REQUIRED)
@@ -96,6 +106,8 @@ FIND_PACKAGE(SalomeHDF5 REQUIRED COMPONENTS C)
 IF(NOT SALOME_LIGHT_ONLY)
   FIND_PACKAGE(SalomeOmniORB REQUIRED)
   FIND_PACKAGE(SalomeOmniORBPy REQUIRED)
+ELSE()
+  ADD_DEFINITIONS("-DGUI_DISABLE_CORBA")
 ENDIF() 
 IF(SALOME_BUILD_TESTS)
   ENABLE_TESTING()
@@ -122,28 +134,69 @@ IF(SALOME_GUI_USE_OBSERVERS)
   ADD_DEFINITIONS(-DWITH_SALOMEDS_OBSERVER)
 ENDIF()
 
+# Single-study GUI
+IF(SALOME_USE_SINGLE_DESKTOP)
+  ADD_DEFINITIONS(-DSINGLE_DESKTOP)
+ENDIF()
+
 # OCCT
 FIND_PACKAGE(SalomeCAS REQUIRED)
 
+# OpenGL
+IF(SALOME_USE_OCCVIEWER OR SALOME_USE_VTKVIEWER OR SALOME_USE_GLVIEWER)
+  FIND_PACKAGE(SalomeOpenGL REQUIRED)
+ENDIF()
+
 # Qt4
-FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui QtXml QtWebKit QtOpenGL)
+FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui QtXml QtWebKit QtOpenGL QtNetwork)
 INCLUDE(${QT_USE_FILE})
 
+# PyQt4
 FIND_PACKAGE(SalomePyQt4 REQUIRED)
 
 # Optional prerequisites for GUI
-IF(SALOME_USE_GLVIEWER)
-  FIND_PACKAGE(SalomeOpenGL)
-  SALOME_LOG_OPTIONAL_PACKAGE(OpenGL SALOME_USE_GLVIEWER) 
+IF(NOT SALOME_USE_GLVIEWER)
+  ADD_DEFINITIONS("-DDISABLE_GLVIEWER")
+ENDIF()
+IF(NOT SALOME_USE_OCCVIEWER)
+  ADD_DEFINITIONS("-DDISABLE_OCCVIEWER")
 ENDIF()
 IF(SALOME_USE_VTKVIEWER)
   # Required components are listed in the FindSalomeVTK.cmake file: 
-  FIND_PACKAGE(SalomeVTK 6.1
+  FIND_PACKAGE(SalomeVTK) 
   SALOME_LOG_OPTIONAL_PACKAGE(VTK SALOME_USE_VTKVIEWER)
+ELSE()
+  ADD_DEFINITIONS("-DDISABLE_VTKVIEWER")
 ENDIF()
 IF(SALOME_USE_PLOT2DVIEWER)
   FIND_PACKAGE(SalomeQwt)  
   SALOME_LOG_OPTIONAL_PACKAGE(Qwt SALOME_USE_PLOT2DVIEWER)
+ELSE()
+  ADD_DEFINITIONS("-DDISABLE_PLOT2DVIEWER")
+ENDIF()
+IF (SALOME_USE_PVVIEWER)
+  FIND_PACKAGE(SalomeParaView)
+  SALOME_LOG_OPTIONAL_PACKAGE(ParaView SALOME_USE_PVVIEWER)
+ELSE()
+  ADD_DEFINITIONS("-DDISABLE_PVVIEWER")
+ENDIF()
+IF (NOT SALOME_USE_GRAPHICSVIEW)
+  ADD_DEFINITIONS("-DDISABLE_GRAPHICSVIEW")
+ENDIF()
+IF (NOT SALOME_USE_PYVIEWER)
+  ADD_DEFINITIONS("-DDISABLE_PYVIEWER")
+ENDIF()
+IF(SALOME_USE_PYCONSOLE)
+  # Build with obsolete Python module's methods
+  ADD_DEFINITIONS(-DCALL_OLD_METHODS)
+ELSE()
+  ADD_DEFINITIONS("-DDISABLE_PYCONSOLE")
+ENDIF()
+IF(NOT SALOME_USE_QXGRAPHVIEWER)
+  ADD_DEFINITIONS("-DDISABLE_QXGRAPHVIEWER")
+ENDIF()
+IF(NOT SALOME_USE_SALOMEOBJECT)
+  ADD_DEFINITIONS("-DDISABLE_SALOMEOBJECT")
 ENDIF()
 
 # Detection summary:
@@ -226,11 +279,16 @@ INCLUDE(CMakePackageConfigHelpers)
 # List of targets in this project we want to make visible to the rest of the world.
 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
 SET(_${PROJECT_NAME}_exposed_targets 
-    caf CAM CASCatch DDS Event LightApp LogWindow ObjBrowser OpenGLUtils
-    QDS qtx SalomeIDLGUI SalomePrs SalomeStyle std SUITApp suit ViewerTools ViewerData
-    vtkTools vtkEDFOverloads ImageComposer
+    caf CAM CASCatch DDS Event LightApp LogWindow ObjBrowser
+    QDS qtx SalomePrs SalomeStyle std SUITApp suit ViewerTools ViewerData
+    ImageComposer
 )
 
+IF(SALOME_USE_OCCVIEWER OR SALOME_USE_VTKVIEWER OR SALOME_USE_GLVIEWER)
+  LIST(APPEND _${PROJECT_NAME}_exposed_targets 
+       OpenGLUtils)
+ENDIF(SALOME_USE_OCCVIEWER OR SALOME_USE_VTKVIEWER OR SALOME_USE_GLVIEWER)
+
 # SALOME object specific targets:
 IF(SALOME_USE_SALOMEOBJECT)
   LIST(APPEND _${PROJECT_NAME}_exposed_targets 
@@ -246,7 +304,7 @@ ENDIF(SALOME_USE_GLVIEWER)
 # VTK specific targets:
 IF(SALOME_USE_VTKVIEWER)
   LIST(APPEND _${PROJECT_NAME}_exposed_targets 
-       VTKViewer)
+       VTKViewer vtkTools vtkEDFOverloads)
   IF(SALOME_USE_SALOMEOBJECT)
     LIST(APPEND _${PROJECT_NAME}_exposed_targets 
          SVTK)
@@ -285,16 +343,37 @@ IF(SALOME_USE_GRAPHICSVIEW)
        GraphicsView)
 ENDIF(SALOME_USE_GRAPHICSVIEW)
 
+# PyEditor/Viewer specific targets:
+IF(SALOME_USE_PYVIEWER)
+  LIST(APPEND _${PROJECT_NAME}_exposed_targets 
+       PyEditor PyViewer)
+ENDIF(SALOME_USE_PYVIEWER)
+
+# ParaView viewer specific targets:
+IF(SALOME_USE_PVVIEWER)
+  LIST(APPEND _${PROJECT_NAME}_exposed_targets PVViewer PVServerService)
+ENDIF()
+
+
 # Python-based packages specific targets:
 IF(SALOME_USE_PYCONSOLE)
   LIST(APPEND _${PROJECT_NAME}_exposed_targets 
-       PyInterp PyConsole SalomePy SalomePyQtGUI SalomePyQtGUILight SalomePyQt)
+       PyInterp PyConsole  SalomePyQtGUILight)
+  IF(SALOME_USE_PLOT2DVIEWER)
+    LIST(APPEND _${PROJECT_NAME}_exposed_targets SalomePyQt)
+  ENDIF()
+  IF(NOT SALOME_LIGHT_ONLY)
+    LIST(APPEND _${PROJECT_NAME}_exposed_targets SalomePyQtGUI)
+  ENDIF()
+  IF(SALOME_USE_VTKVIEWER)
+    LIST(APPEND _${PROJECT_NAME}_exposed_targets SalomePy)
+  ENDIF(SALOME_USE_VTKVIEWER)
 ENDIF(SALOME_USE_PYCONSOLE)
 
 # CORBA specific targets:
 IF(NOT SALOME_LIGHT_ONLY)
   LIST(APPEND _${PROJECT_NAME}_exposed_targets
-       SalomeSession SalomeApp SalomeGuiHelpers SalomeTreeData ToolsGUI)
+       SalomeIDLGUI SalomeSession SalomeApp SalomeGuiHelpers SalomeTreeData ToolsGUI)
 ENDIF(NOT SALOME_LIGHT_ONLY)
 
 # Add all targets to the build-tree export set