1 # Copyright (C) 2012-2023 CEA, EDF, 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, or (at your option) any later version.
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] [TARGET_NAME name])
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 # WORKING_DIRECTORY option may be used to specify the relative or absolute
106 # path to the directory containing source files listed in file_list argument.
107 # If TARGET_NAME option is specified, the name of the target being created
108 # with this macro is returned via the given variable.
109 #----------------------------------------------------------------------------
110 MACRO(SALOME_INSTALL_SCRIPTS file_list path)
111 PARSE_ARGUMENTS(SALOME_INSTALL_SCRIPTS "WORKING_DIRECTORY;TARGET_NAME" "DEF_PERMS" ${ARGN})
112 SET(PERMS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
113 IF(NOT SALOME_INSTALL_SCRIPTS_DEF_PERMS)
114 SET(PERMS ${PERMS} OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE)
115 ENDIF(NOT SALOME_INSTALL_SCRIPTS_DEF_PERMS)
118 FOREACH(file ${file_list})
120 SET(_source_prefix "")
121 GET_FILENAME_COMPONENT(file_name ${file} NAME)
122 IF(NOT IS_ABSOLUTE ${file})
123 IF(SALOME_INSTALL_SCRIPTS_WORKING_DIRECTORY)
124 SET(PREFIX "${SALOME_INSTALL_SCRIPTS_WORKING_DIRECTORY}/")
125 ENDIF(SALOME_INSTALL_SCRIPTS_WORKING_DIRECTORY)
126 SET(_source_prefix "${CMAKE_CURRENT_SOURCE_DIR}/")
127 ENDIF(NOT IS_ABSOLUTE ${file})
128 INSTALL(FILES ${PREFIX}${file} DESTINATION ${path} PERMISSIONS ${PERMS})
129 GET_FILENAME_COMPONENT(ext ${file} EXT)
130 GET_FILENAME_COMPONENT(we_ext ${file} NAME_WE)
133 # Generate and install the pyc and pyo
134 # [ABN] Important: we avoid references or usage of CMAKE_INSTALL_PREFIX which is not correctly set
136 SET(_pyc_file "${CMAKE_CURRENT_BINARY_DIR}/${we_ext}.cpython-${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}.pyc")
137 SET(_pyo_file "${CMAKE_CURRENT_BINARY_DIR}/${we_ext}.cpython-${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}.opt-1.pyc")
138 LIST(APPEND _all_pyc ${_pyc_file})
139 LIST(APPEND _all_pyo ${_pyo_file})
141 OUTPUT ${_pyc_file} ${_pyo_file}
142 COMMAND ${PYTHON_EXECUTABLE} -c "from py_compile import compile; compile('${_source_prefix}${file}', '${_pyc_file}', doraise=True, optimize=0); compile('${_source_prefix}${file}', '${_pyo_file}', doraise=True, optimize=1)"
143 DEPENDS ${PREFIX}${file}
146 # Install the .pyo and the .pyc
147 INSTALL(FILES ${_pyc_file} DESTINATION ${path}/__pycache__ PERMISSIONS ${PERMS})
148 INSTALL(FILES ${_pyo_file} DESTINATION ${path}/__pycache__ PERMISSIONS ${PERMS})
149 ENDIF(ext STREQUAL .py)
151 # get relative path (from CMAKE_SOURCE_DIR to CMAKE_CURRENT_SOURCE_DIR)
152 STRING(REGEX REPLACE ${CMAKE_SOURCE_DIR} "" rel_dir ${CMAKE_CURRENT_SOURCE_DIR})
155 STRING(REGEX REPLACE "/" "_" unique_name ${rel_dir})
160 ENDFOREACH(file ${file_list})
161 # Generate only one target for all requested Python script compilation.
162 # Make sure that the target name is unique too.
165 WHILE(TARGET "PYCOMPILE${unique_name}_${_cnt}")
166 MATH(EXPR _cnt ${_cnt}+1)
168 SET(_target_name "PYCOMPILE${unique_name}_${_cnt}")
169 ADD_CUSTOM_TARGET(${_target_name} ALL DEPENDS ${_all_pyc} ${_all_pyo})
170 IF(SALOME_INSTALL_SCRIPTS_TARGET_NAME)
171 SET(${SALOME_INSTALL_SCRIPTS_TARGET_NAME} ${_target_name})
172 ENDIF(SALOME_INSTALL_SCRIPTS_TARGET_NAME)
174 ENDMACRO(SALOME_INSTALL_SCRIPTS)
176 #----------------------------------------------------------------------------
177 # SALOME_CONFIGURE_FILE is a macro useful for copying a file to another location
178 # and modify its contents.
180 # USAGE: SALOME_CONFIGURE_FILE(in_file out_file [INSTALL dir])
183 # in_file: IN : input file (if relative path is given, full file path is computed from current source dir).
184 # out_file: IN : output file (if relative path is given, full file path is computed from current build dir).
185 # If INSTALL is specified, then 'out_file' will be installed to the 'dir' directory.
186 #----------------------------------------------------------------------------
187 MACRO(SALOME_CONFIGURE_FILE IN_FILE OUT_FILE)
188 IF(IS_ABSOLUTE ${IN_FILE})
189 SET(_in_file ${IN_FILE})
191 SET(_in_file ${CMAKE_CURRENT_SOURCE_DIR}/${IN_FILE})
193 IF(IS_ABSOLUTE ${OUT_FILE})
194 SET(_out_file ${OUT_FILE})
196 SET(_out_file ${CMAKE_CURRENT_BINARY_DIR}/${OUT_FILE})
198 MESSAGE(STATUS "Creation of ${_out_file}")
199 CONFIGURE_FILE(${_in_file} ${_out_file} @ONLY)
200 PARSE_ARGUMENTS(SALOME_CONFIGURE_FILE "INSTALL" "" ${ARGN})
201 IF(SALOME_CONFIGURE_FILE_INSTALL)
202 INSTALL(FILES ${_out_file} DESTINATION ${SALOME_CONFIGURE_FILE_INSTALL})
203 ENDIF(SALOME_CONFIGURE_FILE_INSTALL)
204 ENDMACRO(SALOME_CONFIGURE_FILE)
207 #######################################################################################
208 # Useful macros for SALOME own package detection system
212 # SALOME_CHECK_EQUAL_PATHS(result path1 path2)
213 # Check if two paths are identical, resolving links. If the paths do not exist a simple
214 # text comparison is performed.
215 # result is a boolean.
217 MACRO(SALOME_CHECK_EQUAL_PATHS varRes path1 path2)
219 IF(EXISTS "${path1}")
220 GET_FILENAME_COMPONENT(_tmp1 "${path1}" REALPATH)
222 SET(_tmp1 "${path1}")
225 IF(EXISTS "${path2}")
226 GET_FILENAME_COMPONENT(_tmp2 "${path2}" REALPATH)
228 SET(_tmp2 "${path2}")
231 IF("${_tmp1}" STREQUAL "${_tmp2}")
234 # MESSAGE(${${varRes}})
238 # SALOME_LOG_OPTIONAL_PACKAGE(pkg flag)
240 # Register in global variables the detection status (found or not) of the optional package 'pkg'
241 # and the configuration flag that should be turned off to avoid detection of the package.
242 # The global variables are read again by SALOME_PACKAGE_REPORT_AND_CHECK to produce
243 # a summary report of the detection status and stops the process if necessary.
244 MACRO(SALOME_LOG_OPTIONAL_PACKAGE pkg flag)
245 # Was the package found
246 STRING(TOUPPER ${pkg} _pkg_UC)
247 IF(${pkg}_FOUND OR ${_pkg_UC}_FOUND)
253 # Is the package already in the list? Then update its status:
254 LIST(FIND _SALOME_OPTIONAL_PACKAGES_names ${pkg} _result)
255 IF(NOT ${_result} EQUAL -1)
256 LIST(REMOVE_AT _SALOME_OPTIONAL_PACKAGES_found ${_result})
257 LIST(REMOVE_AT _SALOME_OPTIONAL_PACKAGES_flags ${_result})
258 LIST(INSERT _SALOME_OPTIONAL_PACKAGES_found ${_result} ${_isFound})
259 LIST(INSERT _SALOME_OPTIONAL_PACKAGES_flags ${_result} ${flag})
261 # Otherwise insert it
262 LIST(APPEND _SALOME_OPTIONAL_PACKAGES_names ${pkg})
263 LIST(APPEND _SALOME_OPTIONAL_PACKAGES_found ${_isFound})
264 LIST(APPEND _SALOME_OPTIONAL_PACKAGES_flags ${flag})
267 ENDMACRO(SALOME_LOG_OPTIONAL_PACKAGE)
270 # SALOME_JUSTIFY_STRING()
272 # Justifies the string specified as an argument to the given length
273 # adding required number of spaces to the end. Does noting if input
274 # string is longer as required length.
275 # Puts the result to the output variable.
277 # USAGE: SALOME_JUSTIFY_STRING(input length result)
280 # input [in] input string
281 # length [in] required length of resulting string
282 # result [out] name of variable where the result string is put to
284 MACRO(SALOME_JUSTIFY_STRING input length result)
285 SET(${result} ${input})
286 STRING(LENGTH ${input} _input_length)
287 MATH(EXPR _nb_spaces "${length}-${_input_length}-1")
288 IF (_nb_spaces GREATER 0)
289 FOREACH(_idx RANGE ${_nb_spaces})
290 SET(${result} "${${result}} ")
293 ENDMACRO(SALOME_JUSTIFY_STRING)
296 # SALOME_PACKAGE_REPORT_AND_CHECK()
298 # Print a quick summary of the detection of optional prerequisites.
299 # If a package was not found, the configuration is stopped. The summary also indicates
300 # which flag should be turned off to skip the detection of the package.
302 # If optional JUSTIFY argument is specified, names of packages
303 # are left-justified to the given length; default value is 10.
305 # USAGE: SALOME_PACKAGE_REPORT_AND_CHECK([JUSTIFY length])
307 MACRO(SALOME_PACKAGE_REPORT_AND_CHECK)
309 PARSE_ARGUMENTS(SALOME_PACKAGE_REPORT "JUSTIFY" "" ${ARGN})
310 IF(SALOME_PACKAGE_REPORT_JUSTIFY)
311 SET(_length ${SALOME_PACKAGE_REPORT_JUSTIFY})
316 MESSAGE(STATUS " Optional packages - Detection report ")
317 MESSAGE(STATUS " ==================================== ")
319 IF(DEFINED _SALOME_OPTIONAL_PACKAGES_names)
320 LIST(LENGTH _SALOME_OPTIONAL_PACKAGES_names _list_len)
321 # Another CMake stupidity - FOREACH(... RANGE r) generates r+1 numbers ...
322 MATH(EXPR _range "${_list_len}-1")
323 FOREACH(_idx RANGE ${_range})
324 LIST(GET _SALOME_OPTIONAL_PACKAGES_names ${_idx} _pkg_name)
325 LIST(GET _SALOME_OPTIONAL_PACKAGES_found ${_idx} _pkg_found)
326 LIST(GET _SALOME_OPTIONAL_PACKAGES_flags ${_idx} _pkg_flag)
327 SALOME_JUSTIFY_STRING(${_pkg_name} ${_length} _pkg_name)
329 SET(_found_msg "Found")
333 SET(_found_msg "NOT Found")
334 SET(_flag_msg " - ${_pkg_flag} can be switched OFF to skip this prerequisite.")
337 MESSAGE(STATUS " * ${_pkg_name} -> ${_found_msg}${_flag_msg}")
339 ENDIF(DEFINED _SALOME_OPTIONAL_PACKAGES_names)
343 # Failure if some packages were missing:
345 MESSAGE(FATAL_ERROR "Some required prerequisites have NOT been found. Take a look at the report above to fix this.")
347 ENDMACRO(SALOME_PACKAGE_REPORT_AND_CHECK)
350 # SALOME_FIND_PACKAGE(englobingPackageName standardPackageName modus [onlyTryQuietly])
352 # example: SALOME_FIND_PACKAGE(SalomeVTK VTK CONFIG)
354 # Encapsulate the call to the standard FIND_PACKAGE(standardPackageName) passing all the options
355 # given when calling the command FIND_PACKAGE(SalomeXYZ). Those options are stored implicitly in
356 # CMake variables: xyz__FIND_QUIETLY, xyz_FIND_REQUIRED, etc ...
358 # If a list of components was specified when invoking the initial FIND_PACKAGE(SalomeXyz ...) this is
359 # also handled properly.
361 # Modus is either MODULE or CONFIG (cf standard FIND_PACKAGE() documentation).
362 # The last argument is optional and if set to TRUE will force the search to be OPTIONAL and QUIET.
363 # If the package is looked for in CONFIG mode, the standard system paths are skipped. If you still want a
364 # system installation to be found in this mode, you have to set the ROOT_DIR variable explicitly to /usr (for
367 # This macro is to be called from within the FindSalomeXXXX.cmake file.
370 MACRO(SALOME_FIND_PACKAGE englobPkg stdPkg mode)
371 SET(_OPT_ARG ${ARGV3})
372 # Only bother if the package was not already found:
373 # Some old packages use the lower case version - standard should be to always use
375 STRING(TOUPPER ${stdPkg} stdPkgUC)
376 IF(NOT (${stdPkg}_FOUND OR ${stdPkgUC}_FOUND))
377 IF(${englobPkg}_FIND_QUIETLY OR _OPT_ARG)
378 SET(_tmp_quiet "QUIET")
382 IF(${englobPkg}_FIND_REQUIRED AND NOT _OPT_ARG)
383 SET(_tmp_req "REQUIRED")
387 IF(${englobPkg}_FIND_VERSION_EXACT)
388 SET(_tmp_exact "EXACT")
393 # Call the CMake FIND_PACKAGE() command:
394 STRING(TOLOWER ${stdPkg} _pkg_lc)
395 IF(("${mode}" STREQUAL "NO_MODULE") OR ("${mode}" STREQUAL "CONFIG"))
396 # Hope to find direclty a CMake config file, indicating the SALOME CMake file
397 # paths (the command already looks in places like "share/cmake", etc ... by default)
398 # Note the options NO_CMAKE_BUILDS_PATH, NO_CMAKE_PACKAGE_REGISTRY to avoid (under Windows)
399 # looking into a previous CMake build done via a GUI, or into the Win registry.
400 # NO_CMAKE_SYSTEM_PATH and NO_SYSTEM_ENVIRONMENT_PATH ensure any _system_ files like 'xyz-config.cmake'
401 # don't get loaded (typically Boost). To force their loading, set the XYZ_ROOT_DIR variable to '/usr'.
402 # See documentation of FIND_PACKAGE() for full details.
404 # Do we need to call the signature using components?
405 IF(${englobPkg}_FIND_COMPONENTS)
406 FIND_PACKAGE(${stdPkg} ${${englobPkg}_FIND_VERSION} ${_tmp_exact}
407 NO_MODULE ${_tmp_quiet} ${_tmp_req} COMPONENTS ${${englobPkg}_FIND_COMPONENTS}
408 PATH_SUFFIXES "salome_adm/cmake_files" "adm_local/cmake_files" "adm/cmake"
409 NO_CMAKE_BUILDS_PATH NO_CMAKE_PACKAGE_REGISTRY NO_CMAKE_SYSTEM_PACKAGE_REGISTRY NO_CMAKE_SYSTEM_PATH
410 NO_SYSTEM_ENVIRONMENT_PATH)
412 FIND_PACKAGE(${stdPkg} ${${englobPkg}_FIND_VERSION} ${_tmp_exact}
413 NO_MODULE ${_tmp_quiet} ${_tmp_req}
414 PATH_SUFFIXES "salome_adm/cmake_files" "adm_local/cmake_files" "adm/cmake"
415 NO_CMAKE_BUILDS_PATH NO_CMAKE_PACKAGE_REGISTRY NO_CMAKE_SYSTEM_PACKAGE_REGISTRY NO_CMAKE_SYSTEM_PATH
416 NO_SYSTEM_ENVIRONMENT_PATH)
418 MARK_AS_ADVANCED(${stdPkg}_DIR)
420 ELSEIF("${mode}" STREQUAL "MODULE")
422 # Do we need to call the signature using components?
423 IF(${englobPkg}_FIND_COMPONENTS)
424 FIND_PACKAGE(${stdPkg} ${${englobPkg}_FIND_VERSION} ${_tmp_exact}
425 MODULE ${_tmp_quiet} ${_tmp_req} COMPONENTS ${${englobPkg}_FIND_COMPONENTS})
427 FIND_PACKAGE(${stdPkg} ${${englobPkg}_FIND_VERSION} ${_tmp_exact}
428 MODULE ${_tmp_quiet} ${_tmp_req})
433 MESSAGE(FATAL_ERROR "Invalid mode argument in the call to the macro SALOME_FIND_PACKAGE. Should be CONFIG or MODULE.")
441 ####################################################################
442 # SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(pkg referenceVariable upCount)
443 # pkg : name of the system package to be detected
444 # referenceVariable: variable containing a path that can be browsed up to
445 # retrieve the package root directory (xxx_ROOT_DIR)
446 # upCount : number of times we have to go up from the path <referenceVariable>
447 # to obtain the package root directory.
448 # If this is a path to a file, going up one time gives the directory containing the file
449 # going up 2 times gives the parent directory.
451 # For example: SALOME_FIND_PACKAGE_DETECT_CONFLICTS(SWIG SWIG_EXECUTABLE 2)
452 # with SWIG_EXECUTABLE set to '/usr/bin/swig'
453 # will produce '/usr'
455 # Generic detection (and conflict check) procedure for package XYZ:
456 # 1. Load a potential env variable XYZ_ROOT_DIR as a default choice for the cache entry XYZ_ROOT_DIR
457 # If empty, load a potential XYZ_ROOT_DIR_EXP as default value (path exposed by another package depending
459 # 2. Invoke FIND_PACKAGE() in this order:
460 # * in CONFIG mode first (if possible): priority is given to a potential
461 # "XYZ-config.cmake" file
462 # * then switch to the standard MODULE mode, appending on CMAKE_PREFIX_PATH
463 # the above XYZ_ROOT_DIR variable
464 # 3. Extract the path actually found into a temp variable _XYZ_TMP_DIR
465 # 4. Warn if XYZ_ROOT_DIR is set and doesn't match what was found (e.g. when CMake found the system installation
466 # instead of what is pointed to by XYZ_ROOT_DIR - happens when a typo in the content of XYZ_ROOT_DIR).
467 # 5. Conflict detection:
468 # * check the temp variable against a potentially existing XYZ_ROOT_DIR_EXP
469 # 6. Finally expose what was *actually* found in XYZ_ROOT_DIR.
470 # 7. Specific stuff: for example exposing a prerequisite of XYZ to the rest of the world for future
471 # conflict detection. This is added after the call to the macro by the callee.
473 MACRO(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS pkg referenceVariable upCount)
477 PARSE_ARGUMENTS(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS "ENVVAR" "" ${ARGN})
479 # Package name, upper case
480 STRING(TOUPPER ${pkg} pkg_UC)
483 ## 1. Load environment or any previously detected root dir for the package
485 SET(_envvar ${pkg_UC}_ROOT_DIR)
486 IF(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS_ENVVAR)
487 SET(_envvar "${SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS_ENVVAR}")
489 IF(DEFINED ENV{${_envvar}})
490 FILE(TO_CMAKE_PATH "$ENV{${_envvar}}" _${pkg_UC}_ROOT_DIR_ENV)
491 SET(_dflt_value "${_${pkg_UC}_ROOT_DIR_ENV}")
493 # will be blank if no package was previously loaded:
494 SET(_dflt_value "${${pkg_UC}_ROOT_DIR_EXP}")
496 # Detect if the variable has been set on the command line or elsewhere:
497 IF(DEFINED ${_envvar})
498 SET(_var_already_there TRUE)
500 SET(_var_already_there FALSE)
503 SET(${_envvar} "${_dflt_value}" CACHE PATH "Path to ${pkg_UC} directory")
506 ## 2. Find package - try CONFIG mode first (i.e. looking for XYZ-config.cmake)
509 # Override the variable - don't append to it, as it would give precedence
510 # to what was stored there before!
511 IF(DEFINED ${_envvar})
512 SET(CMAKE_PREFIX_PATH "${${_envvar}}")
515 # Try find_package in config mode. This has the priority, but is
516 # performed QUIET and not REQUIRED:
517 SALOME_FIND_PACKAGE("Salome${pkg}" ${pkg} NO_MODULE TRUE)
519 IF (${pkg_UC}_FOUND OR ${pkg}_FOUND)
520 MESSAGE(STATUS "Found ${pkg} in CONFIG mode!")
523 # Otherwise try the standard way (module mode, with the standard CMake Find*** macro):
524 # We do it quietly to produce our own error message, except if we are in debug mode:
525 IF(SALOME_CMAKE_DEBUG)
526 SALOME_FIND_PACKAGE("Salome${pkg}" ${pkg} MODULE FALSE)
528 SALOME_FIND_PACKAGE("Salome${pkg}" ${pkg} MODULE TRUE)
531 # Set the "FOUND" variable for the SALOME wrapper:
532 IF(${pkg_UC}_FOUND OR ${pkg}_FOUND)
533 SET(SALOME${pkg_UC}_FOUND TRUE)
535 SET(SALOME${pkg_UC}_FOUND FALSE)
536 IF(NOT Salome${pkg}_FIND_QUIETLY)
537 IF(Salome${pkg}_FIND_REQUIRED)
538 MESSAGE(FATAL_ERROR "Package ${pkg} couldn't be found - did you set the corresponing root dir correctly? "
539 "It currently contains ${_envvar}=${${_envvar}} "
540 "Append -DSALOME_CMAKE_DEBUG=ON on the command line if you want to see the original CMake error.")
542 MESSAGE(WARNING "Package ${pkg} couldn't be found - did you set the corresponing root dir correctly? "
543 "It currently contains ${_envvar}=${${_envvar}} "
544 "Append -DSALOME_CMAKE_DEBUG=ON on the command line if you want to see the original CMake error.")
549 IF (${pkg_UC}_FOUND OR ${pkg}_FOUND)
550 ## 3. Set the root dir which was finally retained by going up "upDir" times
551 ## from the given reference path. The variable "referenceVariable" may be a list.
552 ## In this case we take its first element.
554 # First test if the variable exists, warn otherwise:
555 IF(NOT DEFINED ${referenceVariable})
556 MESSAGE(WARNING "${pkg}: the reference variable '${referenceVariable}' used when calling the macro "
557 "SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS() is not defined.")
560 LIST(LENGTH ${referenceVariable} _tmp_len)
562 LIST(GET ${referenceVariable} 0 _tmp_ROOT_DIR)
564 # Note the double de-reference of "referenceVariable":
565 SET(_tmp_ROOT_DIR "${${referenceVariable}}")
567 # Up cound can be reset by detection procedure
568 SET(_upCount ${upCount})
569 IF(DEFINED ${pkg_UC}_UPCOUNT)
570 SET(_upCount ${${pkg_UC}_UPCOUNT})
573 FOREACH(_unused RANGE 1 ${_upCount})
574 GET_FILENAME_COMPONENT(_tmp_ROOT_DIR "${_tmp_ROOT_DIR}" PATH)
579 ## 4. Warn if CMake found something not located under ENV(XYZ_ROOT_DIR)
581 IF(DEFINED ENV{${_envvar}})
582 SALOME_CHECK_EQUAL_PATHS(_res "${_tmp_ROOT_DIR}" "${_${pkg_UC}_ROOT_DIR_ENV}")
584 MESSAGE(WARNING "${pkg} was found, but not at the path given by the "
585 "environment ${_envvar}! Is the variable correctly set? "
586 "The two paths are: ${_tmp_ROOT_DIR} and: ${_${pkg_UC}_ROOT_DIR_ENV}")
589 MESSAGE(STATUS "${pkg} found directory matches what was specified in the ${_envvar} variable, all good!")
592 IF(NOT _var_already_there)
593 MESSAGE(STATUS "Variable ${_envvar} was not explicitly defined. "
594 "An installation was found anyway: ${_tmp_ROOT_DIR}")
599 ## 5. Conflict detection
600 ## From another prerequisite using the package:
602 IF(${pkg_UC}_ROOT_DIR_EXP)
603 SALOME_CHECK_EQUAL_PATHS(_res "${_tmp_ROOT_DIR}" "${${pkg_UC}_ROOT_DIR_EXP}")
605 MESSAGE(WARNING "Warning: ${pkg}: detected version conflicts with a previously found ${pkg}!"
606 " The two paths are " ${_tmp_ROOT_DIR} " vs " ${${pkg_UC}_ROOT_DIR_EXP})
608 MESSAGE(STATUS "${pkg} directory matches what was previously exposed by another prereq, all good!")
613 ## 6. Save the detected installation
615 SET(${_envvar} "${_tmp_ROOT_DIR}")
618 MESSAGE(STATUS "${pkg} was not found.")
621 SET(Salome${pkg}_FOUND "${pkg}_FOUND")
622 ENDMACRO(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS)
625 ####################################################################
626 # SALOME_ADD_MPI_TO_HDF5()
628 # Overload the HDF5 flags so that they also contain MPI references.
629 # This is to be used when HDF5 was compiled with MPI support;
630 MACRO(SALOME_ADD_MPI_TO_HDF5)
631 SET(HDF5_INCLUDE_DIRS ${HDF5_INCLUDE_DIRS} ${MPI_INCLUDE_DIRS})
632 SET(HDF5_DEFINITIONS "${HDF5_DEFINITIONS} ${MPI_DEFINITIONS}")
633 SET(HDF5_LIBRARIES ${HDF5_LIBRARIES} ${MPI_LIBRARIES})
634 ENDMACRO(SALOME_ADD_MPI_TO_HDF5)
636 ####################################################################
638 # Convert a number (smaller than 16) into hexadecimal representation
640 MACRO(SALOME_TOHEXA num result)
641 SET(_hexa_map a b c d e f)
643 SET(${result} "0${num}")
645 MATH(EXPR _res "${num}-10" )
646 LIST(GET _hexa_map ${_res} _out)
647 SET(${result} "0${_out}")
649 ENDMACRO(SALOME_TOHEXA)
651 ####################################################################
654 # Computes hexadecimal version of SALOME package
656 # USAGE: SALOME_XVERSION(package)
660 # package: IN: SALOME package name
662 # The macro reads SALOME package version from PACKAGE_VERSION variable
663 # (note package name in uppercase as assumed for SALOME modules);
664 # hexadecimal version value in form 0xAABBCC (where AA, BB and CC are
665 # major, minor and maintenance components of package version in
666 # hexadecimal form) is put to the PACKAGE_XVERSION variable
667 MACRO(SALOME_XVERSION pkg)
668 STRING(TOUPPER ${pkg} _pkg_UC)
669 IF(${_pkg_UC}_VERSION)
673 SALOME_TOHEXA(${${_pkg_UC}_MAJOR_VERSION} _major)
674 SALOME_TOHEXA(${${_pkg_UC}_MINOR_VERSION} _minor)
675 SALOME_TOHEXA(${${_pkg_UC}_PATCH_VERSION} _patch)
676 SET(${_pkg_UC}_XVERSION "0x${_major}${_minor}${_patch}")
678 ENDMACRO(SALOME_XVERSION)
681 #########################################################################
682 # SALOME_ACCUMULATE_HEADERS()
684 # This macro is called in the various FindSalomeXYZ.cmake modules to accumulate
685 # internally the list of include headers to be saved for future export.
686 # The full set of include is saved in a variable called
687 # _${PROJECT_NAME}_EXTRA_HEADERS
689 MACRO(SALOME_ACCUMULATE_HEADERS lst)
690 FOREACH(l IN LISTS ${lst})
691 LIST(FIND _${PROJECT_NAME}_EXTRA_HEADERS "${l}" _res)
693 IF(NOT "${l}" STREQUAL "/usr/include")
694 LIST(APPEND _${PROJECT_NAME}_EXTRA_HEADERS "${l}")
698 ENDMACRO(SALOME_ACCUMULATE_HEADERS)
700 #########################################################################
701 # SALOME_ACCUMULATE_ENVIRONMENT()
703 # USAGE: SALOME_ACCUMULATE_ENVIRONMENT(envvar value [value ...])
706 # envvar [in] environment variable name, e.g. PATH
707 # value [in] value(s) to be added to environment variable
709 # This macro is called in the various FindSalomeXYZ.cmake modules to
710 # accumulate environment variables, to be used later to run some command
711 # in proper environment.
713 # 1. Each envrironment variable is stored in specific CMake variable
714 # _${PROJECT_NAME}_EXTRA_ENV_<var>, where <var> is name of variable.
715 # 2. Full list of environment variable names is stored in CMake variable
716 # _${PROJECT_NAME}_EXTRA_ENV.
719 # - The arguments list can include optional CHECK or NOCHECK keywords:
720 # * For all arguments following CHECK keyword the macro perform an
721 # additional check (see below); this is the default mode, it is suitable
722 # for path variables (PATH, LD_LIBRARY_PATH, etc).
723 # * For all arguments following NOCHECK keyword, no additional check is
725 # Checking an argument means that we check:
726 # - That the path actually exists
727 # - That this is not a standard system path (starting with "/usr"); this avoids
728 # polluting LD_LIBRARY_PATH or PATH with things like "/usr/lib64" ...
730 MACRO(SALOME_ACCUMULATE_ENVIRONMENT envvar)
732 FOREACH(_item ${ARGN})
733 IF(${_item} STREQUAL "NOCHECK")
735 ELSEIF(${_item} STREQUAL "CHECK")
739 IF(NOT IS_DIRECTORY ${_item})
741 GET_TARGET_PROPERTY(_item ${_item} LOCATION)
743 GET_FILENAME_COMPONENT(_item ${_item} PATH)
746 STRING(REGEX MATCH "^(/usr|/lib|/bin)" _usr_find ${_item})
747 LIST(FIND _${PROJECT_NAME}_EXTRA_ENV_${envvar} ${_item} _res)
748 IF(NOT _usr_find AND _res EQUAL -1)
749 LIST(APPEND _${PROJECT_NAME}_EXTRA_ENV_${envvar} ${_item})
753 LIST(FIND _${PROJECT_NAME}_EXTRA_ENV_${envvar} ${_item} _res)
755 LIST(APPEND _${PROJECT_NAME}_EXTRA_ENV_${envvar} ${_item})
761 LIST(FIND _${PROJECT_NAME}_EXTRA_ENV ${envvar} _res)
763 LIST(APPEND _${PROJECT_NAME}_EXTRA_ENV ${envvar})
765 SET(_${PROJECT_NAME}_EXTRA_ENV_FULL "SET\(${PROJECT_NAME}_EXTRA_ENV ${_${PROJECT_NAME}_EXTRA_ENV}\)")
766 FOREACH(_res ${_${PROJECT_NAME}_EXTRA_ENV})
767 STRING(REPLACE "${CMAKE_INSTALL_PREFIX}" "\${PACKAGE_PREFIX_DIR}" _res_path "${_${PROJECT_NAME}_EXTRA_ENV_${_res}}")
768 SET(_${PROJECT_NAME}_EXTRA_ENV_FULL "${_${PROJECT_NAME}_EXTRA_ENV_FULL}\nSET\(${PROJECT_NAME}_EXTRA_ENV_${_res} ${_res_path}\)")
770 ENDMACRO(SALOME_ACCUMULATE_ENVIRONMENT)
772 #########################################################################
773 # SALOME_GENERATE_ENVIRONMENT_SCRIPT()
775 # USAGE: SALOME_GENERATE_ENVIRONMENT_SCRIPT(output script cmd opts)
778 # output [out] output command, e.g. for creation of target.
779 # script [in] output environement script name
780 # cmd [in] input command, e.g. sphinx or python command.
781 # opts [in] options for input command (cmd).
783 # This macro is called when it's necessary to use given environment to run some command.
784 # Macro generates environement script using previously created variables
785 # _${PROJECT_NAME}_EXTRA_ENV_<var>, where <var> is name of variable and
786 # _${PROJECT_NAME}_EXTRA_ENV (see marco SALOME_ACCUMULATE_ENVIRONMENT);
787 # and puts generated command in proper environment into <output> argument.
790 # - If <script> is specified as relative path, it is computed from the current build
793 MACRO(SALOME_GENERATE_ENVIRONMENT_SCRIPT output script cmd opts)
794 IF(IS_ABSOLUTE ${script})
795 SET(_script ${script})
797 SET(_script ${CMAKE_CURRENT_BINARY_DIR}/${script})
802 SET(_call_cmd "call")
809 FOREACH(_item ${_${PROJECT_NAME}_EXTRA_ENV})
810 FOREACH(_val ${_${PROJECT_NAME}_EXTRA_ENV_${_item}})
812 IF(${_item} STREQUAL "LD_LIBRARY_PATH")
815 STRING(REPLACE "/" "\\" _env "${_env} @SET ${_item}=${_val};%${_item}%\n")
817 IF(${_item} STREQUAL "LD_LIBRARY_PATH")
818 SET(_env "${_env} export DYLD_LIBRARY_PATH=${_val}:\${DYLD_LIBRARY_PATH}\n")
820 SET(_env "${_env} export ${_item}=${_val}:\${${_item}}\n")
823 SET(_env "${_env} export ${_item}=${_val}:\${${_item}}\n")
828 SET(_script ${_script}.${_ext})
829 FILE(WRITE ${_script} "${_env}")
831 SET(${output} ${_call_cmd} ${_script} && ${cmd} ${opts})
833 ENDMACRO(SALOME_GENERATE_ENVIRONMENT_SCRIPT)
835 #########################################################################
836 # SALOME_GENERATE_TESTS_ENVIRONMENT()
838 # USAGE: SALOME_GENERATE_TESTS_ENVIRONMENT(output)
841 # output [out] output environement variable.
843 # This macro generates <output> variable to use given environment to run some tests.
844 # Macro generates environement variable using previously created variables
845 # _${PROJECT_NAME}_EXTRA_ENV_<var>, where <var> is name of variable and
846 # _${PROJECT_NAME}_EXTRA_ENV (see marco SALOME_ACCUMULATE_ENVIRONMENT);
847 # and puts this variable into <output> argument.
849 MACRO(SALOME_GENERATE_TESTS_ENVIRONMENT output)
851 SET(_WIN_LD_LIBRARY OFF)
852 FOREACH(_item ${_${PROJECT_NAME}_EXTRA_ENV})
853 IF(${_item} STREQUAL "LD_LIBRARY_PATH")
854 SET(_WIN_LD_LIBRARY ON)
857 FOREACH(_val ${_${PROJECT_NAME}_EXTRA_ENV_${_item}})
859 STRING(REPLACE "/" "\\" _val "${_val}")
860 SET(_env_${_item} "${_val};${_env_${_item}}")
862 SET(_env_${_item} "${_val}:${_env_${_item}}")
867 IF(_WIN_LD_LIBRARY AND WIN32)
868 SET(_env_PATH "${_env_PATH}$ENV{LD_LIBRARY_PATH};${_env_LD_LIBRARY_PATH}")
877 FOREACH(_item ${_${PROJECT_NAME}_EXTRA_ENV})
879 IF(NOT ${_item} STREQUAL "LD_LIBRARY_PATH")
880 SET(_env "${_item}=$ENV{${_item}};${_env_${_item}}${sep}${_env}")
883 STRING(REPLACE ";" ":" _iii "$ENV{${_item}}")
884 SET(_env "${_item}=${_iii}:${_env_${_item}}${sep}${_env}")
888 # Get module name as substring of "Salome<ModuleName>"
889 STRING(REGEX MATCH "^Salome" _is_salome_project ${PROJECT_NAME})
890 IF(_is_salome_project)
891 STRING(SUBSTRING "${PROJECT_NAME}" 6 -1 PRNAME)
893 SET(PRNAME ${PROJECT_NAME})
895 SET(_env "${PRNAME}_ROOT_DIR=${CMAKE_INSTALL_PREFIX}${sep}${_env}")
897 # Creating follow string for Windows environement:
898 # "VAR1_ENV=1\;2\;3\;...\;...\;...;VAR2_ENV=1\;2\;3\;...\;...\;...;VAR3_ENV=1\;2\;3\;...\;...\;...;..."
900 STRING(REGEX REPLACE "\\\\*;" "\\\\;" _env "${_env}")
901 STRING(REGEX REPLACE "\\\\*;*," ";" _env "${_env}")
904 SET(${output} "${_env}")
906 ENDMACRO(SALOME_GENERATE_TESTS_ENVIRONMENT)
908 #########################################################################
909 # SALOME_APPEND_LIST_OF_LIST()
911 # USAGE: SALOME_APPEND_LIST_OF_LIST(result element_list)
913 # Build a list of lists. The element_list is first parsed to convert it
919 # It is then added to the big list 'result'. Hence 'result' looks like:
920 # a,b,c,d,e;f,g,h; ...
922 MACRO(SALOME_APPEND_LIST_OF_LIST result element_list)
924 STRING(REPLACE ";" "," _tmp_res "${${element_list}}")
926 # Yet another CMake stupidity - LIST(LENGTH ";" var) returns 0
927 STRING(LENGTH result _list_len)
928 IF(NOT _list_len EQUAL 0)
929 SET(${result} "${${result}}${_tmp_res};") # LIST(APPEND ...) doesn't handle well empty elements!?
931 SET(${result} "${_tmp_res};") # to avoid redundant ';' at the beginning of the list
934 ENDMACRO(SALOME_APPEND_LIST_OF_LIST)
936 #########################################################################
937 # SALOME_CONFIGURE_PREPARE()
939 # USAGE: SALOME_CONFIGURE_PREPARE(pkg1 pkg2 ...)
941 # Prepare the variable that will be used to configure the file Salome<MODULE>Config.cmake,
943 # - _PREREQ_LIST : the list of level 1 external prerequisites
944 # - _PREREQ_DIR_LIST : their corresponding CMake directories (i.e. where the CMake configuration
945 # file for this package can be found, if there is any!)
946 # - _PREREQ_COMPO_LIST: the list of components requested when this package was invoked
948 # All this information is built from the package_list, the list of level 1 packages for this module.
949 # Only the packages found in CONFIG mode are retained.
951 MACRO(SALOME_CONFIGURE_PREPARE)
952 SET(_tmp_prereq "${ARGV}")
954 SET(_PREREQ_DIR_LIST)
955 SET(_PREREQ_COMPO_LIST)
956 FOREACH(_prereq IN LISTS _tmp_prereq)
958 SET(_PREREQ_LIST "${_PREREQ_LIST} ${_prereq}")
959 FILE(TO_CMAKE_PATH ${${_prereq}_DIR} CURR_DIR)
960 SET(_PREREQ_DIR_LIST "${_PREREQ_DIR_LIST} \"${CURR_DIR}\"")
961 SALOME_APPEND_LIST_OF_LIST(_PREREQ_COMPO_LIST Salome${_prereq}_COMPONENTS)
964 ENDMACRO(SALOME_CONFIGURE_PREPARE)
966 #######################################################################
968 # From a version string like "2.7.12+" extract the major, minor and patch number
969 # taking ONLY the numerical part.
970 # This macro was created to treat Ubuntu Python version number where the libs are
971 # version 2.7.12+ and the interp is 2.7.12 ...
973 MACRO(SALOME_EXTRACT_VERSION version_string major minor patch)
974 IF(${version_string} MATCHES "[0-9]+[^0-9]*\\.[0-9]+[^0-9]*\\.*[0-9]*[^0-9]*")
975 STRING(REGEX REPLACE "^([0-9]+)[^0-9]*\\.[0-9]+[^0-9]*\\.*[0-9]*[^0-9]*" "\\1" ${major} "${version_string}")
976 STRING(REGEX REPLACE "^[0-9]+[^0-9]*\\.([0-9]+)[^0-9]*\\.*[0-9]*[^0-9]*" "\\1" ${minor} "${version_string}")
978 IF(${version_string} MATCHES "[0-9]+[^0-9]*\\.[0-9]+[^0-9]*\\.[0-9]+[^0-9]*")
979 # X.Y.Z format (python 3.5.2 ...)
980 STRING(REGEX REPLACE "^[0-9]+[^0-9]*\\.[0-9]+[^0-9]*\\.([0-9]+)[^0-9]*" "\\1" ${patch} "${version_string}")
982 # X.Y format (python 3.5 ...)
986 MESSAGE("MACRO(SALOME_EXTRACT_VERSION ${version_string} ${major} ${minor} ${patch}")
987 MESSAGE(FATAL_ERROR "Problem parsing version string, I can't parse it properly.")
989 ENDMACRO(SALOME_EXTRACT_VERSION)
991 #######################################################################
993 # This macro checks that swig files were generated.
994 # It is requared under Windows platform, because sometimes under Windows platform
995 # the genetarion of the swig wrappings tooks long time. And seems swig opens
996 # file at the begining of generation process and after that swig
997 # begins the generation of the content. In its turn Microsoft Visual Studio
998 # tryes to compile file immediately after creation and as a result compilation breaks.
999 MACRO(SWIG_CHECK_GENERATION swig_module)
1004 ( (call ) >> @SWIG_GEN_FILE_NAME@ ) 2>null && (
1005 echo The file @SWIG_GEN_FILE_NAME@ was created. & goto :eof
1007 echo The file @SWIG_GEN_FILE_NAME@ is still being created !!! & goto :check
1010 LIST(LENGTH swig_generated_sources NB_GEN_FILES)
1012 LIST(GET swig_generated_sources 0 SWIG_GEN_FILE_NAME)
1013 STRING(CONFIGURE ${SCRIPT} SCRIPT)
1014 GET_FILENAME_COMPONENT(SWIG_GEN_FILE_NAME_DIR ${SWIG_GEN_FILE_NAME} DIRECTORY)
1015 GET_FILENAME_COMPONENT(SWIG_GEN_FILE_NAME_WE ${SWIG_GEN_FILE_NAME} NAME_WE)
1016 SET(SCRIPT_FILE_NAME ${SWIG_GEN_FILE_NAME_DIR}/${SWIG_GEN_FILE_NAME_WE}.bat)
1017 FILE(WRITE ${SCRIPT_FILE_NAME} ${SCRIPT})
1018 ADD_CUSTOM_TARGET(${SWIG_MODULE_${swig_module}_REAL_NAME}_ready
1019 DEPENDS ${SWIG_GEN_FILE_NAME}
1020 COMMAND ${SCRIPT_FILE_NAME}
1021 COMMENT "Waiting for swig wrappings !!!")
1022 ADD_DEPENDENCIES(${SWIG_MODULE_${swig_module}_REAL_NAME} ${SWIG_MODULE_${swig_module}_REAL_NAME}_ready)
1024 MESSAGE(FATAL "swig sources for targer ${swig_module} are not found !!!")
1027 ENDMACRO(SWIG_CHECK_GENERATION)
1029 #########################################################################
1030 # SALOME_SETUP_VERSION()
1032 # USAGE: SALOME_SETUP_VERSION(version [DEVELOPMENT])
1035 # version [in] Version decriptor (string).
1038 # DEVELOPMENT Forces setting development flag.
1040 # The macro sets the following variables:
1041 # - PROJECTNAME_MAJOR_VERSION - major version number
1042 # - PROJECTNAME_MINOR_VERSION - minor version number
1043 # - PROJECTNAME_PATCH_VERSION - release version number
1044 # - PROJECTNAME_VERSION - full qualified version
1045 # - PROJECTNAME_VERSION_DEV - development flag (0 value for released version)
1046 # - PROJECTNAME_XVERSION - hexadecimal representation of version
1047 # - PROJECTNAME_GIT_SHA1 - git commit's sha1
1049 FUNCTION(SALOME_SETUP_VERSION version)
1051 PARSE_ARGUMENTS(SALOME_SETUP_VERSION "" "DEVELOPMENT" ${ARGN})
1052 # project name in upper case (if not set in master CMakeLists.txt)
1053 STRING(TOUPPER ${PROJECT_NAME} _pkg_uc)
1054 # parse version component
1055 STRING(REGEX MATCHALL "[^.]" _components "${version}")
1056 LIST(LENGTH _components _length)
1057 IF(${_length} GREATER 0)
1058 LIST(GET _components 0 _major)
1059 LIST(REMOVE_AT _components 0)
1063 LIST(LENGTH _components _length)
1064 IF(${_length} GREATER 0)
1065 LIST(GET _components 0 _minor)
1066 LIST(REMOVE_AT _components 0)
1070 LIST(LENGTH _components _length)
1071 IF(${_length} GREATER 0)
1072 LIST(GET _components 0 _patch)
1073 LIST(REMOVE_AT _components 0)
1077 # set project version: 'major', 'minor' and 'patch' components
1078 SET(${_pkg_uc}_MAJOR_VERSION ${_major} PARENT_SCOPE)
1079 SET(${_pkg_uc}_MINOR_VERSION ${_minor} PARENT_SCOPE)
1080 SET(${_pkg_uc}_PATCH_VERSION ${_patch} PARENT_SCOPE)
1081 SET(${_pkg_uc}_VERSION ${_major}.${_minor}.${_patch} PARENT_SCOPE)
1082 # set 'development' flag
1083 IF(SALOME_SETUP_VERSION_DEVELOPMENT)
1084 SET(${_pkg_uc}_VERSION_DEV 1 PARENT_SCOPE)
1086 SET(${_pkg_uc}_VERSION_DEV 0 PARENT_SCOPE)
1088 # set hexa representation of version
1089 SALOME_TOHEXA(${_major} _major_h)
1090 SALOME_TOHEXA(${_minor} _minor_h)
1091 SALOME_TOHEXA(${_patch} _patch_h)
1092 SET(${_pkg_uc}_XVERSION "0x${_major_h}${_minor_h}${_patch_h}" PARENT_SCOPE)
1094 EXECUTE_PROCESS(COMMAND git describe --dirty --tags --match=V* --always
1095 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
1096 OUTPUT_VARIABLE _git_version
1098 OUTPUT_STRIP_TRAILING_WHITESPACE)
1100 SET(${_pkg_uc}_GIT_SHA1 "${_git_version}" PARENT_SCOPE)
1102 SET(${_pkg_uc}_GIT_SHA1 "unknown" PARENT_SCOPE)