ENDIF(NOT SALOME_INSTALL_SCRIPTS_DEF_PERMS)
FOREACH(file ${file_list})
SET(PREFIX "")
- IF(SALOME_INSTALL_SCRIPTS_WORKING_DIRECTORY)
- SET(PREFIX "${SALOME_INSTALL_SCRIPTS_WORKING_DIRECTORY}/")
- ENDIF(SALOME_INSTALL_SCRIPTS_WORKING_DIRECTORY)
+ IF(IS_ABSOLUTE ${file})
+ GET_FILENAME_COMPONENT(file_name ${file} NAME)
+ ELSE()
+ SET(file_name ${file})
+ IF(SALOME_INSTALL_SCRIPTS_WORKING_DIRECTORY)
+ SET(PREFIX "${SALOME_INSTALL_SCRIPTS_WORKING_DIRECTORY}/")
+ ENDIF(SALOME_INSTALL_SCRIPTS_WORKING_DIRECTORY)
+ ENDIF(IS_ABSOLUTE ${file})
INSTALL(FILES ${PREFIX}${file} DESTINATION ${path} PERMISSIONS ${PERMS})
GET_FILENAME_COMPONENT(ext ${file} EXT)
IF(ext STREQUAL .py)
- INSTALL(CODE "MESSAGE(STATUS \"py compiling ${CMAKE_INSTALL_PREFIX}/${path}/${file}\")")
- INSTALL(CODE "SET(CMD \"import py_compile ; py_compile.compile('${CMAKE_INSTALL_PREFIX}/${path}/${file}')\")")
+ INSTALL(CODE "MESSAGE(STATUS \"py compiling ${CMAKE_INSTALL_PREFIX}/${path}/${file_name}\")")
+ INSTALL(CODE "SET(CMD \"import py_compile ; py_compile.compile('${CMAKE_INSTALL_PREFIX}/${path}/${file_name}')\")")
INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c \"\${CMD}\")")
INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -O -c \"\${CMD}\")")
ENDIF(ext STREQUAL .py)
# USAGE: SALOME_CONFIGURE_FILE(in_file out_file [INSTALL dir])
#
# ARGUMENTS:
-# in_file: IN : input file with full paths.
-# out_file: IN : output file with full paths.
+# in_file: IN : input file (if relative path is given, full file path is computed from current source dir).
+# out_file: IN : output file (if relative path is given, full file path is computed from current build dir).
# If INSTALL is specified, then 'out_file' will be installed to the 'dir' directory.
#----------------------------------------------------------------------------
MACRO(SALOME_CONFIGURE_FILE IN_FILE OUT_FILE)
- MESSAGE(STATUS "Creation of ${OUT_FILE}")
- CONFIGURE_FILE(${IN_FILE} ${OUT_FILE} @ONLY)
+ IF(IS_ABSOLUTE ${IN_FILE})
+ SET(_in_file ${IN_FILE})
+ ELSE()
+ SET(_in_file ${CMAKE_CURRENT_SOURCE_DIR}/${IN_FILE})
+ ENDIF()
+ IF(IS_ABSOLUTE ${OUT_FILE})
+ SET(_out_file ${OUT_FILE})
+ ELSE()
+ SET(_out_file ${CMAKE_CURRENT_BINARY_DIR}/${OUT_FILE})
+ ENDIF()
+ MESSAGE(STATUS "Creation of ${_out_file}")
+ CONFIGURE_FILE(${_in_file} ${_out_file} @ONLY)
PARSE_ARGUMENTS(SALOME_CONFIGURE_FILE "INSTALL" "" ${ARGN})
IF(SALOME_CONFIGURE_FILE_INSTALL)
- INSTALL(FILES ${OUT_FILE} DESTINATION ${SALOME_CONFIGURE_FILE_INSTALL})
+ INSTALL(FILES ${_out_file} DESTINATION ${SALOME_CONFIGURE_FILE_INSTALL})
ENDIF(SALOME_CONFIGURE_FILE_INSTALL)
ENDMACRO(SALOME_CONFIGURE_FILE)
# MESSAGE(${${varRes}})
ENDMACRO()
+####
+# SALOME_LOG_OPTIONAL_PACKAGE(pkg flag)
+#
+# Register in global variables the detection status (found or not) of the optional package 'pkg'
+# and the configuration flag that should be turned off to avoid detection of the package.
+# The global variables are read again by SALOME_PACKAGE_REPORT_AND_CHECK to produce
+# a summary report of the detection status and stops the process if necessary.
+MACRO(SALOME_LOG_OPTIONAL_PACKAGE pkg flag)
+ # Was the package found
+ STRING(TOUPPER ${pkg} _pkg_UC)
+ IF(${pkg}_FOUND OR ${_pkg_UC}_FOUND)
+ SET(_isFound TRUE)
+ ELSE()
+ SET(_isFound FALSE)
+ ENDIF()
+
+ # Is the package already in the list? Then update its status:
+ LIST(FIND _SALOME_OPTIONAL_PACKAGES_names ${pkg} _result)
+ IF(NOT ${_result} EQUAL -1)
+ LIST(REMOVE_AT _SALOME_OPTIONAL_PACKAGES_found ${_result})
+ LIST(REMOVE_AT _SALOME_OPTIONAL_PACKAGES_flags ${_result})
+ LIST(INSERT _SALOME_OPTIONAL_PACKAGES_found ${_result} ${_isFound})
+ LIST(INSERT _SALOME_OPTIONAL_PACKAGES_flags ${_result} ${flag})
+ ELSE()
+ # Otherwise insert it
+ LIST(APPEND _SALOME_OPTIONAL_PACKAGES_names ${pkg})
+ LIST(APPEND _SALOME_OPTIONAL_PACKAGES_found ${_isFound})
+ LIST(APPEND _SALOME_OPTIONAL_PACKAGES_flags ${flag})
+ ENDIF()
+
+ENDMACRO(SALOME_LOG_OPTIONAL_PACKAGE)
+
+####
+# SALOME_JUSTIFY_STRING()
+#
+# Justifies the string specified as an argument to the given length
+# adding required number of spaces to the end. Does noting if input
+# string is longer as required length.
+# Puts the result to the output variable.
+#
+# USAGE: SALOME_JUSTIFY_STRING(input length result)
+#
+# ARGUMENTS:
+# input [in] input string
+# length [in] required length of resulting string
+# result [out] name of variable where the result string is put to
+#
+MACRO(SALOME_JUSTIFY_STRING input length result)
+ SET(${result} ${input})
+ STRING(LENGTH ${input} _input_length)
+ MATH(EXPR _nb_spaces "${length}-${_input_length}-1")
+ IF (_nb_spaces GREATER 0)
+ FOREACH(_idx RANGE ${_nb_spaces})
+ SET(${result} "${${result}} ")
+ ENDFOREACH()
+ ENDIF()
+ENDMACRO(SALOME_JUSTIFY_STRING)
+
+####
+# SALOME_PACKAGE_REPORT_AND_CHECK()
+#
+# Print a quick summary of the detection of optional prerequisites.
+# If a package was not found, the configuration is stopped. The summary also indicates
+# which flag should be turned off to skip the detection of the package.
+#
+# If optional JUSTIFY argument is specified, names of packages
+# are left-justified to the given length; default value is 10.
+#
+# USAGE: SALOME_PACKAGE_REPORT_AND_CHECK([JUSTIFY length])
+#
+MACRO(SALOME_PACKAGE_REPORT_AND_CHECK)
+ SET(_will_fail OFF)
+ PARSE_ARGUMENTS(SALOME_PACKAGE_REPORT "JUSTIFY" "" ${ARGN})
+ IF(SALOME_PACKAGE_REPORT_JUSTIFY)
+ SET(_length ${SALOME_PACKAGE_REPORT_JUSTIFY})
+ ELSE()
+ SET(_length 23)
+ ENDIF()
+ MESSAGE(STATUS "")
+ MESSAGE(STATUS " Optional packages - Detection report ")
+ MESSAGE(STATUS " ==================================== ")
+ MESSAGE(STATUS "")
+ IF(DEFINED _SALOME_OPTIONAL_PACKAGES_names)
+ LIST(LENGTH _SALOME_OPTIONAL_PACKAGES_names _list_len)
+ # Another CMake stupidity - FOREACH(... RANGE r) generates r+1 numbers ...
+ MATH(EXPR _range "${_list_len}-1")
+ FOREACH(_idx RANGE ${_range})
+ LIST(GET _SALOME_OPTIONAL_PACKAGES_names ${_idx} _pkg_name)
+ LIST(GET _SALOME_OPTIONAL_PACKAGES_found ${_idx} _pkg_found)
+ LIST(GET _SALOME_OPTIONAL_PACKAGES_flags ${_idx} _pkg_flag)
+ SALOME_JUSTIFY_STRING(${_pkg_name} ${_length} _pkg_name)
+ IF(_pkg_found)
+ SET(_found_msg "Found")
+ SET(_flag_msg "")
+ ELSE()
+ SET(_will_fail ON)
+ SET(_found_msg "NOT Found")
+ SET(_flag_msg " - ${_pkg_flag} can be switched OFF to skip this prerequisite.")
+ ENDIF()
+
+ MESSAGE(STATUS " * ${_pkg_name} -> ${_found_msg}${_flag_msg}")
+ ENDFOREACH()
+ ENDIF(DEFINED _SALOME_OPTIONAL_PACKAGES_names)
+ MESSAGE(STATUS "")
+ MESSAGE(STATUS "")
+
+ # Failure if some packages were missing:
+ IF(_will_fail)
+ MESSAGE(FATAL_ERROR "Some required prerequisites have NOT been found. Take a look at the report above to fix this.")
+ ENDIF()
+ENDMACRO(SALOME_PACKAGE_REPORT_AND_CHECK)
####
# SALOME_FIND_PACKAGE(englobingPackageName standardPackageName modus [onlyTryQuietly])
# given when calling the command FIND_PACKAGE(SalomeXYZ). Those options are stored implicitly in
# CMake variables: xyz__FIND_QUIETLY, xyz_FIND_REQUIRED, etc ...
#
+# If a list of components was specified when invoking the initial FIND_PACKAGE(SalomeXyz ...) this is
+# also handled properly.
+#
# Modus is either MODULE or CONFIG (cf standard FIND_PACKAGE() documentation).
# The last argument is optional and if set to TRUE will force the search to be OPTIONAL and QUIET.
+# If the package is looked for in CONFIG mode, the standard system paths are skipped. If you still want a
+# system installation to be found in this mode, you have to set the ROOT_DIR variable explicitly to /usr (for
+# example).
#
# This macro is to be called from within the FindSalomeXXXX.cmake file.
#
STRING(TOLOWER ${stdPkg} _pkg_lc)
IF(("${mode}" STREQUAL "NO_MODULE") OR ("${mode}" STREQUAL "CONFIG"))
# Hope to find direclty a CMake config file, indicating the SALOME CMake file
- # paths (the command already look in places like "share/cmake", etc ... by default)
+ # paths (the command already looks in places like "share/cmake", etc ... by default)
# Note the options NO_CMAKE_BUILDS_PATH, NO_CMAKE_PACKAGE_REGISTRY to avoid (under Windows)
- # looking into a previous CMake build done via a GUI, or into the Win registry.
+ # looking into a previous CMake build done via a GUI, or into the Win registry.
+ # NO_CMAKE_SYSTEM_PATH and NO_SYSTEM_ENVIRONMENT_PATH ensure any _system_ files like 'xyz-config.cmake'
+ # don't get loaded (typically Boost). To force their loading, set the XYZ_ROOT_DIR variable to '/usr'.
# See documentation of FIND_PACKAGE() for full details.
# Do we need to call the signature using components?
FIND_PACKAGE(${stdPkg} ${${englobPkg}_FIND_VERSION} ${_tmp_exact}
NO_MODULE ${_tmp_quiet} ${_tmp_req} COMPONENTS ${${englobPkg}_FIND_COMPONENTS}
PATH_SUFFIXES "salome_adm/cmake_files" "adm_local/cmake_files"
- NO_CMAKE_BUILDS_PATH NO_CMAKE_PACKAGE_REGISTRY NO_CMAKE_SYSTEM_PACKAGE_REGISTRY)
+ NO_CMAKE_BUILDS_PATH NO_CMAKE_PACKAGE_REGISTRY NO_CMAKE_SYSTEM_PACKAGE_REGISTRY NO_CMAKE_SYSTEM_PATH
+ NO_SYSTEM_ENVIRONMENT_PATH)
ELSE()
FIND_PACKAGE(${stdPkg} ${${englobPkg}_FIND_VERSION} ${_tmp_exact}
NO_MODULE ${_tmp_quiet} ${_tmp_req}
PATH_SUFFIXES "salome_adm/cmake_files" "adm_local/cmake_files"
- NO_CMAKE_BUILDS_PATH NO_CMAKE_PACKAGE_REGISTRY NO_CMAKE_SYSTEM_PACKAGE_REGISTRY)
+ NO_CMAKE_BUILDS_PATH NO_CMAKE_PACKAGE_REGISTRY NO_CMAKE_SYSTEM_PACKAGE_REGISTRY NO_CMAKE_SYSTEM_PATH
+ NO_SYSTEM_ENVIRONMENT_PATH)
ENDIF()
MARK_AS_ADVANCED(${stdPkg}_DIR)
####################################################################
-# SALOME_FIND_PACKAGE_DETECT_CONFLICTS(pkg referenceVariable upCount <component1> <component2> ...)
+# SALOME_FIND_PACKAGE_DETECT_CONFLICTS(pkg referenceVariable upCount)
# pkg : name of the system package to be detected
# referenceVariable: variable containing a path that can be browsed up to
# retrieve the package root directory (xxx_ROOT_DIR)
# upCount : number of times we have to go up from the path <referenceVariable>
# to obtain the package root directory.
-# <component_n> : an optional list of components to be found.
#
# For example: SALOME_FIND_PACKAGE_DETECT_CONFLICTS(SWIG SWIG_EXECUTABLE 2)
#
# Override the variable - don't append to it, as it would give precedence
# to what was stored there before!
SET(CMAKE_PREFIX_PATH "${${pkg_UC}_ROOT_DIR}")
-
+
# Try find_package in config mode. This has the priority, but is
# performed QUIET and not REQUIRED:
SALOME_FIND_PACKAGE("Salome${pkg}" ${pkg} NO_MODULE TRUE)
IF (${pkg_UC}_FOUND OR ${pkg}_FOUND)
- MESSAGE(STATUS "Found ${pkg} in CONFIG mode!")
+ MESSAGE(STATUS "Found ${pkg} in CONFIG mode!")
ENDIF()
# Otherwise try the standard way (module mode, with the standard CMake Find*** macro):
- SALOME_FIND_PACKAGE("Salome${pkg}" ${pkg} MODULE)
+ # We do it quietly to produce our own error message, except if we are in debug mode:
+ IF(SALOME_CMAKE_DEBUG)
+ SALOME_FIND_PACKAGE("Salome${pkg}" ${pkg} MODULE FALSE)
+ ELSE()
+ SALOME_FIND_PACKAGE("Salome${pkg}" ${pkg} MODULE TRUE)
+ ENDIF()
# Set the "FOUND" variable for the SALOME wrapper:
IF(${pkg_UC}_FOUND OR ${pkg}_FOUND)
SET(SALOME${pkg_UC}_FOUND TRUE)
ELSE()
SET(SALOME${pkg_UC}_FOUND FALSE)
+ IF(NOT Salome${pkg}_FIND_QUIETLY)
+ IF(Salome${pkg}_FIND_REQUIRED)
+ MESSAGE(FATAL_ERROR "Package ${pkg} couldn't be found - did you set the corresponing root dir correctly? "
+ "It currently contains ${pkg_UC}_ROOT_DIR=${${pkg_UC}_ROOT_DIR} "
+ "Append -DSALOME_CMAKE_DEBUG=ON on the command line if you want to see the original CMake error.")
+ ELSE()
+ MESSAGE(WARNING "Package ${pkg} couldn't be found - did you set the corresponing root dir correctly? "
+ "It currently contains ${pkg_UC}_ROOT_DIR=${${pkg_UC}_ROOT_DIR} "
+ "Append -DSALOME_CMAKE_DEBUG=ON on the command line if you want to see the original CMake error.")
+ ENDIF()
+ ENDIF()
ENDIF()
IF (${pkg_UC}_FOUND OR ${pkg}_FOUND)
## 3. Set the root dir which was finally retained by going up "upDir" times
## from the given reference path. The variable "referenceVariable" may be a list.
## In this case we take its first element.
+
+ # First test if the variable exists, warn otherwise:
+ IF(NOT DEFINED ${referenceVariable})
+ MESSAGE(WARNING "${pkg}: the reference variable '${referenceVariable}' used when calling the macro "
+ "SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS() is not defined.")
+ ENDIF()
+
LIST(LENGTH ${referenceVariable} _tmp_len)
IF(_tmp_len)
LIST(GET ${referenceVariable} 0 _tmp_ROOT_DIR)
# Note the double de-reference of "referenceVariable":
SET(_tmp_ROOT_DIR "${${referenceVariable}}")
ENDIF()
- IF(${upCount})
- MATH(EXPR _rge "${upCount}-1")
- FOREACH(_unused RANGE ${_rge})
+ IF(${upCount})
+ FOREACH(_unused RANGE 1 ${upCount})
GET_FILENAME_COMPONENT(_tmp_ROOT_DIR "${_tmp_ROOT_DIR}" PATH)
ENDFOREACH()
ENDIF()
SET(Salome${pkg}_FOUND "${pkg}_FOUND")
ENDMACRO(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS)
+
+####################################################################
+# SALOME_ADD_MPI_TO_HDF5()
+#
+# Overload the HDF5 flags so that they also contain MPI references.
+# This is to be used when HDF5 was compiled with MPI support;
+MACRO(SALOME_ADD_MPI_TO_HDF5)
+ SET(HDF5_INCLUDE_DIRS ${HDF5_INCLUDE_DIRS} ${MPI_INCLUDE_DIRS})
+ SET(HDF5_DEFINITIONS "${HDF5_DEFINITIONS} ${MPI_DEFINITIONS}")
+ SET(HDF5_LIBRARIES ${HDF5_LIBRARIES} ${MPI_LIBRARIES})
+ENDMACRO(SALOME_ADD_MPI_TO_HDF5)
+
+####################################################################
+# SALOME_XVERSION()
+#
+# Computes hexadecimal version of SALOME package
+#
+# USAGE: SALOME_XVERSION(package)
+#
+# ARGUMENTS:
+#
+# package: IN: SALOME package name
+#
+# The macro reads SALOME package version from PACKAGE_VERSION variable
+# (note package name in uppercase as assumed for SALOME modules);
+# hexadecimal version value in form 0xAABBCC (where AA, BB and CC are
+# major, minor and maintenance components of package version in
+# hexadecimal form) is put to the PACKAGE_XVERSION variable
+MACRO(SALOME_XVERSION pkg)
+ STRING(TOUPPER ${pkg} _pkg_UC)
+ IF(${_pkg_UC}_VERSION)
+ 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}
+ OUTPUT_VARIABLE ${_pkg_UC}_XVERSION)
+ ENDIF()
+ENDMACRO(SALOME_XVERSION)
+
+#########################################################################
+# SALOME_ACCUMULATE_HEADERS()
+#
+# This macro is called in the various FindSalomeXYZ.cmake modules to accumulate
+# internally the list of include headers to be saved for future export.
+# The full set of include is saved in a variable called
+# _${PROJECT_NAME}_EXTRA_HEADERS
+#
+MACRO(SALOME_ACCUMULATE_HEADERS lst)
+ FOREACH(l IN LISTS ${lst})
+ LIST(FIND _${PROJECT_NAME}_EXTRA_HEADERS "${l}" _res)
+ IF(_res EQUAL "-1")
+ IF(NOT "${l}" STREQUAL "/usr/include")
+ LIST(APPEND _${PROJECT_NAME}_EXTRA_HEADERS "${l}")
+ ENDIF()
+ ENDIF()
+ ENDFOREACH()
+ENDMACRO(SALOME_ACCUMULATE_HEADERS)