From c62fea5bbd91ef175229fcd8c7f10ef58eb31265 Mon Sep 17 00:00:00 2001 From: bruneton Date: Wed, 3 Jul 2013 10:26:42 +0000 Subject: [PATCH] CMake: Adding FindSalomeGUI.cmake. Ensuring level 1 prerequisites are automatically loaded when finding GUI. This avoids having to set the LD_LIBRARY_PATH to link. --- CMakeLists.txt | 14 +++- adm_local/cmake_files/CMakeLists.txt | 2 + adm_local/cmake_files/FindGUI.cmake | 4 + adm_local/cmake_files/FindPyQt4.cmake | 2 +- adm_local/cmake_files/FindSalomeGUI.cmake | 39 +++++++++ .../cmake_files/SalomeGUIConfig.cmake.in | 82 ++++++++++++++----- bin/CMakeLists.txt | 2 - src/GUI_PY/CMakeLists.txt | 2 - src/SALOME_SWIG/CMakeLists.txt | 2 - src/SalomeApp/CMakeLists.txt | 1 - src/SalomeApp/pluginsdemo/CMakeLists.txt | 2 - 11 files changed, 119 insertions(+), 33 deletions(-) create mode 100644 adm_local/cmake_files/FindSalomeGUI.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index d52d44683..dc965b43d 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -245,14 +245,21 @@ EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets} # - in the build tree: # Ensure the variables are always defined for the configure: -SET(CPPUNIT_ROOT_DIR "${CPPUNIT_ROOT_DIR}") +SET(SIP_ROOT_DIR "${SIP_ROOT_DIR}") +SET(QT4_ROOT_DIR "${QT4_ROOT_DIR}") +SET(PYQT4_ROOT_DIR "${PYQT4_ROOT_DIR}") +SET(CAS_ROOT_DIR "${CAS_ROOT_DIR}") +SET(OPENGL_ROOT_DIR "${OPENGL_ROOT_DIR}") +SET(VTK_ROOT_DIR "${VTK_ROOT_DIR}") +SET(QWT_ROOT_DIR "${QWT_ROOT_DIR}") SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include") CONFIGURE_PACKAGE_CONFIG_FILE(adm_local/cmake_files/${PROJECT_NAME}Config.cmake.in ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE}" PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE CMAKE_INSTALL_PREFIX - KERNEL_ROOT_DIR) + KERNEL_ROOT_DIR SIP_ROOT_DIR QT4_ROOT_DIR PYQT4_ROOT_DIR CAS_ROOT_DIR + OPENGL_ROOT_DIR VTK_ROOT_DIR QWT_ROOT_DIR) # - in the install tree: # Get the relative path of the include directory so @@ -262,7 +269,8 @@ CONFIGURE_PACKAGE_CONFIG_FILE(adm_local/cmake_files/${PROJECT_NAME}Config.cmake. ${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE}" PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE CMAKE_INSTALL_PREFIX - KERNEL_ROOT_DIR) + KERNEL_ROOT_DIR SIP_ROOT_DIR QT4_ROOT_DIR PYQT4_ROOT_DIR CAS_ROOT_DIR + OPENGL_ROOT_DIR VTK_ROOT_DIR QWT_ROOT_DIR) WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake VERSION ${${PROJECT_NAME_UC}_VERSION} diff --git a/adm_local/cmake_files/CMakeLists.txt b/adm_local/cmake_files/CMakeLists.txt index ff7aec4dc..5367da953 100755 --- a/adm_local/cmake_files/CMakeLists.txt +++ b/adm_local/cmake_files/CMakeLists.txt @@ -37,5 +37,7 @@ SET(DATA FindSalomeQwt.cmake FindSalomeSIP.cmake FindSalomeVTK.cmake + FindSalomeGUI.cmake + FindSalomeOpenGL.cmake ) INSTALL(FILES ${DATA} DESTINATION ${SALOME_INSTALL_CMAKE_LOCAL}) diff --git a/adm_local/cmake_files/FindGUI.cmake b/adm_local/cmake_files/FindGUI.cmake index 4136dcd53..e7f3117a3 100644 --- a/adm_local/cmake_files/FindGUI.cmake +++ b/adm_local/cmake_files/FindGUI.cmake @@ -17,6 +17,10 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # +# +# TODO: this file should be removed when switching to full CMake +# + SET(GUI_CXXFLAGS -I${GUI_ROOT_DIR}/include/salome) FIND_LIBRARY(caf caf ${GUI_ROOT_DIR}/lib/salome) diff --git a/adm_local/cmake_files/FindPyQt4.cmake b/adm_local/cmake_files/FindPyQt4.cmake index ac8df0052..d025b58af 100644 --- a/adm_local/cmake_files/FindPyQt4.cmake +++ b/adm_local/cmake_files/FindPyQt4.cmake @@ -48,7 +48,7 @@ FIND_PROGRAM(PYQT_PYUIC_EXECUTABLE NAMES pyuic4 pyuic4.bat) GET_FILENAME_COMPONENT(_tmp_ROOT_DIR "${PYQT_PYUIC_EXECUTABLE}" PATH) GET_FILENAME_COMPONENT(_tmp_ROOT_DIR "${_tmp_ROOT_DIR}" PATH) -# Typical location of qobject.sip are: +# Typical locations of qobject.sip are: # - /usr/share/sip/PyQt4/QtCore, for a system install # - or /sip/QtCore, for a custom install # - or /share/sip/QtCore, for a custom install diff --git a/adm_local/cmake_files/FindSalomeGUI.cmake b/adm_local/cmake_files/FindSalomeGUI.cmake new file mode 100644 index 000000000..f397b0708 --- /dev/null +++ b/adm_local/cmake_files/FindSalomeGUI.cmake @@ -0,0 +1,39 @@ +# Copyright (C) 2007-2013 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. +# +# 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 +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# +# Author: Adrien Bruneton +# + +# GUI detection for Salome - this is typically called by dependent modules +# (PARAVIS, etc ...) +# +# The detection is simpler than for other prerequisites. +# See explanation in FindSalomeKERNEL.cmake. +# + +IF(NOT SalomeGUI_FIND_QUIETLY) + MESSAGE(STATUS "Looking for Salome GUI ...") +ENDIF() + +SET(CMAKE_PREFIX_PATH "${GUI_ROOT_DIR}") +SALOME_FIND_PACKAGE(SalomeGUI SalomeGUI CONFIG) + +IF(NOT SalomeGUI_FIND_QUIETLY) + MESSAGE(STATUS "Found Salome GUI: ${GUI_ROOT_DIR}") +ENDIF() \ No newline at end of file diff --git a/adm_local/cmake_files/SalomeGUIConfig.cmake.in b/adm_local/cmake_files/SalomeGUIConfig.cmake.in index 3592fdbde..a5a1bfb9f 100644 --- a/adm_local/cmake_files/SalomeGUIConfig.cmake.in +++ b/adm_local/cmake_files/SalomeGUIConfig.cmake.in @@ -34,7 +34,7 @@ # Load the dependencies for the libraries of @PROJECT_NAME@ # (contains definitions for IMPORTED targets). This is only # imported if we are not built as a subproject (in this case targets are already there) -IF(NOT Event AND NOT @PROJECT_NAME@_BINARY_DIR) +IF(NOT TARGET Event AND NOT @PROJECT_NAME@_BINARY_DIR) INCLUDE("@PACKAGE_SALOME_INSTALL_CMAKE@/@PROJECT_NAME@Targets.cmake") ENDIF() @@ -49,31 +49,73 @@ SET(SALOME_BUILD_DOC @SALOME_BUILD_DOC@) SET(SALOME_BUILD_TESTS @SALOME_BUILD_TESTS@) SET(SALOME_LIGHT_ONLY @SALOME_LIGHT_ONLY@) -# Prerequisites: +# Advanced options +SET(SALOME_USE_OCCVIEWER @SALOME_USE_OCCVIEWER@) +SET(SALOME_USE_GLVIEWER @SALOME_USE_GLVIEWER@) +SET(SALOME_USE_VTKVIEWER @SALOME_USE_VTKVIEWER@) +SET(SALOME_USE_PLOT2DVIEWER @SALOME_USE_PLOT2DVIEWER@) + +# Level 1 prerequisites: SET_AND_CHECK(KERNEL_ROOT_DIR_EXP "@PACKAGE_KERNEL_ROOT_DIR@") +SET_AND_CHECK(SIP_ROOT_DIR_EXP "@PACKAGE_SIP_ROOT_DIR@") +SET_AND_CHECK(QT4_ROOT_DIR_EXP "@PACKAGE_QT4_ROOT_DIR@") +SET_AND_CHECK(PYQT4_ROOT_DIR_EXP "@PACKAGE_PYQT4_ROOT_DIR@") + +# Optional level 1 prerequisites: +IF(SALOME_USE_OCCVIEWER) + SET_AND_CHECK(CAS_ROOT_DIR_EXP "@PACKAGE_CAS_ROOT_DIR@") +ENDIF() +IF(SALOME_USE_GLVIEWER) + SET_AND_CHECK(OPENGL_ROOT_DIR_EXP "@PACKAGE_OPENGL_ROOT_DIR@") +ENDIF() +IF(SALOME_USE_VTKVIEWER) + SET_AND_CHECK(VTK_ROOT_DIR_EXP "@PACKAGE_VTK_ROOT_DIR@") +ENDIF() +IF(SALOME_USE_PLOT2DVIEWER) + SET_AND_CHECK(QWT_ROOT_DIR_EXP "@PACKAGE_QWT_ROOT_DIR@") +ENDIF() -SET_AND_CHECK(SWIG_ROOT_DIR_EXP "@PACKAGE_SWIG_ROOT_DIR@") +# For all prerequisites, load the corresponding targets if the package was used +# in CONFIG mode. This ensures dependent projects link correctly +# without having to set LD_LIBRARY_PATH: +SET(_PREREQ CAS OpenGL PyQt4 Qt4 Qwt SIP VTK) +SET(_PREREQ_CONFIG_DIR "@CAS_DIR@" "@OpenGL_DIR@" "@PyQt4_DIR@" "@Qt4_DIR@" "@Qwt_DIR@" "@SIP_DIR@" "@VTK_DIR@") +LIST(LENGTH _PREREQ_CONFIG_DIR _list_len) +# Another CMake stupidity - FOREACH(... RANGE r) generates r+1 numbers ... +MATH(EXPR _range "${_list_len}-1") +FOREACH(_p RANGE ${_range}) + LIST(GET _PREREQ ${_p} _pkg ) + LIST(GET _PREREQ_CONFIG_DIR ${_p} _pkg_dir) + IF(_pkg_dir) + MESSAGE(STATUS "===> Reloading targets from ${_pkg} ...") + FIND_PACKAGE(${_pkg} REQUIRED NO_MODULE + PATHS "${_pkg_dir}" + NO_DEFAULT_PATH) + ENDIF() +ENDFOREACH() # Installation directories -SET_AND_CHECK(SALOME_INSTALL_BINS "@SALOME_INSTALL_BINS@") -SET_AND_CHECK(SALOME_INSTALL_LIBS "@SALOME_INSTALL_LIBS@") -SET_AND_CHECK(SALOME_INSTALL_IDLS "@SALOME_INSTALL_IDLS@") -SET_AND_CHECK(SALOME_INSTALL_HEADERS "@SALOME_INSTALL_HEADERS@") -SET_AND_CHECK(SALOME_INSTALL_SCRIPT_SCRIPTS "@SALOME_INSTALL_SCRIPT_SCRIPTS@") -SET_AND_CHECK(SALOME_INSTALL_SCRIPT_DATA "@SALOME_INSTALL_SCRIPT_DATA@") -SET_AND_CHECK(SALOME_INSTALL_SCRIPT_PYTHON "@SALOME_INSTALL_SCRIPT_PYTHON@") -SET_AND_CHECK(SALOME_INSTALL_APPLISKEL_SCRIPTS "@SALOME_INSTALL_APPLISKEL_SCRIPTS@") -SET_AND_CHECK(SALOME_INSTALL_APPLISKEL_PYTHON "@SALOME_INSTALL_APPLISKEL_PYTHON@") -SET_AND_CHECK(SALOME_INSTALL_CMAKE "@SALOME_INSTALL_CMAKE@") -SET_AND_CHECK(SALOME_INSTALL_CMAKE_LOCAL "@SALOME_INSTALL_CMAKE_LOCAL@") -SET_AND_CHECK(SALOME_INSTALL_PYTHON "@SALOME_INSTALL_PYTHON@") -SET_AND_CHECK(SALOME_INSTALL_PYTHON_SHARED "@SALOME_INSTALL_PYTHON_SHARED@") -SET_AND_CHECK(SALOME_INSTALL_RES "@SALOME_INSTALL_RES@") +SET(SALOME_INSTALL_BINS "@SALOME_INSTALL_BINS@") +SET(SALOME_INSTALL_LIBS "@SALOME_INSTALL_LIBS@") +SET(SALOME_INSTALL_IDLS "@SALOME_INSTALL_IDLS@") +SET(SALOME_INSTALL_HEADERS "@SALOME_INSTALL_HEADERS@") +SET(SALOME_INSTALL_SCRIPT_SCRIPTS "@SALOME_INSTALL_SCRIPT_SCRIPTS@") +SET(SALOME_INSTALL_SCRIPT_DATA "@SALOME_INSTALL_SCRIPT_DATA@") +SET(SALOME_INSTALL_SCRIPT_PYTHON "@SALOME_INSTALL_SCRIPT_PYTHON@") +SET(SALOME_INSTALL_APPLISKEL_SCRIPTS "@SALOME_INSTALL_APPLISKEL_SCRIPTS@") +SET(SALOME_INSTALL_APPLISKEL_PYTHON "@SALOME_INSTALL_APPLISKEL_PYTHON@") +SET(SALOME_INSTALL_CMAKE "@SALOME_INSTALL_CMAKE@") +SET(SALOME_INSTALL_CMAKE_LOCAL "@SALOME_INSTALL_CMAKE_LOCAL@") +SET(SALOME_INSTALL_PYTHON "@SALOME_INSTALL_PYTHON@") +SET(SALOME_INSTALL_PYTHON_SHARED "@SALOME_INSTALL_PYTHON_SHARED@") +SET(SALOME_INSTALL_RES "@SALOME_INSTALL_RES@") -# Include KERNEL targets: -INCLUDE("${KERNEL_ROOT_DIR_EXP}/${SALOME_INSTALL_CMAKE}/SalomeKERNELTargets.cmake") +# Include KERNEL targets if they were not already loaded: +IF(NOT (TARGET SALOMEBasics)) + INCLUDE("${KERNEL_ROOT_DIR_EXP}/${SALOME_INSTALL_CMAKE}/SalomeKERNELTargets.cmake") +ENDIF() -# Exposed targets: +# Exposed GUI targets: SET(GUI_caf caf) SET(GUI_CAM CAM) SET(GUI_CASCatch CASCatch) diff --git a/bin/CMakeLists.txt b/bin/CMakeLists.txt index 29f771fc5..d17b54c71 100755 --- a/bin/CMakeLists.txt +++ b/bin/CMakeLists.txt @@ -17,8 +17,6 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/SalomeMacros.cmake) - CONFIGURE_FILE(VERSION.in VERSION @ONLY) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/VERSION DESTINATION ${SALOME_INSTALL_BINS}) diff --git a/src/GUI_PY/CMakeLists.txt b/src/GUI_PY/CMakeLists.txt index 09abae165..53a636543 100755 --- a/src/GUI_PY/CMakeLists.txt +++ b/src/GUI_PY/CMakeLists.txt @@ -17,8 +17,6 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/SalomeMacros.cmake) - INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ) diff --git a/src/SALOME_SWIG/CMakeLists.txt b/src/SALOME_SWIG/CMakeLists.txt index 8c37162fe..dcb255075 100755 --- a/src/SALOME_SWIG/CMakeLists.txt +++ b/src/SALOME_SWIG/CMakeLists.txt @@ -17,9 +17,7 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -FIND_PACKAGE(SWIG REQUIRED) INCLUDE(${SWIG_USE_FILE}) -INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/SalomeMacros.cmake) INCLUDE(${VTK_USE_FILE}) SET_SOURCE_FILES_PROPERTIES(libSALOME_Swig.i PROPERTIES CPLUSPLUS ON) diff --git a/src/SalomeApp/CMakeLists.txt b/src/SalomeApp/CMakeLists.txt index 89f240b34..66aeb2264 100755 --- a/src/SalomeApp/CMakeLists.txt +++ b/src/SalomeApp/CMakeLists.txt @@ -24,7 +24,6 @@ IF(NOT SALOME_LIGHT_ONLY AND SALOME_BUILD_TESTS) ENDIF() INCLUDE(UseQt4Ext) -INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/SalomeMacros.cmake) INCLUDE(${VTK_USE_FILE}) INCLUDE_DIRECTORIES( diff --git a/src/SalomeApp/pluginsdemo/CMakeLists.txt b/src/SalomeApp/pluginsdemo/CMakeLists.txt index 2abfb591e..1e2749197 100755 --- a/src/SalomeApp/pluginsdemo/CMakeLists.txt +++ b/src/SalomeApp/pluginsdemo/CMakeLists.txt @@ -25,8 +25,6 @@ # variable *_ROOT_DIR). # -INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/SalomeMacros.cmake) - SET(plugins_PYTHON salome_plugins.py smesh_plugins.py -- 2.39.2