From: bruneton Date: Thu, 11 Jul 2013 09:52:16 +0000 (+0000) Subject: CMake: nicer error message (hinting to the ROOT_DIR variable) when a X-Git-Tag: B4KillOfAutomake~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b0bb35fd3f357944a5be760e9c22bf82b4acb28b;p=modules%2Fkernel.git CMake: nicer error message (hinting to the ROOT_DIR variable) when a package is not found. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 25cb4c0fc..bcd59b1d0 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,7 +38,7 @@ SET(VERSION_DEV "0") # Our own set of macros: LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/salome_adm/cmake_files") -INCLUDE(${PROJECT_SOURCE_DIR}/salome_adm/cmake_files/SalomeMacros.cmake) +INCLUDE(SalomeMacros) # Platform setup # ============== diff --git a/salome_adm/cmake_files/SalomeMacros.cmake b/salome_adm/cmake_files/SalomeMacros.cmake index 34730369c..acf423372 100755 --- a/salome_adm/cmake_files/SalomeMacros.cmake +++ b/salome_adm/cmake_files/SalomeMacros.cmake @@ -205,6 +205,9 @@ ENDMACRO() # given when calling the command FIND_PACKAGE(SalomeXYZ). Those options are stored implicitly in # CMake variables: xyz__FIND_QUIETLY, xyz_FIND_REQUIRED, etc ... # +# If a list of components was specified when invoking the initial FIND_PACKAGE(SalomeXyz ...) this is +# also handled properly. +# # Modus is either MODULE or CONFIG (cf standard FIND_PACKAGE() documentation). # The last argument is optional and if set to TRUE will force the search to be OPTIONAL and QUIET. # @@ -279,13 +282,12 @@ ENDMACRO() #################################################################### -# SALOME_FIND_PACKAGE_DETECT_CONFLICTS(pkg referenceVariable upCount ...) +# SALOME_FIND_PACKAGE_DETECT_CONFLICTS(pkg referenceVariable upCount) # pkg : name of the system package to be detected # referenceVariable: variable containing a path that can be browsed up to # retrieve the package root directory (xxx_ROOT_DIR) # upCount : number of times we have to go up from the path # to obtain the package root directory. -# : an optional list of components to be found. # # For example: SALOME_FIND_PACKAGE_DETECT_CONFLICTS(SWIG SWIG_EXECUTABLE 2) # @@ -352,13 +354,23 @@ MACRO(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS pkg referenceVariable upCount) ENDIF() # Otherwise try the standard way (module mode, with the standard CMake Find*** macro): - SALOME_FIND_PACKAGE("Salome${pkg}" ${pkg} MODULE) + # We do it quietly to produce our own error message: + SALOME_FIND_PACKAGE("Salome${pkg}" ${pkg} MODULE TRUE) # Set the "FOUND" variable for the SALOME wrapper: IF(${pkg_UC}_FOUND OR ${pkg}_FOUND) SET(SALOME${pkg_UC}_FOUND TRUE) ELSE() SET(SALOME${pkg_UC}_FOUND FALSE) + IF(NOT Salome${pkg}_FIND_QUIETLY) + IF(Salome${pkg}_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Package ${pkg} couldn't be found - did you set the corresponing root dir correctly? " + "It currently contains ${pkg_UC}_ROOT_DIR=${${pkg_UC}_ROOT_DIR}") + ELSE() + MESSAGE(WARNING "Package ${pkg} couldn't be found - did you set the corresponing root dir correctly? " + "It currently contains ${pkg_UC}_ROOT_DIR=${${pkg_UC}_ROOT_DIR}") + ENDIF() + ENDIF() ENDIF() IF (${pkg_UC}_FOUND OR ${pkg}_FOUND)