1 # Copyright (C) 2012-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 # Author: A.Geay, V. Sandler, A. Bruneton
22 #----------------------------------------------------------------------------
23 # LIST_CONTAINS is a macro useful for determining whether a list has a
25 #----------------------------------------------------------------------------
26 MACRO(LIST_CONTAINS var value)
28 FOREACH(value2 ${ARGN})
29 IF(${value} STREQUAL "${value2}")
31 ENDIF (${value} STREQUAL "${value2}")
33 ENDMACRO(LIST_CONTAINS)
35 #----------------------------------------------------------------------------
36 # The PARSE_ARGUMENTS macro will take the arguments of another macro and
37 # define several variables.
39 # USAGE: PARSE_ARGUMENTS(prefix arg_names options arg1 arg2...)
43 # prefix: IN: a prefix to put on all variables it creates.
45 # arg_names: IN: a list of names.
46 # For each item in arg_names, PARSE_ARGUMENTS will create a
47 # variable with that name, prefixed with prefix_. Each variable will be filled
48 # with the arguments that occur after the given arg_name is encountered
49 # up to the next arg_name or the end of the arguments. All options are
50 # removed from these lists. PARSE_ARGUMENTS also creates a
51 # prefix_DEFAULT_ARGS variable containing the list of all arguments up
52 # to the first arg_name encountered.
54 # options: IN: a list of options.
55 # For each item in options, PARSE_ARGUMENTS will create a
56 # variable with that name, prefixed with prefix_. So, for example, if prefix is
57 # MY_MACRO and options is OPTION1;OPTION2, then PARSE_ARGUMENTS will
58 # create the variables MY_MACRO_OPTION1 and MY_MACRO_OPTION2. These
59 # variables will be set to true if the option exists in the command line
61 # arg_names and options lists should be quoted.
63 # The rest of PARSE_ARGUMENTS are arguments from another macro to be parsed.
64 #----------------------------------------------------------------------------
65 MACRO(PARSE_ARGUMENTS prefix arg_names option_names)
67 FOREACH(arg_name ${arg_names})
68 SET(${prefix}_${arg_name})
70 FOREACH(option ${option_names})
71 SET(${prefix}_${option} FALSE)
73 SET(current_arg_name DEFAULT_ARGS)
76 LIST_CONTAINS(is_arg_name ${arg} ${arg_names})
78 SET(${prefix}_${current_arg_name} ${current_arg_list})
79 SET(current_arg_name ${arg})
82 LIST_CONTAINS(is_option ${arg} ${option_names})
84 SET(${prefix}_${arg} TRUE)
86 SET(current_arg_list ${current_arg_list} ${arg})
90 SET(${prefix}_${current_arg_name} ${current_arg_list})
91 ENDMACRO(PARSE_ARGUMENTS)
93 #----------------------------------------------------------------------------
94 # SALOME_INSTALL_SCRIPTS is a macro useful for installing scripts.
96 # USAGE: SALOME_INSTALL_SCRIPTS(file_list path [WORKING_DIRECTORY dir] [DEF_PERMS])
99 # file_list: IN : list of files to be installed. This list should be quoted.
100 # path: IN : full pathname for installing.
102 # By default files to be installed as executable scripts.
103 # If DEF_PERMS option is provided, than permissions for installed files are
104 # only OWNER_WRITE, OWNER_READ, GROUP_READ, and WORLD_READ.
105 #----------------------------------------------------------------------------
106 MACRO(SALOME_INSTALL_SCRIPTS file_list path)
107 PARSE_ARGUMENTS(SALOME_INSTALL_SCRIPTS "WORKING_DIRECTORY" "DEF_PERMS" ${ARGN})
108 SET(PERMS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
109 IF(NOT SALOME_INSTALL_SCRIPTS_DEF_PERMS)
110 SET(PERMS ${PERMS} OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE)
111 ENDIF(NOT SALOME_INSTALL_SCRIPTS_DEF_PERMS)
112 FOREACH(file ${file_list})
114 IF(IS_ABSOLUTE ${file})
115 GET_FILENAME_COMPONENT(file_name ${file} NAME)
117 SET(file_name ${file})
118 IF(SALOME_INSTALL_SCRIPTS_WORKING_DIRECTORY)
119 SET(PREFIX "${SALOME_INSTALL_SCRIPTS_WORKING_DIRECTORY}/")
120 ENDIF(SALOME_INSTALL_SCRIPTS_WORKING_DIRECTORY)
121 ENDIF(IS_ABSOLUTE ${file})
122 INSTALL(FILES ${PREFIX}${file} DESTINATION ${path} PERMISSIONS ${PERMS})
123 GET_FILENAME_COMPONENT(ext ${file} EXT)
125 INSTALL(CODE "MESSAGE(STATUS \"py compiling ${CMAKE_INSTALL_PREFIX}/${path}/${file_name}\")")
126 INSTALL(CODE "SET(CMD \"import py_compile ; py_compile.compile('${CMAKE_INSTALL_PREFIX}/${path}/${file_name}')\")")
127 INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c \"\${CMD}\")")
128 INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -O -c \"\${CMD}\")")
129 ENDIF(ext STREQUAL .py)
130 ENDFOREACH(file ${file_list})
131 ENDMACRO(SALOME_INSTALL_SCRIPTS)
133 #----------------------------------------------------------------------------
134 # SALOME_INSTALL_SCRIPTS is a macro useful for installing executable scripts.
136 # PYFILE2COMPINST: IN : list of python files to be installed.
137 # PYFILELOC: IN : full pathname for installing.
138 # Permissions of installed files: OWNER_WRITE, OWNER_READ, GROUP_READ, and WORLD_READ
139 #----------------------------------------------------------------------------
140 MACRO(INSTALL_AND_COMPILE_PYTHON_FILE PYFILE2COMPINST PYFILELOC)
141 INSTALL(CODE "SET(PYTHON_FILE ${f})")
142 FOREACH(input ${PYFILE2COMPINST})
143 GET_FILENAME_COMPONENT(inputname ${input} NAME)
144 INSTALL(FILES ${input} DESTINATION ${CMAKE_INSTALL_PREFIX}/${PYFILELOC})
145 INSTALL(CODE "MESSAGE(STATUS \"py compiling ${CMAKE_INSTALL_PREFIX}/${PYFILELOC}/${inputname}\")")
146 INSTALL(CODE "SET(CMD \"import py_compile ; py_compile.compile('${CMAKE_INSTALL_PREFIX}/${PYFILELOC}/${inputname}')\")")
147 INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c \"\${CMD}\")")
148 INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -O -c \"\${CMD}\")")
149 ENDFOREACH(input ${PYFILE2COMPINST})
150 ENDMACRO(INSTALL_AND_COMPILE_PYTHON_FILE PYFILE2COMPINST PYFILELOC)
152 #----------------------------------------------------------------------------
153 # SALOME_CONFIGURE_FILE is a macro useful for copying a file to another location
154 # and modify its contents.
156 # USAGE: SALOME_CONFIGURE_FILE(in_file out_file [INSTALL dir])
159 # in_file: IN : input file (if relative path is given, full file path is computed from current source dir).
160 # out_file: IN : output file (if relative path is given, full file path is computed from current build dir).
161 # If INSTALL is specified, then 'out_file' will be installed to the 'dir' directory.
162 #----------------------------------------------------------------------------
163 MACRO(SALOME_CONFIGURE_FILE IN_FILE OUT_FILE)
164 IF(IS_ABSOLUTE ${IN_FILE})
165 SET(_in_file ${IN_FILE})
167 SET(_in_file ${CMAKE_CURRENT_SOURCE_DIR}/${IN_FILE})
169 IF(IS_ABSOLUTE ${OUT_FILE})
170 SET(_out_file ${OUT_FILE})
172 SET(_out_file ${CMAKE_CURRENT_BINARY_DIR}/${OUT_FILE})
174 MESSAGE(STATUS "Creation of ${_out_file}")
175 CONFIGURE_FILE(${_in_file} ${_out_file} @ONLY)
176 PARSE_ARGUMENTS(SALOME_CONFIGURE_FILE "INSTALL" "" ${ARGN})
177 IF(SALOME_CONFIGURE_FILE_INSTALL)
178 INSTALL(FILES ${_out_file} DESTINATION ${SALOME_CONFIGURE_FILE_INSTALL})
179 ENDIF(SALOME_CONFIGURE_FILE_INSTALL)
180 ENDMACRO(SALOME_CONFIGURE_FILE)
183 #######################################################################################
184 # Useful macros for SALOME own package detection system
188 # SALOME_CHECK_EQUAL_PATHS(result path1 path2)
189 # Check if two paths are identical, resolving links. If the paths do not exist a simple
190 # text comparison is performed.
191 # result is a boolean.
193 MACRO(SALOME_CHECK_EQUAL_PATHS varRes path1 path2)
195 IF(EXISTS "${path1}")
196 GET_FILENAME_COMPONENT(_tmp1 "${path1}" REALPATH)
198 SET(_tmp1 "${path1}")
201 IF(EXISTS "${path2}")
202 GET_FILENAME_COMPONENT(_tmp2 "${path2}" REALPATH)
204 SET(_tmp2 "${path2}")
207 IF("${_tmp1}" STREQUAL "${_tmp2}")
210 # MESSAGE(${${varRes}})
214 # SALOME_UPDATE_FLAG_AND_LOG_PACKAGE(pkg flag)
216 # Register in global variables the detection status (found or not) of the optional package 'pkg'
217 # and the configuration flag that should be turned off if it is not found.
218 # If the package was not found, the macro explicitly turns off the flag.
219 # The global variables are read again by SALOME_PACKAGE_REPORT to produce a summary report
220 # of the detection status, and of the modified flags.
221 MACRO(SALOME_UPDATE_FLAG_AND_LOG_PACKAGE pkg flag)
222 # Was the package found
223 STRING(TOUPPER ${pkg} _pkg_UC)
224 IF(${pkg}_FOUND OR ${_pkg_UC}_FOUND)
230 # Is the package already in the list? Then update its status:
231 LIST(FIND _SALOME_OPTIONAL_PACKAGES_names ${pkg} _result)
232 IF(NOT ${_result} EQUAL -1)
233 LIST(REMOVE_AT _SALOME_OPTIONAL_PACKAGES_found ${_result})
234 LIST(REMOVE_AT _SALOME_OPTIONAL_PACKAGES_flags ${_result})
235 LIST(INSERT _SALOME_OPTIONAL_PACKAGES_found ${_result} ${_isFound})
236 LIST(INSERT _SALOME_OPTIONAL_PACKAGES_flags ${_result} ${flag})
238 # Otherwise insert it
239 LIST(APPEND _SALOME_OPTIONAL_PACKAGES_names ${pkg})
240 LIST(APPEND _SALOME_OPTIONAL_PACKAGES_found ${_isFound})
241 LIST(APPEND _SALOME_OPTIONAL_PACKAGES_flags ${flag})
244 # If the package was not found, force the cache flag to OFF
248 ENDMACRO(SALOME_UPDATE_FLAG_AND_LOG_PACKAGE)
251 # SALOME_JUSTIFY_STRING()
253 # Justifies the string specified as an argument to the given length
254 # adding required number of spaces to the end. Does noting if input
255 # string is longer as required length.
256 # Puts the result to the output variable.
257 MACRO(SALOME_JUSTIFY_STRING input length result)
258 SET(${result} ${input})
259 STRING(LENGTH ${input} _input_length)
260 MATH(EXPR _nb_spaces "${length}-${_input_length}-1")
261 IF (_nb_spaces GREATER 0)
262 FOREACH(_idx RANGE ${_nb_spaces})
263 SET(${result} "${${result}} ")
266 ENDMACRO(SALOME_JUSTIFY_STRING)
269 # SALOME_PACKAGE_REPORT()
271 # Print a quick summary of the detection of optional prerequisites.
273 MACRO(SALOME_PACKAGE_REPORT)
274 PARSE_ARGUMENTS(SALOME_PACKAGE_REPORT "LENGTH" "" ${ARGN})
275 IF(SALOME_PACKAGE_REPORT_LENGTH)
276 SET(_length ${SALOME_PACKAGE_REPORT_LENGTH})
281 MESSAGE(STATUS " Optional packages - Detection report ")
282 MESSAGE(STATUS " ==================================== ")
284 LIST(LENGTH _SALOME_OPTIONAL_PACKAGES_names _list_len)
285 # Another CMake stupidity - FOREACH(... RANGE r) generates r+1 numbers ...
286 MATH(EXPR _range "${_list_len}-1")
287 FOREACH(_idx RANGE ${_range})
288 LIST(GET _SALOME_OPTIONAL_PACKAGES_names ${_idx} _pkg_name)
289 LIST(GET _SALOME_OPTIONAL_PACKAGES_found ${_idx} _pkg_found)
290 LIST(GET _SALOME_OPTIONAL_PACKAGES_flags ${_idx} _pkg_flag)
291 SALOME_JUSTIFY_STRING(${_pkg_name} ${_length} _pkg_name)
293 SET(_found_msg "Found")
296 SET(_found_msg "NOT Found")
297 SET(_flag_msg " - ${_pkg_flag} has been switched OFF.")
300 MESSAGE(STATUS " * ${_pkg_name} -> ${_found_msg}${_flag_msg}")
304 ENDMACRO(SALOME_PACKAGE_REPORT)
307 # SALOME_FIND_PACKAGE(englobingPackageName standardPackageName modus [onlyTryQuietly])
309 # example: SALOME_FIND_PACKAGE(SalomeVTK VTK CONFIG)
311 # Encapsulate the call to the standard FIND_PACKAGE(standardPackageName) passing all the options
312 # given when calling the command FIND_PACKAGE(SalomeXYZ). Those options are stored implicitly in
313 # CMake variables: xyz__FIND_QUIETLY, xyz_FIND_REQUIRED, etc ...
315 # If a list of components was specified when invoking the initial FIND_PACKAGE(SalomeXyz ...) this is
316 # also handled properly.
318 # Modus is either MODULE or CONFIG (cf standard FIND_PACKAGE() documentation).
319 # The last argument is optional and if set to TRUE will force the search to be OPTIONAL and QUIET.
320 # If the package is looked for in CONFIG mode, the standard system paths are skipped. If you still want a
321 # system installation to be found in this mode, you have to set the ROOT_DIR variable explicitly to /usr (for
324 # This macro is to be called from within the FindSalomeXXXX.cmake file.
327 MACRO(SALOME_FIND_PACKAGE englobPkg stdPkg mode)
328 SET(_OPT_ARG ${ARGV3})
329 # Only bother if the package was not already found:
330 # Some old packages use the lower case version - standard should be to always use
332 STRING(TOUPPER ${stdPkg} stdPkgUC)
333 IF(NOT (${stdPkg}_FOUND OR ${stdPkgUC}_FOUND))
334 IF(${englobPkg}_FIND_QUIETLY OR _OPT_ARG)
335 SET(_tmp_quiet "QUIET")
339 IF(${englobPkg}_FIND_REQUIRED AND NOT _OPT_ARG)
340 SET(_tmp_req "REQUIRED")
344 IF(${englobPkg}_FIND_VERSION_EXACT)
345 SET(_tmp_exact "EXACT")
350 # Call the CMake FIND_PACKAGE() command:
351 STRING(TOLOWER ${stdPkg} _pkg_lc)
352 IF(("${mode}" STREQUAL "NO_MODULE") OR ("${mode}" STREQUAL "CONFIG"))
353 # Hope to find direclty a CMake config file, indicating the SALOME CMake file
354 # paths (the command already looks in places like "share/cmake", etc ... by default)
355 # Note the options NO_CMAKE_BUILDS_PATH, NO_CMAKE_PACKAGE_REGISTRY to avoid (under Windows)
356 # looking into a previous CMake build done via a GUI, or into the Win registry.
357 # NO_CMAKE_SYSTEM_PATH and NO_SYSTEM_ENVIRONMENT_PATH ensure any _system_ files like 'xyz-config.cmake'
358 # don't get loaded (typically Boost). To force their loading, set the XYZ_ROOT_DIR variable to '/usr'.
359 # See documentation of FIND_PACKAGE() for full details.
361 # Do we need to call the signature using components?
362 IF(${englobPkg}_FIND_COMPONENTS)
363 FIND_PACKAGE(${stdPkg} ${${englobPkg}_FIND_VERSION} ${_tmp_exact}
364 NO_MODULE ${_tmp_quiet} ${_tmp_req} COMPONENTS ${${englobPkg}_FIND_COMPONENTS}
365 PATH_SUFFIXES "salome_adm/cmake_files" "adm_local/cmake_files"
366 NO_CMAKE_BUILDS_PATH NO_CMAKE_PACKAGE_REGISTRY NO_CMAKE_SYSTEM_PACKAGE_REGISTRY NO_CMAKE_SYSTEM_PATH
367 NO_SYSTEM_ENVIRONMENT_PATH)
369 FIND_PACKAGE(${stdPkg} ${${englobPkg}_FIND_VERSION} ${_tmp_exact}
370 NO_MODULE ${_tmp_quiet} ${_tmp_req}
371 PATH_SUFFIXES "salome_adm/cmake_files" "adm_local/cmake_files"
372 NO_CMAKE_BUILDS_PATH NO_CMAKE_PACKAGE_REGISTRY NO_CMAKE_SYSTEM_PACKAGE_REGISTRY NO_CMAKE_SYSTEM_PATH
373 NO_SYSTEM_ENVIRONMENT_PATH)
375 MARK_AS_ADVANCED(${stdPkg}_DIR)
377 ELSEIF("${mode}" STREQUAL "MODULE")
379 # Do we need to call the signature using components?
380 IF(${englobPkg}_FIND_COMPONENTS)
381 FIND_PACKAGE(${stdPkg} ${${englobPkg}_FIND_VERSION} ${_tmp_exact}
382 MODULE ${_tmp_quiet} ${_tmp_req} COMPONENTS ${${englobPkg}_FIND_COMPONENTS})
384 FIND_PACKAGE(${stdPkg} ${${englobPkg}_FIND_VERSION} ${_tmp_exact}
385 MODULE ${_tmp_quiet} ${_tmp_req})
390 MESSAGE(FATAL_ERROR "Invalid mode argument in the call to the macro SALOME_FIND_PACKAGE. Should be CONFIG or MODULE.")
398 ####################################################################
399 # SALOME_FIND_PACKAGE_DETECT_CONFLICTS(pkg referenceVariable upCount)
400 # pkg : name of the system package to be detected
401 # referenceVariable: variable containing a path that can be browsed up to
402 # retrieve the package root directory (xxx_ROOT_DIR)
403 # upCount : number of times we have to go up from the path <referenceVariable>
404 # to obtain the package root directory.
406 # For example: SALOME_FIND_PACKAGE_DETECT_CONFLICTS(SWIG SWIG_EXECUTABLE 2)
408 # Generic detection (and conflict check) procedure for package XYZ:
409 # 1. Load a potential env variable XYZ_ROOT_DIR as a default choice for the cache entry XYZ_ROOT_DIR
410 # If empty, load a potential XYZ_ROOT_DIR_EXP as default value (path exposed by another package depending
412 # 2. Invoke FIND_PACKAGE() in this order:
413 # * in CONFIG mode first (if possible): priority is given to a potential
414 # "XYZ-config.cmake" file
415 # * then switch to the standard MODULE mode, appending on CMAKE_PREFIX_PATH
416 # the above XYZ_ROOT_DIR variable
417 # 3. Extract the path actually found into a temp variable _XYZ_TMP_DIR
418 # 4. Warn if XYZ_ROOT_DIR is set and doesn't match what was found (e.g. when CMake found the system installation
419 # instead of what is pointed to by XYZ_ROOT_DIR - happens when a typo in the content of XYZ_ROOT_DIR).
420 # 5. Conflict detection:
421 # * check the temp variable against a potentially existing XYZ_ROOT_DIR_EXP
422 # 6. Finally expose what was *actually* found in XYZ_ROOT_DIR.
423 # 7. Specific stuff: for example exposing a prerequisite of XYZ to the rest of the world for future
424 # conflict detection. This is added after the call to the macro by the callee.
426 MACRO(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS pkg referenceVariable upCount)
431 # Package name, upper case
432 STRING(TOUPPER ${pkg} pkg_UC)
435 ## 1. Load environment or any previously detected root dir for the package
437 IF(DEFINED ENV{${pkg_UC}_ROOT_DIR})
438 FILE(TO_CMAKE_PATH "$ENV{${pkg_UC}_ROOT_DIR}" _${pkg_UC}_ROOT_DIR_ENV)
439 SET(_dflt_value "${_${pkg_UC}_ROOT_DIR_ENV}")
441 # will be blank if no package was previously loaded:
442 SET(_dflt_value "${${pkg_UC}_ROOT_DIR_EXP}")
445 # Detect if the variable has been set on the command line or elsewhere:
446 IF(DEFINED ${pkg_UC}_ROOT_DIR)
447 SET(_var_already_there TRUE)
449 SET(_var_already_there FALSE)
452 SET(${pkg_UC}_ROOT_DIR "${_dflt_value}" CACHE PATH "Path to ${pkg_UC} directory")
455 ## 2. Find package - try CONFIG mode first (i.e. looking for XYZ-config.cmake)
458 # Override the variable - don't append to it, as it would give precedence
459 # to what was stored there before!
460 SET(CMAKE_PREFIX_PATH "${${pkg_UC}_ROOT_DIR}")
462 # Try find_package in config mode. This has the priority, but is
463 # performed QUIET and not REQUIRED:
464 SALOME_FIND_PACKAGE("Salome${pkg}" ${pkg} NO_MODULE TRUE)
466 IF (${pkg_UC}_FOUND OR ${pkg}_FOUND)
467 MESSAGE(STATUS "Found ${pkg} in CONFIG mode!")
470 # Otherwise try the standard way (module mode, with the standard CMake Find*** macro):
471 # We do it quietly to produce our own error message:
472 SALOME_FIND_PACKAGE("Salome${pkg}" ${pkg} MODULE TRUE)
474 # Set the "FOUND" variable for the SALOME wrapper:
475 IF(${pkg_UC}_FOUND OR ${pkg}_FOUND)
476 SET(SALOME${pkg_UC}_FOUND TRUE)
478 SET(SALOME${pkg_UC}_FOUND FALSE)
479 IF(NOT Salome${pkg}_FIND_QUIETLY)
480 IF(Salome${pkg}_FIND_REQUIRED)
481 MESSAGE(FATAL_ERROR "Package ${pkg} couldn't be found - did you set the corresponing root dir correctly? "
482 "It currently contains ${pkg_UC}_ROOT_DIR=${${pkg_UC}_ROOT_DIR}")
484 MESSAGE(WARNING "Package ${pkg} couldn't be found - did you set the corresponing root dir correctly? "
485 "It currently contains ${pkg_UC}_ROOT_DIR=${${pkg_UC}_ROOT_DIR}")
490 IF (${pkg_UC}_FOUND OR ${pkg}_FOUND)
491 ## 3. Set the root dir which was finally retained by going up "upDir" times
492 ## from the given reference path. The variable "referenceVariable" may be a list.
493 ## In this case we take its first element.
495 # First test if the variable exists and is not empty:
496 IF((NOT DEFINED ${referenceVariable}) OR ("${${referenceVariable}}" STREQUAL ""))
497 MESSAGE(WARNING "${pkg}: the reference variable '${referenceVariable}' used when calling the macro "
498 "SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS() does not exist or is empty.")
501 LIST(LENGTH ${referenceVariable} _tmp_len)
503 LIST(GET ${referenceVariable} 0 _tmp_ROOT_DIR)
505 # Note the double de-reference of "referenceVariable":
506 SET(_tmp_ROOT_DIR "${${referenceVariable}}")
509 MATH(EXPR _rge "${upCount}-1")
510 FOREACH(_unused RANGE ${_rge})
511 GET_FILENAME_COMPONENT(_tmp_ROOT_DIR "${_tmp_ROOT_DIR}" PATH)
516 ## 4. Warn if CMake found something not located under ENV(XYZ_ROOT_DIR)
518 IF(DEFINED ENV{${pkg_UC}_ROOT_DIR})
519 SALOME_CHECK_EQUAL_PATHS(_res "${_tmp_ROOT_DIR}" "${_${pkg_UC}_ROOT_DIR_ENV}")
521 MESSAGE(WARNING "${pkg} was found, but not at the path given by the "
522 "environment ${pkg_UC}_ROOT_DIR! Is the variable correctly set? "
523 "The two paths are: ${_tmp_ROOT_DIR} and: ${_${pkg_UC}_ROOT_DIR_ENV}")
526 MESSAGE(STATUS "${pkg} found directory matches what was specified in the ${pkg_UC}_ROOT_DIR variable, all good!")
529 IF(NOT _var_already_there)
530 MESSAGE(STATUS "Variable ${pkg_UC}_ROOT_DIR was not explicitly defined. "
531 "An installation was found anyway: ${_tmp_ROOT_DIR}")
536 ## 5. Conflict detection
537 ## From another prerequisite using the package:
539 IF(${pkg_UC}_ROOT_DIR_EXP)
540 SALOME_CHECK_EQUAL_PATHS(_res "${_tmp_ROOT_DIR}" "${${pkg_UC}_ROOT_DIR_EXP}")
542 MESSAGE(WARNING "Warning: ${pkg}: detected version conflicts with a previously found ${pkg}!"
543 " The two paths are " ${_tmp_ROOT_DIR} " vs " ${${pkg_UC}_ROOT_DIR_EXP})
545 MESSAGE(STATUS "${pkg} directory matches what was previously exposed by another prereq, all good!")
550 ## 6. Save the detected installation
552 SET(${pkg_UC}_ROOT_DIR "${_tmp_ROOT_DIR}")
555 MESSAGE(STATUS "${pkg} was not found.")
558 SET(Salome${pkg}_FOUND "${pkg}_FOUND")
559 ENDMACRO(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS)
562 ####################################################################
563 # SALOME_ADD_MPI_TO_HDF5()
565 # Overload the HDF5 flags so that they also contain MPI references.
566 # This is to be used when HDF5 was compiled with MPI support;
567 MACRO(SALOME_ADD_MPI_TO_HDF5)
568 SET(HDF5_INCLUDE_DIRS ${HDF5_INCLUDE_DIRS} ${MPI_INCLUDE_DIRS})
569 SET(HDF5_DEFINITIONS "${HDF5_DEFINITIONS} ${MPI_DEFINITIONS}")
570 SET(HDF5_LIBRARIES ${HDF5_LIBRARIES} ${MPI_LIBRARIES})
571 ENDMACRO(SALOME_ADD_MPI_TO_HDF5)
573 ####################################################################
576 # Computes hexadecimal version of SALOME package
578 # USAGE: SALOME_XVERSION(package)
582 # package: IN: SALOME package name
584 # The macro reads SALOME package version from PACKAGE_VERSION variable
585 # (note package name in uppercase as assumed for SALOME modules);
586 # hexadecimal version value in form 0xAABBCC (where AA, BB and CC are
587 # major, minor and maintenance components of package version in
588 # hexadecimal form) is put to the PACKAGE_XVERSION variable
589 MACRO(SALOME_XVERSION pkg)
590 STRING(TOUPPER ${pkg} _pkg_UC)
591 IF(${_pkg_UC}_VERSION)
592 EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "import sys; t=sys.argv[-1].split(\".\") ; t[:]=(int(elt) for elt in t) ; sys.stdout.write(\"0x%02x%02x%02x\"%tuple(t))" ${${_pkg_UC}_VERSION}
593 OUTPUT_VARIABLE ${_pkg_UC}_XVERSION)
595 ENDMACRO(SALOME_XVERSION)