+IF( EXISTS ${KERNEL_ROOT_DIR} )
+ FIND_PACKAGE(SalomeKERNEL REQUIRED)
+ KERNEL_WITH_CORBA() #check whether KERNEL built with CORBA
+ ADD_DEFINITIONS(${KERNEL_DEFINITIONS})
+ INCLUDE_DIRECTORIES(${KERNEL_INCLUDE_DIRS})
+ELSE( EXISTS ${KERNEL_ROOT_DIR} )
+ MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR or turn option SALOME_HYDRO_USE_KERNEL to OFF !")
+ENDIF( EXISTS ${KERNEL_ROOT_DIR} )
+
+# Platform setup
+# ==============
+INCLUDE(SalomeSetupPlatform) # From KERNEL
+# Always build libraries as shared objects:
+SET(BUILD_SHARED_LIBS TRUE)
+
+# User options
+# ============
+# (some options may have already been defined in KERNEL)
+OPTION(SALOME_BUILD_DOC "Generate HYDRO documentation" ON)
+OPTION(SALOME_BUILD_TESTS "Build HYDRO tests" ON)
+
+# Prerequisites
+# =============
+# Find "big" prerequisites first - they reference themselves many others
+# -> this can helps to find the smaller prerequisites and detect conflicts.
+# In our case KERNEL may have already loaded many prerequisites which are also used in HYDRO:
+
+##
+## From KERNEL:
+##
+
+# Mandatory products:
+
+FIND_PACKAGE(SalomePythonInterp REQUIRED)
+FIND_PACKAGE(SalomePythonLibs REQUIRED)
+FIND_PACKAGE(SalomeOmniORB REQUIRED)
+
+# Optional products:
+
+IF(SALOME_BUILD_TESTS)
+ ENABLE_TESTING()
+ FIND_PACKAGE(SalomeCppUnit)
+ SALOME_LOG_OPTIONAL_PACKAGE(CppUnit SALOME_BUILD_TESTS)
+ENDIF()
+
+IF(SALOME_BUILD_DOC)
+ IF(SALOME_USE_MPI)
+ FIND_PACKAGE(SalomeMPI) # needed for doc generation by Sphinx
+ SALOME_LOG_OPTIONAL_PACKAGE(MPI SALOME_BUILD_DOC)
+ ENDIF()
+ FIND_PACKAGE(SalomeDoxygen)
+ FIND_PACKAGE(SalomeSphinx)
+ SALOME_LOG_OPTIONAL_PACKAGE(Doxygen SALOME_BUILD_DOC)
+ SALOME_LOG_OPTIONAL_PACKAGE(Sphinx SALOME_BUILD_DOC)
+ENDIF()
+
+# Find SALOME GUI (optional)
+# ==============
+SET(GDAL_ROOT_DIR $ENV{GDALHOME}) # When looking for Salome GUI, reloading targets from Paraview
+IF(EXISTS ${GDAL_ROOT_DIR})
+ SET(GDAL_LIBRARY ${GDAL_ROOT_DIR}/lib)
+ SET(GDAL_INCLUDE_DIR ${GDAL_ROOT_DIR}/include)
+ENDIF(EXISTS ${GDAL_ROOT_DIR})
+
+OPTION(SALOME_BUILD_GUI "Build GUI of HYDRO" ON)
+IF(SALOME_BUILD_GUI)
+ SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI")
+ IF(EXISTS ${GUI_ROOT_DIR})
+ FIND_PACKAGE(SalomeGUI)
+ SALOME_GUI_WITH_CORBA() #check whether GUI built with CORBA
+ SALOME_GUI_MODE(SALOME_USE_VTKVIEWER SALOME_USE_SALOMEOBJECT
+ OPTIONAL SALOME_USE_PLOT2DVIEWER SALOME_USE_PYCONSOLE)
+ ##
+ ## Prerequisites From GUI:
+ ##
+ # Qt
+ FIND_PACKAGE(SalomeQt5 REQUIRED)
+ # SIP
+ FIND_PACKAGE(SalomeSIP REQUIRED) # should come after Python and before PyQt5
+ # PyQt
+ FIND_PACKAGE(SalomePyQt5 REQUIRED)
+ # Qwt
+ FIND_PACKAGE(SalomeQwt REQUIRED)
+ ELSE(EXISTS ${GUI_ROOT_DIR})
+ MESSAGE(FATAL_ERROR "We absolutely need a Salome GUI, please define GUI_ROOT_DIR or turn option SALOME_BUILD_GUI to OFF !")
+ ENDIF(EXISTS ${GUI_ROOT_DIR})
+ SALOME_LOG_OPTIONAL_PACKAGE(SalomeGUI SALOME_BUILD_GUI)
+ENDIF(SALOME_BUILD_GUI)
+
+# Find GEOM
+# ===========
+SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR} CACHE PATH "Path to the Salome GEOM")
+IF(EXISTS ${GEOM_ROOT_DIR})
+ FIND_PACKAGE(SalomeGEOM REQUIRED)
+ ADD_DEFINITIONS(${GEOM_DEFINITIONS})
+ INCLUDE_DIRECTORIES(${GEOM_INCLUDE_DIRS})
+ IF(SALOME_BUILD_GUI)
+ IF(NOT SALOME_GEOM_BUILD_GUI)
+ MESSAGE(FATAL_ERROR "We absolutely need a Salome GEOM with GUI, please set SALOME_BUILD_GUI=ON in GEOM module")
+ ENDIF(NOT SALOME_GEOM_BUILD_GUI)
+ ENDIF(SALOME_BUILD_GUI)
+ELSE(EXISTS ${GEOM_ROOT_DIR})
+ MESSAGE(FATAL_ERROR "We absolutely need a Salome GEOM, please define GEOM_ROOT_DIR")
+ENDIF(EXISTS ${GEOM_ROOT_DIR})
+
+
+##
+## From GUI:
+##
+
+FIND_PACKAGE(SalomeOpenCASCADE REQUIRED)
+FIND_PACKAGE(SalomeVTK REQUIRED)
+FIND_PACKAGE(SalomeSIP REQUIRED) # should come after Python and before PyQt4
+
+SET(QT_ROOT_DIR "${QT5_ROOT_DIR}")
+SET(PYQT_ROOT_DIR "${PYQT5_ROOT_DIR}")
+SALOME_CONFIGURE_PREPARE(HYDROData HYDROGUI HYDROPy Qt5 PyQt5)
+
+# Detection summary:
+SALOME_PACKAGE_REPORT_AND_CHECK()
+
+# Directories
+# ===========
+SET(SALOME_INSTALL_BINS "${SALOME_INSTALL_BINS}" CACHE PATH "Install path: SALOME binaries")
+SET(SALOME_INSTALL_LIBS "${SALOME_INSTALL_LIBS}" CACHE PATH "Install path: SALOME libs")
+SET(SALOME_INSTALL_IDLS "${SALOME_INSTALL_IDLS}" CACHE PATH "Install path: SALOME IDL files")
+SET(SALOME_INSTALL_HEADERS "${SALOME_INSTALL_HEADERS}" CACHE PATH "Install path: SALOME headers")
+SET(SALOME_INSTALL_SCRIPT_SCRIPTS "${SALOME_INSTALL_SCRIPT_SCRIPTS}" CACHE PATH
+ "Install path: SALOME scripts")
+SET(SALOME_INSTALL_SCRIPT_DATA "${SALOME_INSTALL_SCRIPT_DATA}" CACHE PATH
+ "Install path: SALOME script data")
+SET(SALOME_INSTALL_SCRIPT_PYTHON "${SALOME_INSTALL_SCRIPT_PYTHON}" CACHE PATH
+ "Install path: SALOME Python scripts")
+SET(SALOME_INSTALL_PYTHON "${SALOME_INSTALL_PYTHON}" CACHE PATH "Install path: SALOME Python stuff")
+SET(SALOME_INSTALL_PYTHON_SHARED "${SALOME_INSTALL_PYTHON_SHARED}" CACHE PATH
+ "Install path: SALOME Python shared modules")
+SET(SALOME_INSTALL_CMAKE_LOCAL adm/cmake CACHE PATH
+ "Install path: local SALOME CMake files")
+SET(SALOME_INSTALL_AMCONFIG_LOCAL adm/unix CACHE PATH
+ "Install path: local SALOME config files (obsolete, to be removed)")
+
+SET(SALOME_INSTALL_RES "${SALOME_INSTALL_RES}" CACHE PATH "Install path: SALOME resources")
+SET(SALOME_INSTALL_DOC "${SALOME_INSTALL_DOC}" CACHE PATH "Install path: SALOME documentation")
+
+# Specific to HYDRO:
+SET(SALOME_HYDRO_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/hydro" CACHE PATH
+ "Install path: SALOME HYDRO specific data")
+SET(SALOME_HYDRO_INSTALL_RES_SCRIPTS "${SALOME_INSTALL_RES}/hydro" CACHE PATH
+ "Install path: SALOME HYDRO scripts")
+SET(SALOME_HYDRO_INSTALL_SAMPLES share/salome/hydrosamples CACHE PATH
+ "Install path: SALOME HYDRO samples")
+SET(SALOME_HYDRO_INSTALL_PLUGINS share/salome/plugins/hydro CACHE PATH
+ "Install path: SALOME HYDRO plugins")
+
+MARK_AS_ADVANCED(
+ SALOME_HYDRO_INSTALL_RES_DATA
+ SALOME_HYDRO_INSTALL_RES_SCRIPTS
+ SALOME_HYDRO_INSTALL_SAMPLES
+ SALOME_HYDRO_INSTALL_PLUGINS
+ )
+
+# Sources
+# ========
+ADD_SUBDIRECTORY (src/shapelib)
+ADD_SUBDIRECTORY (src/HYDROData)
+ADD_SUBDIRECTORY (src/HYDROGUI)
+ADD_SUBDIRECTORY (src/HYDROPy)
+ADD_SUBDIRECTORY (src/HYDROTools)
+ADD_SUBDIRECTORY (src/HYDRO_tests)
+IF(SALOME_BUILD_DOC)
+ ADD_SUBDIRECTORY(doc)
+ENDIF()
+
+# Header configuration
+# ====================
+SALOME_XVERSION(${PROJECT_NAME})
+SALOME_CONFIGURE_FILE(HYDRO_version.h.in HYDRO_version.h INSTALL ${SALOME_INSTALL_HEADERS})
+
+# Configuration export
+# (here only the level 1 prerequisites are exposed)
+# ====================
+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
+ shapelib HYDROData HYDROPy
+)
+
+IF(SALOME_BUILD_TESTS)
+ #LIST(APPEND _${PROJECT_NAME}_exposed_targets <insert_test_targets_here>)
+ENDIF(SALOME_BUILD_TESTS)
+
+IF(SALOME_BUILD_GUI)
+ LIST(APPEND _${PROJECT_NAME}_exposed_targets
+ HYDROGUI
+ )
+ENDIF(SALOME_BUILD_GUI)
+
+# Add all targets to the build-tree export set
+EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
+ FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
+
+# Create the configuration files:
+# - in the build tree:
+
+# Ensure the variables are always defined for the configure:
+SET(KERNEL_ROOT_DIR "${KERNEL_ROOT_DIR}")
+SET(GUI_ROOT_DIR "${GUI_ROOT_DIR}")
+SET(SIP_ROOT_DIR "${SIP_ROOT_DIR}")
+SET(QTDIR "${QTDIR}")
+SET(PYQT_ROOT_DIR "${PYQT_ROOT_DIR}")
+SET(CAS_ROOT_DIR "${CAS_ROOT_DIR}")
+
+SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
+CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in
+ ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
+ INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
+ PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX
+ KERNEL_ROOT_DIR GUI_ROOT_DIR SIP_ROOT_DIR QTDIR PYQT_ROOT_DIR CAS_ROOT_DIR)
+
+# - in the install tree (VSR 16/08/2013: TEMPORARILY COMMENT THIS - TO REMOVE?):
+# Get the relative path of the include directory so
+# we can register it in the generated configuration files:
+#SET(CONF_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR}")
+#CONFIGURE_PACKAGE_CONFIG_FILE(adm_local/cmake_files/${PROJECT_NAME}Config.cmake.in
+# ${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake
+# INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
+# PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX
+# KERNEL_ROOT_DIR GUI_ROOT_DIR SIP_ROOT_DIR QT4_ROOT_DIR PYQT4_ROOT_DIR EXPAT_ROOT_DIR QSCINTILLA_ROOT_DIR)
+
+WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
+ VERSION ${${PROJECT_NAME_UC}_VERSION}
+ COMPATIBILITY AnyNewerVersion)
+
+# Install the CMake configuration files:
+INSTALL(FILES
+ "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
+ "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
+ DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}")
+
+# Install the export set for use with the install-tree
+INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
+ FILE ${PROJECT_NAME}Targets.cmake)
+
+
+
+SET(_bin_scripts bin/hydro_setenv.py)
+SALOME_INSTALL_SCRIPTS("${_bin_scripts}" ${SALOME_INSTALL_SCRIPT_SCRIPTS})
+