X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=salome_adm%2Fcmake_files%2FSalomeMacros.cmake;h=5a94723fb09407b4eb355b90d8aff80dc6baac32;hb=718e0abe0126e5e53b3ba41fff1028efcf5bc887;hp=7ed262265b68421ec63967f72a07d5c406c49375;hpb=509528c13bd0d6be2dccfaa01ac238e382cdfd3a;p=modules%2Fkernel.git diff --git a/salome_adm/cmake_files/SalomeMacros.cmake b/salome_adm/cmake_files/SalomeMacros.cmake index 7ed262265..5a94723fb 100644 --- a/salome_adm/cmake_files/SalomeMacros.cmake +++ b/salome_adm/cmake_files/SalomeMacros.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2015 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2012-2016 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 @@ -473,6 +473,7 @@ MACRO(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS pkg referenceVariable upCount) ## ## 0. Initialization ## + PARSE_ARGUMENTS(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS "ENVVAR" "" ${ARGN}) # Package name, upper case STRING(TOUPPER ${pkg} pkg_UC) @@ -480,22 +481,25 @@ MACRO(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS pkg referenceVariable upCount) ## ## 1. Load environment or any previously detected root dir for the package ## - IF(DEFINED ENV{${pkg_UC}_ROOT_DIR}) - FILE(TO_CMAKE_PATH "$ENV{${pkg_UC}_ROOT_DIR}" _${pkg_UC}_ROOT_DIR_ENV) + SET(_envvar ${pkg_UC}_ROOT_DIR) + IF(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS_ENVVAR) + SET(_envvar "${SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS_ENVVAR}") + ENDIF() + IF(DEFINED ENV{${_envvar}}) + FILE(TO_CMAKE_PATH "$ENV{${_envvar}}" _${pkg_UC}_ROOT_DIR_ENV) SET(_dflt_value "${_${pkg_UC}_ROOT_DIR_ENV}") ELSE() # will be blank if no package was previously loaded: SET(_dflt_value "${${pkg_UC}_ROOT_DIR_EXP}") ENDIF() - # Detect if the variable has been set on the command line or elsewhere: - IF(DEFINED ${pkg_UC}_ROOT_DIR) + IF(DEFINED ${_envvar}) SET(_var_already_there TRUE) ELSE() SET(_var_already_there FALSE) ENDIF() # Make cache entry - SET(${pkg_UC}_ROOT_DIR "${_dflt_value}" CACHE PATH "Path to ${pkg_UC} directory") + SET(${_envvar} "${_dflt_value}" CACHE PATH "Path to ${pkg_UC} directory") ## ## 2. Find package - try CONFIG mode first (i.e. looking for XYZ-config.cmake) @@ -503,7 +507,9 @@ MACRO(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS pkg referenceVariable upCount) # Override the variable - don't append to it, as it would give precedence # to what was stored there before! - SET(CMAKE_PREFIX_PATH "${${pkg_UC}_ROOT_DIR}") + IF(DEFINED ${_envvar}) + SET(CMAKE_PREFIX_PATH "${${_envvar}}") + ENDIF() # Try find_package in config mode. This has the priority, but is # performed QUIET and not REQUIRED: @@ -529,11 +535,11 @@ MACRO(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS pkg referenceVariable upCount) 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} " + "It currently contains ${_envvar}=${${_envvar}} " "Append -DSALOME_CMAKE_DEBUG=ON on the command line if you want to see the original CMake error.") 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} " + "It currently contains ${_envvar}=${${_envvar}} " "Append -DSALOME_CMAKE_DEBUG=ON on the command line if you want to see the original CMake error.") ENDIF() ENDIF() @@ -566,19 +572,19 @@ MACRO(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS pkg referenceVariable upCount) ## ## 4. Warn if CMake found something not located under ENV(XYZ_ROOT_DIR) ## - IF(DEFINED ENV{${pkg_UC}_ROOT_DIR}) + IF(DEFINED ENV{${_envvar}}) SALOME_CHECK_EQUAL_PATHS(_res "${_tmp_ROOT_DIR}" "${_${pkg_UC}_ROOT_DIR_ENV}") IF(NOT _res) MESSAGE(WARNING "${pkg} was found, but not at the path given by the " - "environment ${pkg_UC}_ROOT_DIR! Is the variable correctly set? " + "environment ${_envvar}! Is the variable correctly set? " "The two paths are: ${_tmp_ROOT_DIR} and: ${_${pkg_UC}_ROOT_DIR_ENV}") ELSE() - MESSAGE(STATUS "${pkg} found directory matches what was specified in the ${pkg_UC}_ROOT_DIR variable, all good!") + MESSAGE(STATUS "${pkg} found directory matches what was specified in the ${_envvar} variable, all good!") ENDIF() ELSE() IF(NOT _var_already_there) - MESSAGE(STATUS "Variable ${pkg_UC}_ROOT_DIR was not explicitly defined. " + MESSAGE(STATUS "Variable ${_envvar} was not explicitly defined. " "An installation was found anyway: ${_tmp_ROOT_DIR}") ENDIF() ENDIF() @@ -600,7 +606,7 @@ MACRO(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS pkg referenceVariable upCount) ## ## 6. Save the detected installation ## - SET(${pkg_UC}_ROOT_DIR "${_tmp_ROOT_DIR}") + SET(${_envvar} "${_tmp_ROOT_DIR}") ELSE() MESSAGE(STATUS "${pkg} was not found.") @@ -752,7 +758,8 @@ MACRO(SALOME_ACCUMULATE_ENVIRONMENT envvar) ENDIF() SET(_${PROJECT_NAME}_EXTRA_ENV_FULL "SET\(${PROJECT_NAME}_EXTRA_ENV ${_${PROJECT_NAME}_EXTRA_ENV}\)") FOREACH(_res ${_${PROJECT_NAME}_EXTRA_ENV}) - SET(_${PROJECT_NAME}_EXTRA_ENV_FULL "${_${PROJECT_NAME}_EXTRA_ENV_FULL}\nSET\(${PROJECT_NAME}_EXTRA_ENV_${_res} ${_${PROJECT_NAME}_EXTRA_ENV_${_res}}\)") + STRING(REPLACE "${CMAKE_INSTALL_PREFIX}" "\${PACKAGE_PREFIX_DIR}" _res_path "${_${PROJECT_NAME}_EXTRA_ENV_${_res}}") + SET(_${PROJECT_NAME}_EXTRA_ENV_FULL "${_${PROJECT_NAME}_EXTRA_ENV_FULL}\nSET\(${PROJECT_NAME}_EXTRA_ENV_${_res} ${_res_path}\)") ENDFOREACH() ENDMACRO(SALOME_ACCUMULATE_ENVIRONMENT) @@ -937,7 +944,8 @@ MACRO(SALOME_CONFIGURE_PREPARE) FOREACH(_prereq IN LISTS _tmp_prereq) IF(${_prereq}_DIR) SET(_PREREQ_LIST "${_PREREQ_LIST} ${_prereq}") - SET(_PREREQ_DIR_LIST "${_PREREQ_DIR_LIST} \"${${_prereq}_DIR}\"") + FILE(TO_CMAKE_PATH ${${_prereq}_DIR} CURR_DIR) + SET(_PREREQ_DIR_LIST "${_PREREQ_DIR_LIST} \"${CURR_DIR}\"") SALOME_APPEND_LIST_OF_LIST(_PREREQ_COMPO_LIST Salome${_prereq}_COMPONENTS) ENDIF() ENDFOREACH()