1 # Copyright (C) 2012-2016 CEA/DEN, EDF R&D, OPEN CASCADE
\r
3 # This library is free software; you can redistribute it and/or
\r
4 # modify it under the terms of the GNU Lesser General Public
\r
5 # License as published by the Free Software Foundation; either
\r
6 # version 2.1 of the License, or (at your option) any later version.
\r
8 # This library is distributed in the hope that it will be useful,
\r
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\r
11 # Lesser General Public License for more details.
\r
13 # You should have received a copy of the GNU Lesser General Public
\r
14 # License along with this library; if not, write to the Free Software
\r
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\r
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
\r
19 # Author: A.Geay, V. Sandler, A. Bruneton
\r
22 #----------------------------------------------------------------------------
\r
23 # LIST_CONTAINS is a macro useful for determining whether a list has a
\r
25 #----------------------------------------------------------------------------
\r
26 MACRO(LIST_CONTAINS var value)
\r
28 FOREACH(value2 ${ARGN})
\r
29 IF(${value} STREQUAL "${value2}")
\r
31 ENDIF (${value} STREQUAL "${value2}")
\r
33 ENDMACRO(LIST_CONTAINS)
\r
35 #----------------------------------------------------------------------------
\r
36 # The PARSE_ARGUMENTS macro will take the arguments of another macro and
\r
37 # define several variables.
\r
39 # USAGE: PARSE_ARGUMENTS(prefix arg_names options arg1 arg2...)
\r
43 # prefix: IN: a prefix to put on all variables it creates.
\r
45 # arg_names: IN: a list of names.
\r
46 # For each item in arg_names, PARSE_ARGUMENTS will create a
\r
47 # variable with that name, prefixed with prefix_. Each variable will be filled
\r
48 # with the arguments that occur after the given arg_name is encountered
\r
49 # up to the next arg_name or the end of the arguments. All options are
\r
50 # removed from these lists. PARSE_ARGUMENTS also creates a
\r
51 # prefix_DEFAULT_ARGS variable containing the list of all arguments up
\r
52 # to the first arg_name encountered.
\r
54 # options: IN: a list of options.
\r
55 # For each item in options, PARSE_ARGUMENTS will create a
\r
56 # variable with that name, prefixed with prefix_. So, for example, if prefix is
\r
57 # MY_MACRO and options is OPTION1;OPTION2, then PARSE_ARGUMENTS will
\r
58 # create the variables MY_MACRO_OPTION1 and MY_MACRO_OPTION2. These
\r
59 # variables will be set to true if the option exists in the command line
\r
60 # or false otherwise.
\r
61 # arg_names and options lists should be quoted.
\r
63 # The rest of PARSE_ARGUMENTS are arguments from another macro to be parsed.
\r
64 #----------------------------------------------------------------------------
\r
65 MACRO(PARSE_ARGUMENTS prefix arg_names option_names)
\r
67 FOREACH(arg_name ${arg_names})
\r
68 SET(${prefix}_${arg_name})
\r
69 ENDFOREACH(arg_name)
\r
70 FOREACH(option ${option_names})
\r
71 SET(${prefix}_${option} FALSE)
\r
73 SET(current_arg_name DEFAULT_ARGS)
\r
74 SET(current_arg_list)
\r
75 FOREACH(arg ${ARGN})
\r
76 LIST_CONTAINS(is_arg_name ${arg} ${arg_names})
\r
78 SET(${prefix}_${current_arg_name} ${current_arg_list})
\r
79 SET(current_arg_name ${arg})
\r
80 SET(current_arg_list)
\r
82 LIST_CONTAINS(is_option ${arg} ${option_names})
\r
84 SET(${prefix}_${arg} TRUE)
\r
86 SET(current_arg_list ${current_arg_list} ${arg})
\r
90 SET(${prefix}_${current_arg_name} ${current_arg_list})
\r
91 ENDMACRO(PARSE_ARGUMENTS)
\r
93 #----------------------------------------------------------------------------
\r
94 # SALOME_INSTALL_SCRIPTS is a macro useful for installing scripts.
\r
96 # USAGE: SALOME_INSTALL_SCRIPTS(file_list path [WORKING_DIRECTORY dir] [DEF_PERMS] [TARGET_NAME name])
\r
99 # file_list: IN : list of files to be installed. This list should be quoted.
\r
100 # path: IN : full pathname for installing.
\r
102 # By default files to be installed as executable scripts.
\r
103 # If DEF_PERMS option is provided, than permissions for installed files are
\r
104 # only OWNER_WRITE, OWNER_READ, GROUP_READ, and WORLD_READ.
\r
105 # WORKING_DIRECTORY option may be used to specify the relative or absolute
\r
106 # path to the directory containing source files listed in file_list argument.
\r
107 # If TARGET_NAME option is specified, the name of the target being created
\r
108 # with this macro is returned via the given variable.
\r
109 #----------------------------------------------------------------------------
\r
110 MACRO(SALOME_INSTALL_SCRIPTS file_list path)
\r
111 PARSE_ARGUMENTS(SALOME_INSTALL_SCRIPTS "WORKING_DIRECTORY;TARGET_NAME;EXTRA_DPYS" "DEF_PERMS" ${ARGN})
\r
112 SET(PERMS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
\r
113 IF(NOT SALOME_INSTALL_SCRIPTS_DEF_PERMS)
\r
114 SET(PERMS ${PERMS} OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE)
\r
115 ENDIF(NOT SALOME_INSTALL_SCRIPTS_DEF_PERMS)
\r
118 FOREACH(file ${file_list})
\r
120 SET(_source_prefix "")
\r
121 GET_FILENAME_COMPONENT(file_name ${file} NAME)
\r
122 IF(NOT IS_ABSOLUTE ${file})
\r
123 IF(SALOME_INSTALL_SCRIPTS_WORKING_DIRECTORY)
\r
124 SET(PREFIX "${SALOME_INSTALL_SCRIPTS_WORKING_DIRECTORY}/")
\r
125 ENDIF(SALOME_INSTALL_SCRIPTS_WORKING_DIRECTORY)
\r
126 SET(_source_prefix "${CMAKE_CURRENT_SOURCE_DIR}/")
\r
127 ENDIF(NOT IS_ABSOLUTE ${file})
\r
128 INSTALL(FILES ${PREFIX}${file} DESTINATION ${path} PERMISSIONS ${PERMS})
\r
129 GET_FILENAME_COMPONENT(ext ${file} EXT)
\r
130 GET_FILENAME_COMPONENT(we_ext ${file} NAME_WE)
\r
132 IF(ext STREQUAL .py)
\r
133 # Generate and install the pyc and pyo
\r
134 # [ABN] Important: we avoid references or usage of CMAKE_INSTALL_PREFIX which is not correctly set
\r
135 # when using CPack.
\r
136 SET(_pyc_file "${CMAKE_CURRENT_BINARY_DIR}/${we_ext}.cpython-${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}.pyc")
\r
137 SET(_pyo_file "${CMAKE_CURRENT_BINARY_DIR}/${we_ext}.cpython-${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}.opt-1.pyc")
\r
138 LIST(APPEND _all_pyc ${_pyc_file})
\r
139 LIST(APPEND _all_pyo ${_pyo_file})
\r
140 #message("@@@@ '${_source_prefix}${file}' gives '${_pyc_file}' and depends '${PREFIX}${file}'")
\r
141 ADD_CUSTOM_COMMAND(
\r
142 OUTPUT ${_pyc_file} ${_pyo_file}
\r
143 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)"
\r
144 DEPENDS ${PREFIX}${file}
\r
147 # Install the .pyo and the .pyc
\r
148 INSTALL(FILES ${_pyc_file} DESTINATION ${path}/__pycache__ PERMISSIONS ${PERMS})
\r
149 INSTALL(FILES ${_pyo_file} DESTINATION ${path}/__pycache__ PERMISSIONS ${PERMS})
\r
150 ENDIF(ext STREQUAL .py)
\r
152 # get relative path (from CMAKE_SOURCE_DIR to CMAKE_CURRENT_SOURCE_DIR)
\r
153 STRING(REGEX REPLACE ${CMAKE_SOURCE_DIR} "" rel_dir ${CMAKE_CURRENT_SOURCE_DIR})
\r
154 # convert "/" to "_"
\r
156 STRING(REGEX REPLACE "/" "_" unique_name ${rel_dir})
\r
161 ENDFOREACH(file ${file_list})
\r
162 # Generate only one target for all requested Python script compilation.
\r
163 # Make sure that the target name is unique too.
\r
166 WHILE(TARGET "PYCOMPILE${unique_name}_${_cnt}")
\r
167 MATH(EXPR _cnt ${_cnt}+1)
\r
169 SET(_target_name "PYCOMPILE${unique_name}_${_cnt}")
\r
170 ADD_CUSTOM_TARGET(${_target_name} ALL DEPENDS ${_all_pyc} ${_all_pyo})
\r
171 IF(SALOME_INSTALL_SCRIPTS_TARGET_NAME)
\r
172 SET(${SALOME_INSTALL_SCRIPTS_TARGET_NAME} ${_target_name})
\r
173 ENDIF(SALOME_INSTALL_SCRIPTS_TARGET_NAME)
\r
174 IF(SALOME_INSTALL_SCRIPTS_EXTRA_DPYS)
\r
175 ADD_DEPENDENCIES(${_target_name} ${SALOME_INSTALL_SCRIPTS_EXTRA_DPYS})
\r
176 ENDIF(SALOME_INSTALL_SCRIPTS_EXTRA_DPYS)
\r
178 ENDMACRO(SALOME_INSTALL_SCRIPTS)
\r
180 #----------------------------------------------------------------------------
\r
181 # SALOME_CONFIGURE_FILE is a macro useful for copying a file to another location
\r
182 # and modify its contents.
\r
184 # USAGE: SALOME_CONFIGURE_FILE(in_file out_file [INSTALL dir])
\r
187 # in_file: IN : input file (if relative path is given, full file path is computed from current source dir).
\r
188 # out_file: IN : output file (if relative path is given, full file path is computed from current build dir).
\r
189 # If INSTALL is specified, then 'out_file' will be installed to the 'dir' directory.
\r
190 #----------------------------------------------------------------------------
\r
191 MACRO(SALOME_CONFIGURE_FILE IN_FILE OUT_FILE)
\r
192 IF(IS_ABSOLUTE ${IN_FILE})
\r
193 SET(_in_file ${IN_FILE})
\r
195 SET(_in_file ${CMAKE_CURRENT_SOURCE_DIR}/${IN_FILE})
\r
197 IF(IS_ABSOLUTE ${OUT_FILE})
\r
198 SET(_out_file ${OUT_FILE})
\r
200 SET(_out_file ${CMAKE_CURRENT_BINARY_DIR}/${OUT_FILE})
\r
202 MESSAGE(STATUS "Creation of ${_out_file}")
\r
203 CONFIGURE_FILE(${_in_file} ${_out_file} @ONLY)
\r
204 PARSE_ARGUMENTS(SALOME_CONFIGURE_FILE "INSTALL" "" ${ARGN})
\r
205 IF(SALOME_CONFIGURE_FILE_INSTALL)
\r
206 INSTALL(FILES ${_out_file} DESTINATION ${SALOME_CONFIGURE_FILE_INSTALL})
\r
207 ENDIF(SALOME_CONFIGURE_FILE_INSTALL)
\r
208 ENDMACRO(SALOME_CONFIGURE_FILE)
\r
211 #######################################################################################
\r
212 # Useful macros for SALOME own package detection system
\r
216 # SALOME_CHECK_EQUAL_PATHS(result path1 path2)
\r
217 # Check if two paths are identical, resolving links. If the paths do not exist a simple
\r
218 # text comparison is performed.
\r
219 # result is a boolean.
\r
221 MACRO(SALOME_CHECK_EQUAL_PATHS varRes path1 path2)
\r
222 SET("${varRes}" OFF)
\r
223 IF(EXISTS "${path1}")
\r
224 GET_FILENAME_COMPONENT(_tmp1 "${path1}" REALPATH)
\r
226 SET(_tmp1 "${path1}")
\r
229 IF(EXISTS "${path2}")
\r
230 GET_FILENAME_COMPONENT(_tmp2 "${path2}" REALPATH)
\r
232 SET(_tmp2 "${path2}")
\r
235 IF("${_tmp1}" STREQUAL "${_tmp2}")
\r
236 SET("${varRes}" ON)
\r
238 # MESSAGE(${${varRes}})
\r
242 # SALOME_LOG_OPTIONAL_PACKAGE(pkg flag)
\r
244 # Register in global variables the detection status (found or not) of the optional package 'pkg'
\r
245 # and the configuration flag that should be turned off to avoid detection of the package.
\r
246 # The global variables are read again by SALOME_PACKAGE_REPORT_AND_CHECK to produce
\r
247 # a summary report of the detection status and stops the process if necessary.
\r
248 MACRO(SALOME_LOG_OPTIONAL_PACKAGE pkg flag)
\r
249 # Was the package found
\r
250 STRING(TOUPPER ${pkg} _pkg_UC)
\r
251 IF(${pkg}_FOUND OR ${_pkg_UC}_FOUND)
\r
254 SET(_isFound FALSE)
\r
257 # Is the package already in the list? Then update its status:
\r
258 LIST(FIND _SALOME_OPTIONAL_PACKAGES_names ${pkg} _result)
\r
259 IF(NOT ${_result} EQUAL -1)
\r
260 LIST(REMOVE_AT _SALOME_OPTIONAL_PACKAGES_found ${_result})
\r
261 LIST(REMOVE_AT _SALOME_OPTIONAL_PACKAGES_flags ${_result})
\r
262 LIST(INSERT _SALOME_OPTIONAL_PACKAGES_found ${_result} ${_isFound})
\r
263 LIST(INSERT _SALOME_OPTIONAL_PACKAGES_flags ${_result} ${flag})
\r
265 # Otherwise insert it
\r
266 LIST(APPEND _SALOME_OPTIONAL_PACKAGES_names ${pkg})
\r
267 LIST(APPEND _SALOME_OPTIONAL_PACKAGES_found ${_isFound})
\r
268 LIST(APPEND _SALOME_OPTIONAL_PACKAGES_flags ${flag})
\r
271 ENDMACRO(SALOME_LOG_OPTIONAL_PACKAGE)
\r
274 # SALOME_JUSTIFY_STRING()
\r
276 # Justifies the string specified as an argument to the given length
\r
277 # adding required number of spaces to the end. Does noting if input
\r
278 # string is longer as required length.
\r
279 # Puts the result to the output variable.
\r
281 # USAGE: SALOME_JUSTIFY_STRING(input length result)
\r
284 # input [in] input string
\r
285 # length [in] required length of resulting string
\r
286 # result [out] name of variable where the result string is put to
\r
288 MACRO(SALOME_JUSTIFY_STRING input length result)
\r
289 SET(${result} ${input})
\r
290 STRING(LENGTH ${input} _input_length)
\r
291 MATH(EXPR _nb_spaces "${length}-${_input_length}-1")
\r
292 IF (_nb_spaces GREATER 0)
\r
293 FOREACH(_idx RANGE ${_nb_spaces})
\r
294 SET(${result} "${${result}} ")
\r
297 ENDMACRO(SALOME_JUSTIFY_STRING)
\r
300 # SALOME_PACKAGE_REPORT_AND_CHECK()
\r
302 # Print a quick summary of the detection of optional prerequisites.
\r
303 # If a package was not found, the configuration is stopped. The summary also indicates
\r
304 # which flag should be turned off to skip the detection of the package.
\r
306 # If optional JUSTIFY argument is specified, names of packages
\r
307 # are left-justified to the given length; default value is 10.
\r
309 # USAGE: SALOME_PACKAGE_REPORT_AND_CHECK([JUSTIFY length])
\r
311 MACRO(SALOME_PACKAGE_REPORT_AND_CHECK)
\r
312 SET(_will_fail OFF)
\r
313 PARSE_ARGUMENTS(SALOME_PACKAGE_REPORT "JUSTIFY" "" ${ARGN})
\r
314 IF(SALOME_PACKAGE_REPORT_JUSTIFY)
\r
315 SET(_length ${SALOME_PACKAGE_REPORT_JUSTIFY})
\r
319 MESSAGE(STATUS "")
\r
320 MESSAGE(STATUS " Optional packages - Detection report ")
\r
321 MESSAGE(STATUS " ==================================== ")
\r
323 IF(DEFINED _SALOME_OPTIONAL_PACKAGES_names)
\r
324 LIST(LENGTH _SALOME_OPTIONAL_PACKAGES_names _list_len)
\r
325 # Another CMake stupidity - FOREACH(... RANGE r) generates r+1 numbers ...
\r
326 MATH(EXPR _range "${_list_len}-1")
\r
327 FOREACH(_idx RANGE ${_range})
\r
328 LIST(GET _SALOME_OPTIONAL_PACKAGES_names ${_idx} _pkg_name)
\r
329 LIST(GET _SALOME_OPTIONAL_PACKAGES_found ${_idx} _pkg_found)
\r
330 LIST(GET _SALOME_OPTIONAL_PACKAGES_flags ${_idx} _pkg_flag)
\r
331 SALOME_JUSTIFY_STRING(${_pkg_name} ${_length} _pkg_name)
\r
333 SET(_found_msg "Found")
\r
337 SET(_found_msg "NOT Found")
\r
338 SET(_flag_msg " - ${_pkg_flag} can be switched OFF to skip this prerequisite.")
\r
341 MESSAGE(STATUS " * ${_pkg_name} -> ${_found_msg}${_flag_msg}")
\r
343 ENDIF(DEFINED _SALOME_OPTIONAL_PACKAGES_names)
\r
347 # Failure if some packages were missing:
\r
349 MESSAGE(FATAL_ERROR "Some required prerequisites have NOT been found. Take a look at the report above to fix this.")
\r
351 ENDMACRO(SALOME_PACKAGE_REPORT_AND_CHECK)
\r
354 # SALOME_FIND_PACKAGE(englobingPackageName standardPackageName modus [onlyTryQuietly])
\r
356 # example: SALOME_FIND_PACKAGE(SalomeVTK VTK CONFIG)
\r
358 # Encapsulate the call to the standard FIND_PACKAGE(standardPackageName) passing all the options
\r
359 # given when calling the command FIND_PACKAGE(SalomeXYZ). Those options are stored implicitly in
\r
360 # CMake variables: xyz__FIND_QUIETLY, xyz_FIND_REQUIRED, etc ...
\r
362 # If a list of components was specified when invoking the initial FIND_PACKAGE(SalomeXyz ...) this is
\r
363 # also handled properly.
\r
365 # Modus is either MODULE or CONFIG (cf standard FIND_PACKAGE() documentation).
\r
366 # The last argument is optional and if set to TRUE will force the search to be OPTIONAL and QUIET.
\r
367 # If the package is looked for in CONFIG mode, the standard system paths are skipped. If you still want a
\r
368 # system installation to be found in this mode, you have to set the ROOT_DIR variable explicitly to /usr (for
\r
371 # This macro is to be called from within the FindSalomeXXXX.cmake file.
\r
374 MACRO(SALOME_FIND_PACKAGE englobPkg stdPkg mode)
\r
375 SET(_OPT_ARG ${ARGV3})
\r
376 # Only bother if the package was not already found:
\r
377 # Some old packages use the lower case version - standard should be to always use
\r
379 STRING(TOUPPER ${stdPkg} stdPkgUC)
\r
380 IF(NOT (${stdPkg}_FOUND OR ${stdPkgUC}_FOUND))
\r
381 IF(${englobPkg}_FIND_QUIETLY OR _OPT_ARG)
\r
382 SET(_tmp_quiet "QUIET")
\r
386 IF(${englobPkg}_FIND_REQUIRED AND NOT _OPT_ARG)
\r
387 SET(_tmp_req "REQUIRED")
\r
391 IF(${englobPkg}_FIND_VERSION_EXACT)
\r
392 SET(_tmp_exact "EXACT")
\r
397 # Call the CMake FIND_PACKAGE() command:
\r
398 STRING(TOLOWER ${stdPkg} _pkg_lc)
\r
399 IF(("${mode}" STREQUAL "NO_MODULE") OR ("${mode}" STREQUAL "CONFIG"))
\r
400 # Hope to find direclty a CMake config file, indicating the SALOME CMake file
\r
401 # paths (the command already looks in places like "share/cmake", etc ... by default)
\r
402 # Note the options NO_CMAKE_BUILDS_PATH, NO_CMAKE_PACKAGE_REGISTRY to avoid (under Windows)
\r
403 # looking into a previous CMake build done via a GUI, or into the Win registry.
\r
404 # NO_CMAKE_SYSTEM_PATH and NO_SYSTEM_ENVIRONMENT_PATH ensure any _system_ files like 'xyz-config.cmake'
\r
405 # don't get loaded (typically Boost). To force their loading, set the XYZ_ROOT_DIR variable to '/usr'.
\r
406 # See documentation of FIND_PACKAGE() for full details.
\r
408 # Do we need to call the signature using components?
\r
409 IF(${englobPkg}_FIND_COMPONENTS)
\r
410 FIND_PACKAGE(${stdPkg} ${${englobPkg}_FIND_VERSION} ${_tmp_exact}
\r
411 NO_MODULE ${_tmp_quiet} ${_tmp_req} COMPONENTS ${${englobPkg}_FIND_COMPONENTS}
\r
412 PATH_SUFFIXES "salome_adm/cmake_files" "adm_local/cmake_files" "adm/cmake"
\r
413 NO_CMAKE_BUILDS_PATH NO_CMAKE_PACKAGE_REGISTRY NO_CMAKE_SYSTEM_PACKAGE_REGISTRY NO_CMAKE_SYSTEM_PATH
\r
414 NO_SYSTEM_ENVIRONMENT_PATH)
\r
416 FIND_PACKAGE(${stdPkg} ${${englobPkg}_FIND_VERSION} ${_tmp_exact}
\r
417 NO_MODULE ${_tmp_quiet} ${_tmp_req}
\r
418 PATH_SUFFIXES "salome_adm/cmake_files" "adm_local/cmake_files" "adm/cmake"
\r
419 NO_CMAKE_BUILDS_PATH NO_CMAKE_PACKAGE_REGISTRY NO_CMAKE_SYSTEM_PACKAGE_REGISTRY NO_CMAKE_SYSTEM_PATH
\r
420 NO_SYSTEM_ENVIRONMENT_PATH)
\r
422 MARK_AS_ADVANCED(${stdPkg}_DIR)
\r
424 ELSEIF("${mode}" STREQUAL "MODULE")
\r
426 # Do we need to call the signature using components?
\r
427 IF(${englobPkg}_FIND_COMPONENTS)
\r
428 FIND_PACKAGE(${stdPkg} ${${englobPkg}_FIND_VERSION} ${_tmp_exact}
\r
429 MODULE ${_tmp_quiet} ${_tmp_req} COMPONENTS ${${englobPkg}_FIND_COMPONENTS})
\r
431 FIND_PACKAGE(${stdPkg} ${${englobPkg}_FIND_VERSION} ${_tmp_exact}
\r
432 MODULE ${_tmp_quiet} ${_tmp_req})
\r
437 MESSAGE(FATAL_ERROR "Invalid mode argument in the call to the macro SALOME_FIND_PACKAGE. Should be CONFIG or MODULE.")
\r
445 ####################################################################
\r
446 # SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(pkg referenceVariable upCount)
\r
447 # pkg : name of the system package to be detected
\r
448 # referenceVariable: variable containing a path that can be browsed up to
\r
449 # retrieve the package root directory (xxx_ROOT_DIR)
\r
450 # upCount : number of times we have to go up from the path <referenceVariable>
\r
451 # to obtain the package root directory.
\r
452 # If this is a path to a file, going up one time gives the directory containing the file
\r
453 # going up 2 times gives the parent directory.
\r
455 # For example: SALOME_FIND_PACKAGE_DETECT_CONFLICTS(SWIG SWIG_EXECUTABLE 2)
\r
456 # with SWIG_EXECUTABLE set to '/usr/bin/swig'
\r
457 # will produce '/usr'
\r
459 # Generic detection (and conflict check) procedure for package XYZ:
\r
460 # 1. Load a potential env variable XYZ_ROOT_DIR as a default choice for the cache entry XYZ_ROOT_DIR
\r
461 # If empty, load a potential XYZ_ROOT_DIR_EXP as default value (path exposed by another package depending
\r
463 # 2. Invoke FIND_PACKAGE() in this order:
\r
464 # * in CONFIG mode first (if possible): priority is given to a potential
\r
465 # "XYZ-config.cmake" file
\r
466 # * then switch to the standard MODULE mode, appending on CMAKE_PREFIX_PATH
\r
467 # the above XYZ_ROOT_DIR variable
\r
468 # 3. Extract the path actually found into a temp variable _XYZ_TMP_DIR
\r
469 # 4. Warn if XYZ_ROOT_DIR is set and doesn't match what was found (e.g. when CMake found the system installation
\r
470 # instead of what is pointed to by XYZ_ROOT_DIR - happens when a typo in the content of XYZ_ROOT_DIR).
\r
471 # 5. Conflict detection:
\r
472 # * check the temp variable against a potentially existing XYZ_ROOT_DIR_EXP
\r
473 # 6. Finally expose what was *actually* found in XYZ_ROOT_DIR.
\r
474 # 7. Specific stuff: for example exposing a prerequisite of XYZ to the rest of the world for future
\r
475 # conflict detection. This is added after the call to the macro by the callee.
\r
477 MACRO(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS pkg referenceVariable upCount)
\r
479 ## 0. Initialization
\r
481 PARSE_ARGUMENTS(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS "ENVVAR" "" ${ARGN})
\r
483 # Package name, upper case
\r
484 STRING(TOUPPER ${pkg} pkg_UC)
\r
487 ## 1. Load environment or any previously detected root dir for the package
\r
489 SET(_envvar ${pkg_UC}_ROOT_DIR)
\r
490 IF(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS_ENVVAR)
\r
491 SET(_envvar "${SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS_ENVVAR}")
\r
493 IF(DEFINED ENV{${_envvar}})
\r
494 FILE(TO_CMAKE_PATH "$ENV{${_envvar}}" _${pkg_UC}_ROOT_DIR_ENV)
\r
495 SET(_dflt_value "${_${pkg_UC}_ROOT_DIR_ENV}")
\r
497 # will be blank if no package was previously loaded:
\r
498 SET(_dflt_value "${${pkg_UC}_ROOT_DIR_EXP}")
\r
500 # Detect if the variable has been set on the command line or elsewhere:
\r
501 IF(DEFINED ${_envvar})
\r
502 SET(_var_already_there TRUE)
\r
504 SET(_var_already_there FALSE)
\r
506 # Make cache entry
\r
507 SET(${_envvar} "${_dflt_value}" CACHE PATH "Path to ${pkg_UC} directory")
\r
510 ## 2. Find package - try CONFIG mode first (i.e. looking for XYZ-config.cmake)
\r
513 # Override the variable - don't append to it, as it would give precedence
\r
514 # to what was stored there before!
\r
515 IF(DEFINED ${_envvar})
\r
516 SET(CMAKE_PREFIX_PATH "${${_envvar}}")
\r
519 # Try find_package in config mode. This has the priority, but is
\r
520 # performed QUIET and not REQUIRED:
\r
521 SALOME_FIND_PACKAGE("Salome${pkg}" ${pkg} NO_MODULE TRUE)
\r
523 IF (${pkg_UC}_FOUND OR ${pkg}_FOUND)
\r
524 MESSAGE(STATUS "Found ${pkg} in CONFIG mode!")
\r
527 # Otherwise try the standard way (module mode, with the standard CMake Find*** macro):
\r
528 # We do it quietly to produce our own error message, except if we are in debug mode:
\r
529 IF(SALOME_CMAKE_DEBUG)
\r
530 SALOME_FIND_PACKAGE("Salome${pkg}" ${pkg} MODULE FALSE)
\r
532 SALOME_FIND_PACKAGE("Salome${pkg}" ${pkg} MODULE TRUE)
\r
535 # Set the "FOUND" variable for the SALOME wrapper:
\r
536 IF(${pkg_UC}_FOUND OR ${pkg}_FOUND)
\r
537 SET(SALOME${pkg_UC}_FOUND TRUE)
\r
539 SET(SALOME${pkg_UC}_FOUND FALSE)
\r
540 IF(NOT Salome${pkg}_FIND_QUIETLY)
\r
541 IF(Salome${pkg}_FIND_REQUIRED)
\r
542 MESSAGE(FATAL_ERROR "Package ${pkg} couldn't be found - did you set the corresponing root dir correctly? "
\r
543 "It currently contains ${_envvar}=${${_envvar}} "
\r
544 "Append -DSALOME_CMAKE_DEBUG=ON on the command line if you want to see the original CMake error.")
\r
546 MESSAGE(WARNING "Package ${pkg} couldn't be found - did you set the corresponing root dir correctly? "
\r
547 "It currently contains ${_envvar}=${${_envvar}} "
\r
548 "Append -DSALOME_CMAKE_DEBUG=ON on the command line if you want to see the original CMake error.")
\r
553 IF (${pkg_UC}_FOUND OR ${pkg}_FOUND)
\r
554 ## 3. Set the root dir which was finally retained by going up "upDir" times
\r
555 ## from the given reference path. The variable "referenceVariable" may be a list.
\r
556 ## In this case we take its first element.
\r
558 # First test if the variable exists, warn otherwise:
\r
559 IF(NOT DEFINED ${referenceVariable})
\r
560 MESSAGE(WARNING "${pkg}: the reference variable '${referenceVariable}' used when calling the macro "
\r
561 "SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS() is not defined.")
\r
564 LIST(LENGTH ${referenceVariable} _tmp_len)
\r
566 LIST(GET ${referenceVariable} 0 _tmp_ROOT_DIR)
\r
568 # Note the double de-reference of "referenceVariable":
\r
569 SET(_tmp_ROOT_DIR "${${referenceVariable}}")
\r
571 # Up cound can be reset by detection procedure
\r
572 SET(_upCount ${upCount})
\r
573 IF(DEFINED ${pkg_UC}_UPCOUNT)
\r
574 SET(_upCount ${${pkg_UC}_UPCOUNT})
\r
577 FOREACH(_unused RANGE 1 ${_upCount})
\r
578 GET_FILENAME_COMPONENT(_tmp_ROOT_DIR "${_tmp_ROOT_DIR}" PATH)
\r
583 ## 4. Warn if CMake found something not located under ENV(XYZ_ROOT_DIR)
\r
585 IF(DEFINED ENV{${_envvar}})
\r
586 SALOME_CHECK_EQUAL_PATHS(_res "${_tmp_ROOT_DIR}" "${_${pkg_UC}_ROOT_DIR_ENV}")
\r
588 MESSAGE(WARNING "${pkg} was found, but not at the path given by the "
\r
589 "environment ${_envvar}! Is the variable correctly set? "
\r
590 "The two paths are: ${_tmp_ROOT_DIR} and: ${_${pkg_UC}_ROOT_DIR_ENV}")
\r
593 MESSAGE(STATUS "${pkg} found directory matches what was specified in the ${_envvar} variable, all good!")
\r
596 IF(NOT _var_already_there)
\r
597 MESSAGE(STATUS "Variable ${_envvar} was not explicitly defined. "
\r
598 "An installation was found anyway: ${_tmp_ROOT_DIR}")
\r
603 ## 5. Conflict detection
\r
604 ## From another prerequisite using the package:
\r
606 IF(${pkg_UC}_ROOT_DIR_EXP)
\r
607 SALOME_CHECK_EQUAL_PATHS(_res "${_tmp_ROOT_DIR}" "${${pkg_UC}_ROOT_DIR_EXP}")
\r
609 MESSAGE(WARNING "Warning: ${pkg}: detected version conflicts with a previously found ${pkg}!"
\r
610 " The two paths are " ${_tmp_ROOT_DIR} " vs " ${${pkg_UC}_ROOT_DIR_EXP})
\r
612 MESSAGE(STATUS "${pkg} directory matches what was previously exposed by another prereq, all good!")
\r
617 ## 6. Save the detected installation
\r
619 SET(${_envvar} "${_tmp_ROOT_DIR}")
\r
622 MESSAGE(STATUS "${pkg} was not found.")
\r
625 SET(Salome${pkg}_FOUND "${pkg}_FOUND")
\r
626 ENDMACRO(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS)
\r
629 ####################################################################
\r
630 # SALOME_ADD_MPI_TO_HDF5()
\r
632 # Overload the HDF5 flags so that they also contain MPI references.
\r
633 # This is to be used when HDF5 was compiled with MPI support;
\r
634 MACRO(SALOME_ADD_MPI_TO_HDF5)
\r
635 SET(HDF5_INCLUDE_DIRS ${HDF5_INCLUDE_DIRS} ${MPI_INCLUDE_DIRS})
\r
636 SET(HDF5_DEFINITIONS "${HDF5_DEFINITIONS} ${MPI_DEFINITIONS}")
\r
637 SET(HDF5_LIBRARIES ${HDF5_LIBRARIES} ${MPI_LIBRARIES})
\r
638 ENDMACRO(SALOME_ADD_MPI_TO_HDF5)
\r
640 ####################################################################
\r
642 # Convert a number (smaller than 16) into hexadecimal representation
\r
643 # with a leading 0.
\r
644 MACRO(SALOME_TOHEXA num result)
\r
645 SET(_hexa_map a b c d e f)
\r
647 SET(${result} "0${num}")
\r
649 MATH(EXPR _res "${num}-10" )
\r
650 LIST(GET _hexa_map ${_res} _out)
\r
651 SET(${result} "0${_out}")
\r
653 ENDMACRO(SALOME_TOHEXA)
\r
655 ####################################################################
\r
656 # SALOME_XVERSION()
\r
658 # Computes hexadecimal version of SALOME package
\r
660 # USAGE: SALOME_XVERSION(package)
\r
664 # package: IN: SALOME package name
\r
666 # The macro reads SALOME package version from PACKAGE_VERSION variable
\r
667 # (note package name in uppercase as assumed for SALOME modules);
\r
668 # hexadecimal version value in form 0xAABBCC (where AA, BB and CC are
\r
669 # major, minor and maintenance components of package version in
\r
670 # hexadecimal form) is put to the PACKAGE_XVERSION variable
\r
671 MACRO(SALOME_XVERSION pkg)
\r
672 STRING(TOUPPER ${pkg} _pkg_UC)
\r
673 IF(${_pkg_UC}_VERSION)
\r
677 SALOME_TOHEXA(${${_pkg_UC}_MAJOR_VERSION} _major)
\r
678 SALOME_TOHEXA(${${_pkg_UC}_MINOR_VERSION} _minor)
\r
679 SALOME_TOHEXA(${${_pkg_UC}_PATCH_VERSION} _patch)
\r
680 SET(${_pkg_UC}_XVERSION "0x${_major}${_minor}${_patch}")
\r
682 ENDMACRO(SALOME_XVERSION)
\r
685 #########################################################################
\r
686 # SALOME_ACCUMULATE_HEADERS()
\r
688 # This macro is called in the various FindSalomeXYZ.cmake modules to accumulate
\r
689 # internally the list of include headers to be saved for future export.
\r
690 # The full set of include is saved in a variable called
\r
691 # _${PROJECT_NAME}_EXTRA_HEADERS
\r
693 MACRO(SALOME_ACCUMULATE_HEADERS lst)
\r
694 FOREACH(l IN LISTS ${lst})
\r
695 LIST(FIND _${PROJECT_NAME}_EXTRA_HEADERS "${l}" _res)
\r
696 IF(_res EQUAL "-1")
\r
697 IF(NOT "${l}" STREQUAL "/usr/include")
\r
698 LIST(APPEND _${PROJECT_NAME}_EXTRA_HEADERS "${l}")
\r
702 ENDMACRO(SALOME_ACCUMULATE_HEADERS)
\r
704 #########################################################################
\r
705 # SALOME_ACCUMULATE_ENVIRONMENT()
\r
707 # USAGE: SALOME_ACCUMULATE_ENVIRONMENT(envvar value [value ...])
\r
710 # envvar [in] environment variable name, e.g. PATH
\r
711 # value [in] value(s) to be added to environment variable
\r
713 # This macro is called in the various FindSalomeXYZ.cmake modules to
\r
714 # accumulate environment variables, to be used later to run some command
\r
715 # in proper environment.
\r
717 # 1. Each envrironment variable is stored in specific CMake variable
\r
718 # _${PROJECT_NAME}_EXTRA_ENV_<var>, where <var> is name of variable.
\r
719 # 2. Full list of environment variable names is stored in CMake variable
\r
720 # _${PROJECT_NAME}_EXTRA_ENV.
\r
723 # - The arguments list can include optional CHECK or NOCHECK keywords:
\r
724 # * For all arguments following CHECK keyword the macro perform an
\r
725 # additional check (see below); this is the default mode, it is suitable
\r
726 # for path variables (PATH, LD_LIBRARY_PATH, etc).
\r
727 # * For all arguments following NOCHECK keyword, no additional check is
\r
729 # Checking an argument means that we check:
\r
730 # - That the path actually exists
\r
731 # - That this is not a standard system path (starting with "/usr"); this avoids
\r
732 # polluting LD_LIBRARY_PATH or PATH with things like "/usr/lib64" ...
\r
734 MACRO(SALOME_ACCUMULATE_ENVIRONMENT envvar)
\r
736 FOREACH(_item ${ARGN})
\r
737 IF(${_item} STREQUAL "NOCHECK")
\r
739 ELSEIF(${_item} STREQUAL "CHECK")
\r
743 IF(NOT IS_DIRECTORY ${_item})
\r
744 IF(TARGET ${_item})
\r
745 GET_TARGET_PROPERTY(_item ${_item} LOCATION)
\r
747 GET_FILENAME_COMPONENT(_item ${_item} PATH)
\r
749 IF(EXISTS ${_item})
\r
750 STRING(REGEX MATCH "^(/usr|/lib|/bin)" _usr_find ${_item})
\r
751 LIST(FIND _${PROJECT_NAME}_EXTRA_ENV_${envvar} ${_item} _res)
\r
752 IF(NOT _usr_find AND _res EQUAL -1)
\r
753 LIST(APPEND _${PROJECT_NAME}_EXTRA_ENV_${envvar} ${_item})
\r
757 LIST(FIND _${PROJECT_NAME}_EXTRA_ENV_${envvar} ${_item} _res)
\r
759 LIST(APPEND _${PROJECT_NAME}_EXTRA_ENV_${envvar} ${_item})
\r
765 LIST(FIND _${PROJECT_NAME}_EXTRA_ENV ${envvar} _res)
\r
767 LIST(APPEND _${PROJECT_NAME}_EXTRA_ENV ${envvar})
\r
769 SET(_${PROJECT_NAME}_EXTRA_ENV_FULL "SET\(${PROJECT_NAME}_EXTRA_ENV ${_${PROJECT_NAME}_EXTRA_ENV}\)")
\r
770 FOREACH(_res ${_${PROJECT_NAME}_EXTRA_ENV})
\r
771 STRING(REPLACE "${CMAKE_INSTALL_PREFIX}" "\${PACKAGE_PREFIX_DIR}" _res_path "${_${PROJECT_NAME}_EXTRA_ENV_${_res}}")
\r
772 SET(_${PROJECT_NAME}_EXTRA_ENV_FULL "${_${PROJECT_NAME}_EXTRA_ENV_FULL}\nSET\(${PROJECT_NAME}_EXTRA_ENV_${_res} ${_res_path}\)")
\r
774 ENDMACRO(SALOME_ACCUMULATE_ENVIRONMENT)
\r
776 #########################################################################
\r
777 # SALOME_GENERATE_ENVIRONMENT_SCRIPT()
\r
779 # USAGE: SALOME_GENERATE_ENVIRONMENT_SCRIPT(output script cmd opts)
\r
782 # output [out] output command, e.g. for creation of target.
\r
783 # script [in] output environement script name
\r
784 # cmd [in] input command, e.g. sphinx or python command.
\r
785 # opts [in] options for input command (cmd).
\r
787 # This macro is called when it's necessary to use given environment to run some command.
\r
788 # Macro generates environement script using previously created variables
\r
789 # _${PROJECT_NAME}_EXTRA_ENV_<var>, where <var> is name of variable and
\r
790 # _${PROJECT_NAME}_EXTRA_ENV (see marco SALOME_ACCUMULATE_ENVIRONMENT);
\r
791 # and puts generated command in proper environment into <output> argument.
\r
794 # - If <script> is specified as relative path, it is computed from the current build
\r
797 MACRO(SALOME_GENERATE_ENVIRONMENT_SCRIPT output script cmd opts)
\r
798 IF(IS_ABSOLUTE ${script})
\r
799 SET(_script ${script})
\r
801 SET(_script ${CMAKE_CURRENT_BINARY_DIR}/${script})
\r
806 SET(_call_cmd "call")
\r
813 FOREACH(_item ${_${PROJECT_NAME}_EXTRA_ENV})
\r
814 FOREACH(_val ${_${PROJECT_NAME}_EXTRA_ENV_${_item}})
\r
816 IF(${_item} STREQUAL "LD_LIBRARY_PATH")
\r
819 STRING(REPLACE "/" "\\" _env "${_env} @SET ${_item}=${_val};%${_item}%\n")
\r
821 IF(${_item} STREQUAL "LD_LIBRARY_PATH")
\r
822 SET(_env "${_env} export DYLD_LIBRARY_PATH=${_val}:\${DYLD_LIBRARY_PATH}\n")
\r
824 SET(_env "${_env} export ${_item}=${_val}:\${${_item}}\n")
\r
827 SET(_env "${_env} export ${_item}=${_val}:\${${_item}}\n")
\r
832 SET(_script ${_script}.${_ext})
\r
833 FILE(WRITE ${_script} "${_env}")
\r
835 SET(${output} ${_call_cmd} ${_script} && ${cmd} ${opts})
\r
837 ENDMACRO(SALOME_GENERATE_ENVIRONMENT_SCRIPT)
\r
839 #########################################################################
\r
840 # SALOME_GENERATE_TESTS_ENVIRONMENT()
\r
842 # USAGE: SALOME_GENERATE_TESTS_ENVIRONMENT(output)
\r
845 # output [out] output environement variable.
\r
847 # This macro generates <output> variable to use given environment to run some tests.
\r
848 # Macro generates environement variable using previously created variables
\r
849 # _${PROJECT_NAME}_EXTRA_ENV_<var>, where <var> is name of variable and
\r
850 # _${PROJECT_NAME}_EXTRA_ENV (see marco SALOME_ACCUMULATE_ENVIRONMENT);
\r
851 # and puts this variable into <output> argument.
\r
853 MACRO(SALOME_GENERATE_TESTS_ENVIRONMENT output)
\r
855 SET(_WIN_LD_LIBRARY OFF)
\r
856 FOREACH(_item ${_${PROJECT_NAME}_EXTRA_ENV})
\r
857 IF(${_item} STREQUAL "LD_LIBRARY_PATH")
\r
858 SET(_WIN_LD_LIBRARY ON)
\r
861 FOREACH(_val ${_${PROJECT_NAME}_EXTRA_ENV_${_item}})
\r
863 STRING(REPLACE "/" "\\" _val "${_val}")
\r
864 SET(_env_${_item} "${_val};${_env_${_item}}")
\r
866 SET(_env_${_item} "${_val}:${_env_${_item}}")
\r
871 IF(_WIN_LD_LIBRARY AND WIN32)
\r
872 SET(_env_PATH "${_env_PATH}$ENV{LD_LIBRARY_PATH};${_env_LD_LIBRARY_PATH}")
\r
881 FOREACH(_item ${_${PROJECT_NAME}_EXTRA_ENV})
\r
883 IF(NOT ${_item} STREQUAL "LD_LIBRARY_PATH")
\r
884 SET(_env "${_item}=$ENV{${_item}};${_env_${_item}}${sep}${_env}")
\r
887 STRING(REPLACE ";" ":" _iii "$ENV{${_item}}")
\r
888 SET(_env "${_item}=${_iii}:${_env_${_item}}${sep}${_env}")
\r
892 # Get module name as substring of "Salome<ModuleName>"
\r
893 STRING(REGEX MATCH "^Salome" _is_salome_project ${PROJECT_NAME})
\r
894 IF(_is_salome_project)
\r
895 STRING(SUBSTRING "${PROJECT_NAME}" 6 -1 PRNAME)
\r
897 SET(PRNAME ${PROJECT_NAME})
\r
899 SET(_env "${PRNAME}_ROOT_DIR=${CMAKE_INSTALL_PREFIX}${sep}${_env}")
\r
901 # Creating follow string for Windows environement:
\r
902 # "VAR1_ENV=1\;2\;3\;...\;...\;...;VAR2_ENV=1\;2\;3\;...\;...\;...;VAR3_ENV=1\;2\;3\;...\;...\;...;..."
\r
904 STRING(REGEX REPLACE "\\\\*;" "\\\\;" _env "${_env}")
\r
905 STRING(REGEX REPLACE "\\\\*;*," ";" _env "${_env}")
\r
908 SET(${output} "${_env}")
\r
910 ENDMACRO(SALOME_GENERATE_TESTS_ENVIRONMENT)
\r
912 #########################################################################
\r
913 # SALOME_APPEND_LIST_OF_LIST()
\r
915 # USAGE: SALOME_APPEND_LIST_OF_LIST(result element_list)
\r
917 # Build a list of lists. The element_list is first parsed to convert it
\r
923 # It is then added to the big list 'result'. Hence 'result' looks like:
\r
924 # a,b,c,d,e;f,g,h; ...
\r
926 MACRO(SALOME_APPEND_LIST_OF_LIST result element_list)
\r
928 STRING(REPLACE ";" "," _tmp_res "${${element_list}}")
\r
930 # Yet another CMake stupidity - LIST(LENGTH ";" var) returns 0
\r
931 STRING(LENGTH result _list_len)
\r
932 IF(NOT _list_len EQUAL 0)
\r
933 SET(${result} "${${result}}${_tmp_res};") # LIST(APPEND ...) doesn't handle well empty elements!?
\r
935 SET(${result} "${_tmp_res};") # to avoid redundant ';' at the beginning of the list
\r
938 ENDMACRO(SALOME_APPEND_LIST_OF_LIST)
\r
940 #########################################################################
\r
941 # SALOME_CONFIGURE_PREPARE()
\r
943 # USAGE: SALOME_CONFIGURE_PREPARE(pkg1 pkg2 ...)
\r
945 # Prepare the variable that will be used to configure the file Salome<MODULE>Config.cmake,
\r
947 # - _PREREQ_LIST : the list of level 1 external prerequisites
\r
948 # - _PREREQ_DIR_LIST : their corresponding CMake directories (i.e. where the CMake configuration
\r
949 # file for this package can be found, if there is any!)
\r
950 # - _PREREQ_COMPO_LIST: the list of components requested when this package was invoked
\r
952 # All this information is built from the package_list, the list of level 1 packages for this module.
\r
953 # Only the packages found in CONFIG mode are retained.
\r
955 MACRO(SALOME_CONFIGURE_PREPARE)
\r
956 SET(_tmp_prereq "${ARGV}")
\r
958 SET(_PREREQ_DIR_LIST)
\r
959 SET(_PREREQ_COMPO_LIST)
\r
960 FOREACH(_prereq IN LISTS _tmp_prereq)
\r
962 SET(_PREREQ_LIST "${_PREREQ_LIST} ${_prereq}")
\r
963 FILE(TO_CMAKE_PATH ${${_prereq}_DIR} CURR_DIR)
\r
964 SET(_PREREQ_DIR_LIST "${_PREREQ_DIR_LIST} \"${CURR_DIR}\"")
\r
965 SALOME_APPEND_LIST_OF_LIST(_PREREQ_COMPO_LIST Salome${_prereq}_COMPONENTS)
\r
968 ENDMACRO(SALOME_CONFIGURE_PREPARE)
\r
970 #######################################################################
\r
972 # From a version string like "2.7.12+" extract the major, minor and patch number
\r
973 # taking ONLY the numerical part.
\r
974 # This macro was created to treat Ubuntu Python version number where the libs are
\r
975 # version 2.7.12+ and the interp is 2.7.12 ...
\r
977 MACRO(SALOME_EXTRACT_VERSION version_string major minor patch)
\r
978 IF(${version_string} MATCHES "[0-9]+[^0-9]*\\.[0-9]+[^0-9]*\\.*[0-9]*[^0-9]*")
\r
979 STRING(REGEX REPLACE "^([0-9]+)[^0-9]*\\.[0-9]+[^0-9]*\\.*[0-9]*[^0-9]*" "\\1" ${major} "${version_string}")
\r
980 STRING(REGEX REPLACE "^[0-9]+[^0-9]*\\.([0-9]+)[^0-9]*\\.*[0-9]*[^0-9]*" "\\1" ${minor} "${version_string}")
\r
982 IF(${version_string} MATCHES "[0-9]+[^0-9]*\\.[0-9]+[^0-9]*\\.[0-9]+[^0-9]*")
\r
983 # X.Y.Z format (python 3.5.2 ...)
\r
984 STRING(REGEX REPLACE "^[0-9]+[^0-9]*\\.[0-9]+[^0-9]*\\.([0-9]+)[^0-9]*" "\\1" ${patch} "${version_string}")
\r
986 # X.Y format (python 3.5 ...)
\r
990 MESSAGE("MACRO(SALOME_EXTRACT_VERSION ${version_string} ${major} ${minor} ${patch}")
\r
991 MESSAGE(FATAL_ERROR "Problem parsing version string, I can't parse it properly.")
\r
993 ENDMACRO(SALOME_EXTRACT_VERSION)
\r
995 #######################################################################
\r
997 # This macro checks that swig files were generated.
\r
998 # It is requared under Windows platform, because sometimes under Windows platform
\r
999 # the genetarion of the swig wrappings tooks long time. And seems swig opens
\r
1000 # file at the begining of generation process and after that swig
\r
1001 # begins the generation of the content. In its turn Microsoft Visual Studio
\r
1002 # tryes to compile file immediately after creation and as a result compilation breaks.
\r
1003 MACRO(SWIG_CHECK_GENERATION swig_module)
\r
1008 ( (call ) >> @SWIG_GEN_FILE_NAME@ ) 2>null && (
\r
1009 echo The file @SWIG_GEN_FILE_NAME@ was created. & goto :eof
\r
1011 echo The file @SWIG_GEN_FILE_NAME@ is still being created !!! & goto :check
\r
1014 LIST(LENGTH swig_generated_sources NB_GEN_FILES)
\r
1015 IF(${NB_GEN_FILES})
\r
1016 LIST(GET swig_generated_sources 0 SWIG_GEN_FILE_NAME)
\r
1017 STRING(CONFIGURE ${SCRIPT} SCRIPT)
\r
1018 GET_FILENAME_COMPONENT(SWIG_GEN_FILE_NAME_DIR ${SWIG_GEN_FILE_NAME} DIRECTORY)
\r
1019 GET_FILENAME_COMPONENT(SWIG_GEN_FILE_NAME_WE ${SWIG_GEN_FILE_NAME} NAME_WE)
\r
1020 SET(SCRIPT_FILE_NAME ${SWIG_GEN_FILE_NAME_DIR}/${SWIG_GEN_FILE_NAME_WE}.bat)
\r
1021 FILE(WRITE ${SCRIPT_FILE_NAME} ${SCRIPT})
\r
1022 ADD_CUSTOM_TARGET(${SWIG_MODULE_${swig_module}_REAL_NAME}_ready
\r
1023 DEPENDS ${SWIG_GEN_FILE_NAME}
\r
1024 COMMAND ${SCRIPT_FILE_NAME}
\r
1025 COMMENT "Waiting for swig wrappings !!!")
\r
1026 ADD_DEPENDENCIES(${SWIG_MODULE_${swig_module}_REAL_NAME} ${SWIG_MODULE_${swig_module}_REAL_NAME}_ready)
\r
1028 MESSAGE(FATAL "swig sources for targer ${swig_module} are not found !!!")
\r
1031 ENDMACRO(SWIG_CHECK_GENERATION)
\r