From 70fa940d14e859a7bcdd2c3471bdd24a69ac9566 Mon Sep 17 00:00:00 2001 From: Gbkng Date: Tue, 18 Jun 2024 00:22:38 +0200 Subject: [PATCH] make CONFIGURATION/cmake of Salome an internal cmake/ folder, with only what's needed --- CMakeLists.txt | 12 +- cmake/FindCppUnit.cmake | 112 +++ cmake/FindMEDFile.cmake | 72 ++ cmake/FindSalomeCppUnit.cmake | 33 + cmake/FindSalomeDoxygen.cmake | 44 + cmake/FindSalomeGraphviz.cmake | 33 + cmake/FindSalomeHDF5.cmake | 121 +++ cmake/FindSalomeLibXml2.cmake | 42 + cmake/FindSalomeMEDFile.cmake | 59 ++ cmake/FindSalomeMPI.cmake | 48 ++ cmake/FindSalomeMetis.cmake | 33 + cmake/FindSalomeNumPySciPy.cmake | 52 ++ cmake/FindSalomePTScotch.cmake | 33 + cmake/FindSalomePythonInterp.cmake | 53 ++ cmake/FindSalomePythonLibs.cmake | 73 ++ cmake/FindSalomeSWIG.cmake | 39 + cmake/FindSalomeScotch.cmake | 33 + cmake/FindSalomeSphinx.cmake | 46 ++ cmake/FindSalomeXDR.cmake | 33 + cmake/FindXDR.cmake | 49 ++ cmake/SalomeMacros.cmake | 1226 ++++++++++++++++++++++++++++ cmake/SalomeSetupPlatform.cmake | 157 ++++ cmake/UseSphinx.cmake | 149 ++++ 23 files changed, 2544 insertions(+), 8 deletions(-) create mode 100644 cmake/FindCppUnit.cmake create mode 100644 cmake/FindMEDFile.cmake create mode 100644 cmake/FindSalomeCppUnit.cmake create mode 100644 cmake/FindSalomeDoxygen.cmake create mode 100644 cmake/FindSalomeGraphviz.cmake create mode 100644 cmake/FindSalomeHDF5.cmake create mode 100644 cmake/FindSalomeLibXml2.cmake create mode 100644 cmake/FindSalomeMEDFile.cmake create mode 100644 cmake/FindSalomeMPI.cmake create mode 100644 cmake/FindSalomeMetis.cmake create mode 100644 cmake/FindSalomeNumPySciPy.cmake create mode 100644 cmake/FindSalomePTScotch.cmake create mode 100644 cmake/FindSalomePythonInterp.cmake create mode 100644 cmake/FindSalomePythonLibs.cmake create mode 100644 cmake/FindSalomeSWIG.cmake create mode 100644 cmake/FindSalomeScotch.cmake create mode 100644 cmake/FindSalomeSphinx.cmake create mode 100644 cmake/FindSalomeXDR.cmake create mode 100644 cmake/FindXDR.cmake create mode 100644 cmake/SalomeMacros.cmake create mode 100644 cmake/SalomeSetupPlatform.cmake create mode 100644 cmake/UseSphinx.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 5aa9fff2a..8d4e63c45 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,14 +38,10 @@ IF (${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.3) ENDIF() -# Common CMake macros -SET(CONFIGURATION_ROOT_DIR $ENV{CONFIGURATION_ROOT_DIR} CACHE PATH "Path to the Salome CMake files") -IF(EXISTS ${CONFIGURATION_ROOT_DIR}) - LIST(APPEND CMAKE_MODULE_PATH "${CONFIGURATION_ROOT_DIR}/cmake") - INCLUDE(SalomeMacros NO_POLICY_SCOPE) -ELSE() - MESSAGE(FATAL_ERROR "We absolutely need the Salome CMake configuration files, please define CONFIGURATION_ROOT_DIR !") -ENDIF() +# CMake macros +LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") + +INCLUDE(SalomeMacros NO_POLICY_SCOPE) # Versioning # =========== diff --git a/cmake/FindCppUnit.cmake b/cmake/FindCppUnit.cmake new file mode 100644 index 000000000..cdc230a98 --- /dev/null +++ b/cmake/FindCppUnit.cmake @@ -0,0 +1,112 @@ +# - Find CppUnit +# Sets the following variables: +# CPPUNIT_INCLUDE_DIRS - path to the CppUnit include directory +# CPPUNIT_LIBRARIES - path to the CppUnit libraries to be linked against +# CPPUNIT_DEFINITIONS - specific CppUnit definitions to be added +# +# The header cppunit/extensions/HelperMacros.h is looked for. +# The following libraries are searched +# cppunit_dll, or cppunitd_dll (Windows) +# cppunit (Linux) +# + +######################################################################### +# Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +IF(NOT CppUnit_FIND_QUIETLY) + MESSAGE(STATUS "Looking for CppUnit ...") +ENDIF() + +# Headers +SET(CPPUNIT_ROOT_DIR $ENV{CPPUNIT_ROOT_DIR} CACHE PATH "Path to the CPPUNIT.") +IF(CPPUNIT_ROOT_DIR) + LIST(APPEND CMAKE_INCLUDE_PATH "${CPPUNIT_ROOT_DIR}/include") + LIST(APPEND CMAKE_PROGRAM_PATH "${CPPUNIT_ROOT_DIR}/bin") +ENDIF(CPPUNIT_ROOT_DIR) + +SET(CPPUNIT_INCLUDE_TO_FIND cppunit/extensions/HelperMacros.h) +FIND_PATH(CPPUNIT_INCLUDE_DIRS ${CPPUNIT_INCLUDE_TO_FIND}) + +# Libraries +IF(WIN32) + IF(CMAKE_BUILD_TYPE STREQUAL Debug) + FIND_LIBRARY(CPPUNIT_LIBRARIES cppunitd_dll) + ELSE(CMAKE_BUILD_TYPE STREQUAL Debug) + FIND_LIBRARY(CPPUNIT_LIBRARIES cppunit_dll) + ENDIF(CMAKE_BUILD_TYPE STREQUAL Debug) +ELSE(WIN32) + + # RNV: Some new Linux distributions don't contain cppunit-config executable, + # so use pkg-config to detect cppunit first. + FIND_PACKAGE(PkgConfig QUIET) + + IF(PKG_CONFIG_FOUND) + PKG_SEARCH_MODULE(CPPUNIT_TOOL cppunit) + IF(CPPUNIT_TOOL_FOUND) + SET(CPPUNIT_LDFLAGS ${CPPUNIT_TOOL_LIBRARIES}) + ENDIF() + ENDIF() + + IF(NOT CPPUNIT_TOOL_FOUND) + MESSAGE("CPPUNIT is not found via pgk-config, try to find cppunit-config executable ...") + FIND_PROGRAM(CPPUNIT_CONFIG_BIN cppunit-config) + IF(NOT CPPUNIT_CONFIG_BIN) + MESSAGE(FATAL_ERROR "Error in CPPUNIT detection ! cppunit-config executable not found !") + ENDIF(NOT CPPUNIT_CONFIG_BIN) + EXECUTE_PROCESS(COMMAND ${CPPUNIT_CONFIG_BIN} --libs OUTPUT_VARIABLE CPPUNIT_LDFLAGS) + ENDIF() + + STRING(STRIP ${CPPUNIT_LDFLAGS} CPPUNIT_LDFLAGS) + STRING(REPLACE " " ";" LDFLAGS_LIST ${CPPUNIT_LDFLAGS}) + FOREACH(LDFLAG ${LDFLAGS_LIST}) + STRING(REGEX MATCH "^-L.*" LIBDIR "${LDFLAG}") + STRING(REGEX MATCH "^-l.*" LIB "${LDFLAG}") + IF(LIBDIR) + STRING(REGEX REPLACE "^-L" "" LIBDIR ${LIBDIR}) + LIST(APPEND CMAKE_LIBRARY_PATH ${LIBDIR}) + ELSEIF(LIB) + STRING(REGEX REPLACE "^-l" "" LIB ${LIB}) + LIST(APPEND LIBS ${LIB}) + ELSE() + IF(CPPUNIT_CONFIG_BIN) + MESSAGE(FATAL_ERROR "Unrecognized token \"${LDFLAG}\" in the output of cppunit-config --libs") + ELSE() + LIST(APPEND LIBS ${LDFLAG}) + ENDIF() + ENDIF() + ENDFOREACH(LDFLAG ${LDFLAGS_LIST}) + FOREACH(LIB ${LIBS}) + FIND_LIBRARY(CPPUNIT_SUBLIB_${LIB} ${LIB}) + IF(NOT CPPUNIT_SUBLIB_${LIB}) + MESSAGE(FATAL_ERROR "Error in CPPUNIT detection! Fail to locate the needed library ${LIB}!") + ENDIF(NOT CPPUNIT_SUBLIB_${LIB}) + LIST(APPEND CPPUNIT_LIBRARIES ${CPPUNIT_SUBLIB_${LIB}}) + ENDFOREACH(LIB ${LIBS}) +# MESSAGE("**** ${CPPUNIT_LIBRARIES}") +ENDIF(WIN32) + +# Global variables +SET(CPPUNIT_DEFINITIONS) +IF(WIN32) + SET(CPPUNIT_DEFINITIONS -DCPPUNIT_DLL) +ENDIF(WIN32) + +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(CppUnit REQUIRED_VARS CPPUNIT_INCLUDE_DIRS CPPUNIT_LIBRARIES) diff --git a/cmake/FindMEDFile.cmake b/cmake/FindMEDFile.cmake new file mode 100644 index 000000000..e666826f7 --- /dev/null +++ b/cmake/FindMEDFile.cmake @@ -0,0 +1,72 @@ +############################################################################ +# +# Detect MEDFile (med-fichier) +# -- +# Defines the following variables +# MEDFILE_INCLUDE_DIRS - include directories +# MEDFILE_LIBRARIES - libraries to link against (C and Fortran) +# MEDFILE_C_LIBRARIES - C libraries only +# MEDFILE_EXTRA_LIBRARIES - additional libraries +# -- +# The CMake (or environment) variable MEDFILE_ROOT_DIR can be set to +# guide the detection and indicate a root directory to look into. +# +############################################################################ +# Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +MESSAGE(STATUS "Check for medfile ...") +# -- + +SET(MEDFILE_ROOT_DIR $ENV{MEDFILE_ROOT_DIR} CACHE PATH "Path to the MEDFile.") +IF(MEDFILE_ROOT_DIR) + LIST(APPEND CMAKE_PREFIX_PATH "${MEDFILE_ROOT_DIR}") +ENDIF(MEDFILE_ROOT_DIR) +# -- + +# Detect headers directory +FIND_PATH(MEDFILE_INCLUDE_DIRS med.h) +# -- + +# Detect libraries +SET(MEDFILE_LIBRARIES) +SET(MEDFILE_C_LIBRARIES) +SET(MEDFILE_EXTRA_LIBRARIES) + +FIND_LIBRARY(MEDFILE_LIBRARY_medC NAMES medC) +IF(MEDFILE_LIBRARY_medC) + LIST(APPEND MEDFILE_C_LIBRARIES "${MEDFILE_LIBRARY_medC}") + LIST(APPEND MEDFILE_LIBRARIES "${MEDFILE_LIBRARY_medC}") +ENDIF() +FIND_LIBRARY(MEDFILE_LIBRARY_medfwrap NAMES medfwrap) +IF(MEDFILE_LIBRARY_medfwrap) + LIST(APPEND MEDFILE_C_LIBRARIES "${MEDFILE_LIBRARY_medfwrap}") + LIST(APPEND MEDFILE_LIBRARIES "${MEDFILE_LIBRARY_medfwrap}") +ENDIF() +FIND_LIBRARY(MEDFILE_LIBRARY_med NAMES med) +IF(MEDFILE_LIBRARY_med) + LIST(APPEND MEDFILE_LIBRARIES "${MEDFILE_LIBRARY_med}") +ENDIF() +FIND_LIBRARY(MEDFILE_LIBRARY_medimport NAMES medimport) +IF(MEDFILE_LIBRARY_medimport) + LIST(APPEND MEDFILE_EXTRA_LIBRARIES "${MEDFILE_LIBRARY_medimport}") +ENDIF() + +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(MEDFile REQUIRED_VARS MEDFILE_INCLUDE_DIRS MEDFILE_LIBRARIES) diff --git a/cmake/FindSalomeCppUnit.cmake b/cmake/FindSalomeCppUnit.cmake new file mode 100644 index 000000000..f5a6dfa9a --- /dev/null +++ b/cmake/FindSalomeCppUnit.cmake @@ -0,0 +1,33 @@ +# Copyright (C) 2013-2024 CEA, EDF, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# Author: Adrien Bruneton +# + +# CppUnit detection for Salome +# +# !! Please read the generic detection procedure in SalomeMacros.cmake !! +# + +SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(CppUnit CPPUNIT_INCLUDE_DIRS 1) +MARK_AS_ADVANCED(CPPUNIT_INCLUDE_DIRS CPPUNIT_LIBRARIES CPPUNIT_CONFIG_BIN CPPUNIT_SUBLIB_cppunit CPPUNIT_SUBLIB_dl) + +IF(CPPUNIT_FOUND) + SALOME_ACCUMULATE_HEADERS(CPPUNIT_INCLUDE_DIRS) + SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${CPPUNIT_LIBRARIES}) +ENDIF() diff --git a/cmake/FindSalomeDoxygen.cmake b/cmake/FindSalomeDoxygen.cmake new file mode 100644 index 000000000..03f3660de --- /dev/null +++ b/cmake/FindSalomeDoxygen.cmake @@ -0,0 +1,44 @@ +# Copyright (C) 2013-2024 CEA, EDF, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# Author: Adrien Bruneton +# + +# Doxygen detection for salome +# +# !! Please read the generic detection procedure in SalomeMacros.cmake !! +# +# Additional variables: +# +# DOXYGEN_SUPPORT_STL (string) [advanced] : set to YES if doxygen properly manages STL files +# or to NO otherwise (version 1.4.4 or older); see description of +# BUILTIN_STL_SUPPORT configuration variable in the doxygen documentation + +SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(Doxygen DOXYGEN_EXECUTABLE 2) +IF(DOXYGEN_FOUND) + IF(DOXYGEN_VERSION VERSION_LESS "1.4.5") + SET(DOXYGEN_SUPPORT_STL NO) + ELSE() + SET(DOXYGEN_SUPPORT_STL YES) + ENDIF() +ENDIF() +MARK_AS_ADVANCED(DOXYGEN_SUPPORT_STL) + +IF(DOXYGEN_FOUND) + SALOME_ACCUMULATE_ENVIRONMENT(PATH ${DOXYGEN_EXECUTABLE}) +ENDIF() diff --git a/cmake/FindSalomeGraphviz.cmake b/cmake/FindSalomeGraphviz.cmake new file mode 100644 index 000000000..b6d0e3dd2 --- /dev/null +++ b/cmake/FindSalomeGraphviz.cmake @@ -0,0 +1,33 @@ +# Copyright (C) 2013-2024 CEA, EDF, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# Author: Adrien Bruneton +# + +# Graphviz detection for salome +# +# !! Please read the generic detection procedure in SalomeMacros.cmake !! +# + +SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(Graphviz GRAPHVIZ_EXECUTABLE 2) +MARK_AS_ADVANCED(GRAPHVIZ_EXECUTABLE GRAPHVIZ_LIBRARIES GRAPHVIZ_INCLUDE_DIRS) + +IF(GRAPHVIZ_FOUND) + SALOME_ACCUMULATE_ENVIRONMENT(PATH ${GRAPHVIZ_EXECUTABLE}) + SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${GRAPHVIZ_LIBRARIES}) +ENDIF() \ No newline at end of file diff --git a/cmake/FindSalomeHDF5.cmake b/cmake/FindSalomeHDF5.cmake new file mode 100644 index 000000000..6e5e08741 --- /dev/null +++ b/cmake/FindSalomeHDF5.cmake @@ -0,0 +1,121 @@ +# Copyright (C) 2013-2024 CEA, EDF, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# Author: Adrien Bruneton +# + +# HDF5 detection for Salome +# +# !! Please read the generic detection procedure in SalomeMacros.cmake !! +# +# --- HDF5 specificities ---- +# MPI root directory used for HDF5 compilation is exposed into MPI_ROOT_DIR_EXP +# + +SET(HDF5_ROOT_DIR $ENV{HDF5_ROOT_DIR} CACHE PATH "Path to the HDF5.") + +IF(HDF5_ROOT_DIR) + SET (HDF5_ROOT ${HDF5_ROOT_DIR}) + IF(WIN32) + SET(HDF5_DIR ${HDF5_ROOT_DIR}/cmake/hdf5) + ENDIF() +ENDIF() + +FIND_PACKAGE(HDF5) +MARK_AS_ADVANCED(FORCE HDF5_INCLUDE_DIR HDF5_LIB HDF5_DIR) + +# Stupidly enough, CONFIG mode and MODULE mode for HDF5 do not return the same thing ...! +SET(HDF5_INCLUDE_DIRS "${HDF5_INCLUDE_DIRS};${HDF5_INCLUDE_DIR}") +# Same story with libraries - if in CONFIG mode, HDF5_LIBRARIES is not defined: +IF(NOT DEFINED HDF5_LIBRARIES) + IF(TARGET hdf5) + SET(HDF5_C_LIBRARIES hdf5) + ELSEIF(TARGET hdf5::hdf5-shared) + SET(HDF5_C_LIBRARIES hdf5::hdf5-shared) + ENDIF() + IF(TARGET hdf5_cpp) + SET(HDF5_CXX_LIBRARIES hdf5_cpp) + ELSEIF(TARGET hdf5::hdf5_cpp-shared) + SET(HDF5_CXX_LIBRARIES hdf5::hdf5_cpp-shared) + ENDIF() + IF(TARGET hdf5_hl) + SET(HDF5_C_HL_LIBRARIES hdf5_hl) + ELSEIF(TARGET hdf5::hdf5_hl-shared) + SET(HDF5_C_HL_LIBRARIES hdf5::hdf5_hl-shared) + ENDIF() + IF(TARGET hdf5_hl_cpp) + SET(HDF5_CXX_HL_LIBRARIES hdf5_hl_cpp) + ELSEIF(TARGET hdf5::hdf5_hl_cpp-shared) + SET(HDF5_CXX_HL_LIBRARIES hdf5::hdf5_hl_cpp-shared) + ENDIF() + # Note: now we only set HDF5_LIBRARIES to CXX libraries as it's enough for SALOME. + # In future, we probably must list all libraries from requested components. + SET(HDF5_LIBRARIES ${HDF5_CXX_LIBRARIES}) +ENDIF() + +## +## 7. Specific to HDF5 only: +## Expose MPI configuration to the rest of the world +## +IF(HDF5_ENABLE_PARALLEL OR HDF5_IS_PARALLEL) + # Set only one reference boolean variable: + # (unfortunately what is found in /usr/share/cmake/Modules/FindHDF5.cmake + # and in the native HDF5-config.cmake differ!) + SET(HDF5_IS_PARALLEL TRUE) + + # HDF5 was compiled with MPI support + # Unfortunately HDF5 doesn't expose its MPI configuration easily ... + # We sniff the properties of the HDF5 target which should also be there: + IF(NOT DEFINED HDF5_LIBRARIES) + SET(HDF5_LIBRARIES "hdf5") + IF(NOT TARGET hdf5 AND NOT TARGET hdf5-static AND NOT TARGET hdf5-shared) + # Some HDF5 versions (e.g. 1.8.18) used hdf5::hdf5 etc + SET(_target_prefix "hdf5::") + ENDIF() + SET(_suffix "-shared") + SET(HDF5_LIBRARIES "${_target_prefix}hdf5${_suffix}") + ENDIF() + GET_PROPERTY(_lib_lst SOURCE ${HDF5_LIBRARIES} PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES_NOCONFIG) + FOREACH(s ${_lib_lst}) + STRING(FIND "${s}" "mpi." _res) # should cover WIN(?) and LINUX + IF(_res GREATER -1) + GET_FILENAME_COMPONENT(_tmp "${s}" PATH) # go up to levels + GET_FILENAME_COMPONENT(MPI_ROOT_DIR_EXP "${_tmp}" PATH) + BREAK() + ENDIF() + ENDFOREACH() + IF(NOT SalomeHDF5_FIND_QUIETLY) + MESSAGE(STATUS "HDF5 was compiled with MPI: ${MPI_ROOT_DIR_EXP}") + ENDIF() +ENDIF() + +## Add definitions +ADD_DEFINITIONS(-DH5_USE_16_API) +IF(WIN32) + ADD_DEFINITIONS(-D_HDF5USEDLL_) +ENDIF() + +## Ensure SALOME uses MPI if HDF5 was parallel: +IF(HDF5_IS_PARALLEL AND NOT SALOME_USE_MPI) + MESSAGE(FATAL_ERROR "HDF5 is compiled with MPI, you have to set SALOME_USE_MPI to ON") +ENDIF() + +IF(HDF5_FOUND) + SALOME_ACCUMULATE_HEADERS(HDF5_INCLUDE_DIRS) + SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${HDF5_LIBRARIES}) +ENDIF() diff --git a/cmake/FindSalomeLibXml2.cmake b/cmake/FindSalomeLibXml2.cmake new file mode 100644 index 000000000..5412f7fe0 --- /dev/null +++ b/cmake/FindSalomeLibXml2.cmake @@ -0,0 +1,42 @@ +# Copyright (C) 2013-2024 CEA, EDF, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +# LibXml2 detection for SALOME +# +# !! Please read the generic detection procedure in SalomeMacros.cmake !! +# +IF(WIN32) + SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(LibXml2 LIBXML2_INCLUDE_DIR 1) +ELSE() + SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(LibXml2 LIBXML2_INCLUDE_DIR 2) +ENDIF() +#MARK_AS_ADVANCED() + +IF(NOT LIBXML2_INCLUDE_DIR) + SET(LIBXML2_INCLUDE_DIR ${LIBXML2_INCLUDE_DIRS}) +ENDIF() + +IF(LIBXML2_FOUND) + SALOME_ACCUMULATE_HEADERS(LIBXML2_INCLUDE_DIR) + SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${LIBXML2_LIBRARIES}) + IF(WIN32 AND LIBXML2_XMLLINT_EXECUTABLE) + GET_FILENAME_COMPONENT(LIBXML2_BIN_DIR ${LIBXML2_XMLLINT_EXECUTABLE} DIRECTORY) + SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${LIBXML2_BIN_DIR}) + ENDIF() +ENDIF() diff --git a/cmake/FindSalomeMEDFile.cmake b/cmake/FindSalomeMEDFile.cmake new file mode 100644 index 000000000..4b2ec2c34 --- /dev/null +++ b/cmake/FindSalomeMEDFile.cmake @@ -0,0 +1,59 @@ +# Copyright (C) 2013-2024 CEA, EDF, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# Author: Adrien Bruneton +# + +# Medfile detection for Salome +# +# !! Please read the generic detection procedure in SalomeMacros.cmake !! +# + +SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(MEDFile MEDFILE_INCLUDE_DIRS 1) +#MARK_AS_ADVANCED() + +SET(MED_INT_IS_LONG FALSE) # fallback value +IF(MEDFile_FOUND) + SALOME_ACCUMULATE_HEADERS(MEDFILE_INCLUDE_DIRS) + SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${MEDFILE_LIBRARIES}) + + # Check size of med_int + SET(_med_int_cxx ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/check_med_int_size.cxx) + FILE(WRITE ${_med_int_cxx} + "#include \n#include \nint main(){printf(\"%d\", sizeof(med_int)); return 0;}") + TRY_RUN(_med_int_run_result _med_int_compile_results + ${CMAKE_BINARY_DIR} ${_med_int_cxx} + CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${MEDFILE_INCLUDE_DIRS};${HDF5_INCLUDE_DIR}" + LINK_LIBRARIES ${MEDFILE_C_LIBRARIES} ${HDF5_LIBRARIES} + RUN_OUTPUT_VARIABLE _med_int_output) + IF(_med_int_compile_results) + SET(MED_INT_SIZE ${_med_int_output}) + ELSE() + SET(MED_INT_SIZE UNKNOWN) + ENDIF() + IF(MED_INT_SIZE EQUAL 8) + SET(MED_INT_IS_LONG TRUE) + ELSE() + SET(MED_INT_IS_LONG FALSE) + ENDIF() + MESSAGE(STATUS "MEDFile: size of med_int is ${MED_INT_SIZE}") + UNSET(_med_int_cxx) + UNSET(_med_int_run_result) + UNSET(_med_int_compile_results) + UNSET(_med_int_output) +ENDIF() diff --git a/cmake/FindSalomeMPI.cmake b/cmake/FindSalomeMPI.cmake new file mode 100644 index 000000000..bbc79628a --- /dev/null +++ b/cmake/FindSalomeMPI.cmake @@ -0,0 +1,48 @@ +# Copyright (C) 2013-2024 CEA, EDF, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# Author: Adrien Bruneton +# + +# MPI detection for Salome +# +# !! Please read the generic detection procedure in SalomeMacros.cmake !! +# + +SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(MPI MPIEXEC 2) +MARK_AS_ADVANCED(MPI_EXTRA_LIBRARY MPI_LIBRARY) + +SET(MPI_INCLUDE_DIRS ${MPI_C_INCLUDE_PATH} ${MPI_CXX_INCLUDE_PATH}) +SET(MPI_LIBRARIES ${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES}) + +IF(MPI_FOUND) + # Detect if function MPI_Publish_name is provided by the external MPI library + # otherwise take ours. + include(CheckSymbolExists) + SET(CMAKE_REQUIRED_LIBRARIES ${MPI_LIBRARIES}) + SET(CMAKE_REQUIRED_INCLUDES ${MPI_C_INCLUDE_PATH}) + CHECK_SYMBOL_EXISTS(MPI_Publish_name mpi.h MPI2_IS_OK) + SET(MPI_DEFINITIONS "${MPI_CXX_COMPILE_FLAGS}") + IF(MPI2_IS_OK) + MESSAGE(STATUS "Your mpi implementation is compatible with mpi2 ... adding -DHAVE_MPI2") + SET(MPI_DEFINITIONS "${MPI_CXX_COMPILE_FLAGS} -DHAVE_MPI2") + ENDIF(MPI2_IS_OK) + + SALOME_ACCUMULATE_HEADERS(MPI_INCLUDE_DIRS) + SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${MPI_LIBRARIES}) +ENDIF() diff --git a/cmake/FindSalomeMetis.cmake b/cmake/FindSalomeMetis.cmake new file mode 100644 index 000000000..c66295bb8 --- /dev/null +++ b/cmake/FindSalomeMetis.cmake @@ -0,0 +1,33 @@ +# Copyright (C) 2013-2024 CEA, EDF, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# Author: Adrien Bruneton +# + +# Medfile detection dor Salome +# +# !! Please read the generic detection procedure in SalomeMacros.cmake !! +# + +SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(Metis METIS_INCLUDE_DIRS 1) +#MARK_AS_ADVANCED() + +IF(METIS_FOUND) + SALOME_ACCUMULATE_HEADERS(METIS_INCLUDE_DIRS) + SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${METIS_LIBRARIES}) +ENDIF() \ No newline at end of file diff --git a/cmake/FindSalomeNumPySciPy.cmake b/cmake/FindSalomeNumPySciPy.cmake new file mode 100644 index 000000000..2f93b3146 --- /dev/null +++ b/cmake/FindSalomeNumPySciPy.cmake @@ -0,0 +1,52 @@ +# Copyright (C) 2013-2024 CEA, EDF, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# Author: Roman NIKOLAEV +# +# Looking for an installation of NumPy and SciPy, and if found the following variables are set +# NUMPY_INCLUDE_DIR - NumPy header location +# NUMPY_DEFINITIONS - NumPy compiler flags +# SCIPY_DEFINITIONS - SciPy compiler flags +# SCIPY_VERSION - SciPy version +# + +IF(SALOMEPYTHONINTERP_FOUND) + # Numpy + EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "import numpy ; import sys ; sys.stdout.write(numpy.get_include())" OUTPUT_VARIABLE NUMPY_INCLUDE_DIR ERROR_QUIET ) + IF(NUMPY_INCLUDE_DIR) + SET(NUMPY_FOUND TRUE) + ENDIF(NUMPY_INCLUDE_DIR) + IF(NUMPY_FOUND) + SET(NUMPY_DEFINITIONS -DWITH_NUMPY) + MESSAGE(STATUS "NumPy found : ${NUMPY_INCLUDE_DIR}") + ELSE(NUMPY_FOUND) + MESSAGE(STATUS "NumPy not found.") + ENDIF(NUMPY_FOUND) + + # SciPy detection + EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "import scipy ; import sys ; sys.stdout.write(scipy.version.version)" OUTPUT_VARIABLE SCIPY_VERSION ERROR_QUIET ) + IF(SCIPY_VERSION) + SET(SCIPY_FOUND TRUE) + ENDIF(SCIPY_VERSION) + IF(SCIPY_FOUND) + MESSAGE(STATUS "Scipy found : Version ${SCIPY_VERSION}") + SET(SCIPY_DEFINITIONS -DWITH_SCIPY) + ELSE(SCIPY_FOUND) + MESSAGE(STATUS "SciPy not found.") + ENDIF(SCIPY_FOUND) +ENDIF() \ No newline at end of file diff --git a/cmake/FindSalomePTScotch.cmake b/cmake/FindSalomePTScotch.cmake new file mode 100644 index 000000000..04fd8d19b --- /dev/null +++ b/cmake/FindSalomePTScotch.cmake @@ -0,0 +1,33 @@ +# Copyright (C) 2017-2024 CEA, EDF, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# Author: Adrien Bruneton +# + +# Medfile detection dor Salome +# +# !! Please read the generic detection procedure in SalomeMacros.cmake !! +# + +SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(PTScotch PTSCOTCH_INCLUDE_DIRS 1) +#MARK_AS_ADVANCED() + +IF(SCOTCH_FOUND) + SALOME_ACCUMULATE_HEADERS(PTSCOTCH_INCLUDE_DIRS) + SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${PTSCOTCH_LIBRARIES}) +ENDIF() diff --git a/cmake/FindSalomePythonInterp.cmake b/cmake/FindSalomePythonInterp.cmake new file mode 100644 index 000000000..3517003fc --- /dev/null +++ b/cmake/FindSalomePythonInterp.cmake @@ -0,0 +1,53 @@ +# Copyright (C) 2013-2024 CEA, EDF, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# Author: Adrien Bruneton +# + +# Python interpreter detection for SALOME +# +# !! Please read the generic detection procedure in SalomeMacros.cmake !! +# + +# Make sure the detection of both libs and interpreter (if both needed) occur in the correct order: +IF(SALOMEPYTHONLIBS_FOUND AND NOT SALOMEPYTHONINTERP_FOUND) + MESSAGE(FATAL_ERROR "Developer error -> Python interpreter should be detected/required before Python libs!") +ENDIF() + +# Use the PYTHON_ROOT_DIR if PYTHONINTERP_ROOT_DIR is not defined: +SET(PYTHON_ROOT_DIR "$ENV{PYTHON_ROOT_DIR}" CACHE PATH "Path to the Python installation (libs+interpreter)") +IF(EXISTS "${PYTHON_ROOT_DIR}" AND (NOT PYTHONINTERP_ROOT_DIR)) + # Extract sub-directory "paraview-x.xx": + MESSAGE(STATUS "Setting PYTHONINTERP_ROOT_DIR to: ${PYTHON_ROOT_DIR}") + SET(PYTHONINTERP_ROOT_DIR "${PYTHON_ROOT_DIR}" CACHE PATH "Path to PythonInterp directory") +ENDIF() + +# python 3 +SET(PythonInterp_FIND_VERSION 3) +SET(PythonInterp_FIND_VERSION_MAJOR 3) + +SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(PythonInterp PYTHON_EXECUTABLE 1) + +IF(SALOMEPYTHONINTERP_FOUND) + SET(PYTHON_PYTHONPATH "${PYTHON_ROOT_DIR}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}") + GET_FILENAME_COMPONENT(_python_bin "${PYTHON_EXECUTABLE}" NAME ) + SET(PYTHONBIN "${_python_bin}" CACHE STRING "Name of Python interpreter") + SALOME_ACCUMULATE_ENVIRONMENT(PATH ${PYTHON_EXECUTABLE}) + SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH ${PYTHON_PYTHONPATH}) +ENDIF() + diff --git a/cmake/FindSalomePythonLibs.cmake b/cmake/FindSalomePythonLibs.cmake new file mode 100644 index 000000000..4ef691a30 --- /dev/null +++ b/cmake/FindSalomePythonLibs.cmake @@ -0,0 +1,73 @@ +# Copyright (C) 2013-2024 CEA, EDF, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# Author: Adrien Bruneton +# + +# Python libraries detection for SALOME +# +# !! Please read the generic detection procedure in SalomeMacros.cmake !! +# + +# Use the PYTHON_ROOT_DIR if PYTHONLIBS_ROOT_DIR is not defined: +SET(PYTHON_ROOT_DIR "$ENV{PYTHON_ROOT_DIR}" CACHE PATH "Path to the Python installation (libs+interpreter)") +IF(EXISTS "${PYTHON_ROOT_DIR}" AND (NOT PYTHONLIBS_ROOT_DIR)) + MESSAGE(STATUS "Setting PYTHONLIBS_ROOT_DIR to: ${PYTHON_ROOT_DIR}") + SET(PYTHONLIBS_ROOT_DIR "${PYTHON_ROOT_DIR}" CACHE PATH "Path to PythonLibs directory") +ENDIF() +IF (SALOMEPYTHONINTERP_FOUND AND NOT "${PYTHON_VERSION_STRING}" STREQUAL "") + # Trying to search libraries with same version as an interpreter version + SET(PythonLibs_FIND_VERSION ${PYTHON_VERSION_STRING}) + SET(PythonLibs_FIND_VERSION_MAJOR ${PYTHON_VERSION_MAJOR}) +ENDIF() +IF(WIN32) + SET(CMAKE_LIBRARY_PATH "${PYTHON_ROOT_DIR}/libs") + SET(PYTHON_INCLUDE_DIR "${PYTHON_ROOT_DIR}/include") +ENDIF() +IF(APPLE) + FIND_PROGRAM(PYTHON_CONFIG_EXECUTABLE python-config) + IF(NOT PYTHON_CONFIG_EXECUTABLE) + MESSAGE(SEND_ERROR "python-config executable not found, but python is required.") + ENDIF() + EXECUTE_PROCESS(COMMAND ${PYTHON_CONFIG_EXECUTABLE} --prefix OUTPUT_VARIABLE python_prefix OUTPUT_STRIP_TRAILING_WHITESPACE) + SET(PYTHON_INCLUDE_DIR ${python_prefix}/include/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) + SET(PYTHON_LIBRARY ${python_prefix}/lib/libpython${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}${CMAKE_SHARED_LIBRARY_SUFFIX}) + SET(PYTHON_MAJOR_VERSION ${PYTHON_VERSION_MAJOR}) + SET(PYTHON_MINOR_VERSION ${PYTHON_VERSION_MINOR}) + MESSAGE(STATUS "Python libraries: ${PYTHON_LIBRARY}") + MESSAGE(STATUS "Python include dir: ${PYTHON_INCLUDE_DIR}") +ENDIF() + +SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(PythonLibs PYTHON_INCLUDE_DIR 2) + +IF(SALOMEPYTHONLIBS_FOUND) + SALOME_ACCUMULATE_HEADERS(PYTHON_INCLUDE_DIR) + SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${PYTHON_LIBRARIES}) +ENDIF() + +## Specifics -- check matching version with Interpreter if already detected: +IF (SALOMEPYTHONLIBS_FOUND AND SALOMEPYTHONINTERP_FOUND) + # Now ensure versions are matching + SALOME_EXTRACT_VERSION(${PYTHONLIBS_VERSION_STRING} maj_lib min_lib patch_lib) + SALOME_EXTRACT_VERSION(${PYTHON_VERSION_STRING} maj_inter min_inter patch_inter) + IF("${maj_lib}.${min_lib}.${patch_lib}" STREQUAL "${maj_inter}.${min_inter}.${patch_inter}") + MESSAGE(STATUS "Python libs and interpreter versions are matching: ${PYTHONLIBS_VERSION_STRING}") + ELSE() + MESSAGE(FATAL_ERROR "Python libs and interpreter versions are NOT matching: ${PYTHONLIBS_VERSION_STRING} vs ${PYTHON_VERSION_STRING}") + ENDIF() +ENDIF() diff --git a/cmake/FindSalomeSWIG.cmake b/cmake/FindSalomeSWIG.cmake new file mode 100644 index 000000000..deab11bdc --- /dev/null +++ b/cmake/FindSalomeSWIG.cmake @@ -0,0 +1,39 @@ +# Copyright (C) 2013-2024 CEA, EDF, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# Author: Adrien Bruneton +# + +# SWIG detection for SALOME +# +# !! Please read the generic detection procedure in SalomeMacros.cmake !! +# + +# Workaround about stupid CMake bug that find_program performs search by iterating through names at first place +# instead of paths!!! +FIND_PROGRAM(SWIG_EXECUTABLE NAMES swig3.0 swig2.0 swig HINTS $ENV{SWIG_ROOT_DIR} PATH_SUFFIXES bin NO_CMAKE_SYSTEM_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_PATH) +IF(WIN32) + SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(SWIG SWIG_EXECUTABLE 1) +ELSE() + SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(SWIG SWIG_EXECUTABLE 2) +ENDIF() +MARK_AS_ADVANCED(SWIG_EXECUTABLE SWIG_VERSION) + +IF(SWIG_FOUND) + SALOME_ACCUMULATE_ENVIRONMENT(PATH ${SWIG_EXECUTABLE}) +ENDIF() diff --git a/cmake/FindSalomeScotch.cmake b/cmake/FindSalomeScotch.cmake new file mode 100644 index 000000000..8915eb96a --- /dev/null +++ b/cmake/FindSalomeScotch.cmake @@ -0,0 +1,33 @@ +# Copyright (C) 2013-2024 CEA, EDF, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# Author: Adrien Bruneton +# + +# Medfile detection dor Salome +# +# !! Please read the generic detection procedure in SalomeMacros.cmake !! +# + +SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(Scotch SCOTCH_INCLUDE_DIRS 1) +#MARK_AS_ADVANCED() + +IF(SCOTCH_FOUND) + SALOME_ACCUMULATE_HEADERS(SCOTCH_INCLUDE_DIRS) + SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${SCOTCH_LIBRARIES}) +ENDIF() diff --git a/cmake/FindSalomeSphinx.cmake b/cmake/FindSalomeSphinx.cmake new file mode 100644 index 000000000..b6ab3aa27 --- /dev/null +++ b/cmake/FindSalomeSphinx.cmake @@ -0,0 +1,46 @@ +# Copyright (C) 2013-2024 CEA, EDF, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +# Sphinx detection for Salome +# +# !! Please read the generic detection procedure in SalomeMacros.cmake !! +# + +SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(Sphinx SPHINX_EXECUTABLE 2) + +# Also retrieve paths to DOCUTILS and SETUPTOOLS: +SET(SETUPTOOLS_ROOT_DIR "$ENV{SETUPTOOLS_ROOT_DIR}" CACHE PATH "Path to the Setuptools installation") +SET(DOCUTILS_ROOT_DIR "$ENV{DOCUTILS_ROOT_DIR}" CACHE PATH "Path to the Docutils installation") + +# Ensure the command is run with the given PYTHONPATH +IF(WIN32 AND NOT CYGWIN) + SET(SPHINX_EXECUTABLE ${SPHINX_EXECUTABLE}) + SET(SPHINX_APIDOC_EXECUTABLE ${SPHINX_APIDOC_EXECUTABLE}) +ELSE() + SET(SPHINX_EXECUTABLE /usr/bin/env PYTHONPATH="${SPHINX_PYTHONPATH}:$$PYTHONPATH" ${SPHINX_EXECUTABLE}) + SET(SPHINX_APIDOC_EXECUTABLE /usr/bin/env PYTHONPATH="${SPHINX_PYTHONPATH}:$$PYTHONPATH" ${SPHINX_APIDOC_EXECUTABLE}) +ENDIF() + +MARK_AS_ADVANCED(SPHINX_EXECUTABLE) + +IF(SPHINX_FOUND) + SALOME_ACCUMULATE_ENVIRONMENT(PATH ${SPHINX_EXECUTABLE}) + SALOME_ACCUMULATE_ENVIRONMENT(PATH ${SPHINX_APIDOC_EXECUTABLE}) + SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH ${SPHINX_PYTHONPATH}) +ENDIF() diff --git a/cmake/FindSalomeXDR.cmake b/cmake/FindSalomeXDR.cmake new file mode 100644 index 000000000..e88daf575 --- /dev/null +++ b/cmake/FindSalomeXDR.cmake @@ -0,0 +1,33 @@ +# Copyright (C) 2013-2024 CEA, EDF, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# Author: Anthony Geay +# + +# XDR detection dor Salome +# +# !! Please read the generic detection procedure in SalomeMacros.cmake !! +# + +SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(XDR XDR_INCLUDE_DIRS 1) +#MARK_AS_ADVANCED() + +#IF(XDR_FOUND) # useless here because XDR is used only in CXX of MEDLoader +# SALOME_ACCUMULATE_HEADERS(XDR_INCLUDE_DIRS) +# SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${XDR_LIBRARIES}) +#ENDIF() \ No newline at end of file diff --git a/cmake/FindXDR.cmake b/cmake/FindXDR.cmake new file mode 100644 index 000000000..2bc2f9119 --- /dev/null +++ b/cmake/FindXDR.cmake @@ -0,0 +1,49 @@ +# Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +MESSAGE(STATUS "Check for XDR ...") + +INCLUDE(FindPackageHandleStandardArgs) + +FIND_PATH(XDR_INCLUDE_DIRS rpc/xdr.h PATH_SUFFIXES tirpc) +IF(XDR_INCLUDE_DIRS) + SET(XDR_DEFINITIONS "-DHAS_XDR") +ENDIF(XDR_INCLUDE_DIRS) + +IF(WIN32) + FIND_LIBRARY(XDR_LIBRARIES xdr) # To get the .lib file from XDR + FIND_PATH(XDR_INCLUDE_DIRS2 stdint.h PATH_SUFFIXES src/msvc) # To get the stdint.h from XDR (needed by types.h) + IF(XDR_INCLUDE_DIRS) + IF(XDR_INCLUDE_DIRS2) + LIST(APPEND XDR_INCLUDE_DIRS "${XDR_INCLUDE_DIRS2}") + ELSE() + SET(XDR_INCLUDE_DIRS "${XDR_INCLUDE_DIRS2}") # Make the detection fail + ENDIF() + ENDIF() + FIND_PACKAGE_HANDLE_STANDARD_ARGS(XDR REQUIRED_VARS XDR_INCLUDE_DIRS XDR_LIBRARIES) +ELSE(WIN32) + FIND_LIBRARY(XDR_LIBRARY NAMES tirpc xdr) + IF(NOT XDR_LIBRARY) + MESSAGE(STATUS "Could not find XDR libraries ...") + ELSE() + MESSAGE(STATUS "Found XDR libraries ${XDR_LIBRARY} ...") + SET(XDR_LIBRARIES ${XDR_LIBRARY}) + ENDIF() + FIND_PACKAGE_HANDLE_STANDARD_ARGS(XDR REQUIRED_VARS XDR_INCLUDE_DIRS) +ENDIF(WIN32) diff --git a/cmake/SalomeMacros.cmake b/cmake/SalomeMacros.cmake new file mode 100644 index 000000000..84641247b --- /dev/null +++ b/cmake/SalomeMacros.cmake @@ -0,0 +1,1226 @@ +# Copyright (C) 2012-2024 CEA, EDF, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# Author: A.Geay, V. Sandler, A. Bruneton +# + +#---------------------------------------------------------------------------- +# Set-up global policies +#---------------------------------------------------------------------------- +CMAKE_POLICY(SET CMP0003 NEW) # Ensure proper linker behavior +IF(WIN32) + CMAKE_POLICY(SET CMP0020 OLD) # Disable automatic linking to qtmain.lib +ENDIF(WIN32) +CMAKE_POLICY(SET CMP0053 NEW) # For correct Qt 5 detection procedure +IF(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12) + CMAKE_POLICY(SET CMP0074 NEW) # Use ROOT variables when detecting packages +ENDIF() +IF(CMAKE_VERSION VERSION_GREATER_EQUAL 3.18) + CMAKE_POLICY(SET CMP0057 NEW) +ENDIF() +#---------------------------------------------------------------------------- +# LIST_CONTAINS is a macro useful for determining whether a list has a +# particular entry +#---------------------------------------------------------------------------- +MACRO(LIST_CONTAINS var value) + SET(${var}) + FOREACH(value2 ${ARGN}) + IF(${value} STREQUAL "${value2}") + SET(${var} TRUE) + ENDIF (${value} STREQUAL "${value2}") + ENDFOREACH (value2) +ENDMACRO(LIST_CONTAINS) + +#---------------------------------------------------------------------------- +# The PARSE_ARGUMENTS macro will take the arguments of another macro and +# define several variables. +# +# USAGE: PARSE_ARGUMENTS(prefix arg_names options arg1 arg2...) +# +# ARGUMENTS: +# +# prefix: IN: a prefix to put on all variables it creates. +# +# arg_names: IN: a list of names. +# For each item in arg_names, PARSE_ARGUMENTS will create a +# variable with that name, prefixed with prefix_. Each variable will be filled +# with the arguments that occur after the given arg_name is encountered +# up to the next arg_name or the end of the arguments. All options are +# removed from these lists. PARSE_ARGUMENTS also creates a +# prefix_DEFAULT_ARGS variable containing the list of all arguments up +# to the first arg_name encountered. +# +# options: IN: a list of options. +# For each item in options, PARSE_ARGUMENTS will create a +# variable with that name, prefixed with prefix_. So, for example, if prefix is +# MY_MACRO and options is OPTION1;OPTION2, then PARSE_ARGUMENTS will +# create the variables MY_MACRO_OPTION1 and MY_MACRO_OPTION2. These +# variables will be set to true if the option exists in the command line +# or false otherwise. +# arg_names and options lists should be quoted. +# +# The rest of PARSE_ARGUMENTS are arguments from another macro to be parsed. +#---------------------------------------------------------------------------- +MACRO(PARSE_ARGUMENTS prefix arg_names option_names) + SET(DEFAULT_ARGS) + FOREACH(arg_name ${arg_names}) + SET(${prefix}_${arg_name}) + ENDFOREACH(arg_name) + FOREACH(option ${option_names}) + SET(${prefix}_${option} FALSE) + ENDFOREACH(option) + SET(current_arg_name DEFAULT_ARGS) + SET(current_arg_list) + FOREACH(arg ${ARGN}) + LIST_CONTAINS(is_arg_name ${arg} ${arg_names}) + IF (is_arg_name) + SET(${prefix}_${current_arg_name} ${current_arg_list}) + SET(current_arg_name ${arg}) + SET(current_arg_list) + ELSE (is_arg_name) + LIST_CONTAINS(is_option ${arg} ${option_names}) + IF (is_option) + SET(${prefix}_${arg} TRUE) + ELSE (is_option) + SET(current_arg_list ${current_arg_list} ${arg}) + ENDIF (is_option) + ENDIF (is_arg_name) + ENDFOREACH(arg) + SET(${prefix}_${current_arg_name} ${current_arg_list}) +ENDMACRO(PARSE_ARGUMENTS) + +#---------------------------------------------------------------------------- +# SALOME_INSTALL_SCRIPTS is a macro useful for installing scripts. +# +# USAGE: SALOME_INSTALL_SCRIPTS(file_list path [WORKING_DIRECTORY dir] [DEF_PERMS] [TARGET_NAME name]) +# +# ARGUMENTS: +# file_list: IN : list of files to be installed. This list should be quoted. +# path: IN : full pathname for installing. +# +# By default files to be installed as executable scripts. +# If DEF_PERMS option is provided, than permissions for installed files are +# only OWNER_WRITE, OWNER_READ, GROUP_READ, and WORLD_READ. +# WORKING_DIRECTORY option may be used to specify the relative or absolute +# path to the directory containing source files listed in file_list argument. +# If TARGET_NAME option is specified, the name of the target being created +# with this macro is returned via the given variable. +#---------------------------------------------------------------------------- +MACRO(SALOME_INSTALL_SCRIPTS file_list path) + PARSE_ARGUMENTS(SALOME_INSTALL_SCRIPTS "WORKING_DIRECTORY;TARGET_NAME;EXTRA_DPYS" "DEF_PERMS" ${ARGN}) + SET(PERMS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) + IF(NOT SALOME_INSTALL_SCRIPTS_DEF_PERMS) + SET(PERMS ${PERMS} OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE) + ENDIF(NOT SALOME_INSTALL_SCRIPTS_DEF_PERMS) + SET(_all_pyc) + SET(_all_pyo) + FOREACH(file ${file_list}) + SET(PREFIX "") + SET(_source_prefix "") + GET_FILENAME_COMPONENT(file_name ${file} NAME) + IF(NOT IS_ABSOLUTE ${file}) + SET(_source_prefix "${CMAKE_CURRENT_SOURCE_DIR}/") + IF(SALOME_INSTALL_SCRIPTS_WORKING_DIRECTORY) + SET(PREFIX "${SALOME_INSTALL_SCRIPTS_WORKING_DIRECTORY}/") + SET(_source_prefix "${SALOME_INSTALL_SCRIPTS_WORKING_DIRECTORY}/") + ENDIF(SALOME_INSTALL_SCRIPTS_WORKING_DIRECTORY) + ENDIF(NOT IS_ABSOLUTE ${file}) + INSTALL(FILES ${PREFIX}${file} DESTINATION ${path} PERMISSIONS ${PERMS}) + GET_FILENAME_COMPONENT(ext ${file} EXT) + GET_FILENAME_COMPONENT(we_ext ${file} NAME_WE) + + IF(ext STREQUAL .py) + # Generate and install the pyc and pyo + # [ABN] Important: we avoid references or usage of CMAKE_INSTALL_PREFIX which is not correctly set + # when using CPack. + SET(_pyc_file "${CMAKE_CURRENT_BINARY_DIR}/${we_ext}.cpython-${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}.pyc") + SET(_pyo_file "${CMAKE_CURRENT_BINARY_DIR}/${we_ext}.cpython-${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}.opt-1.pyc") + LIST(APPEND _all_pyc ${_pyc_file}) + LIST(APPEND _all_pyo ${_pyo_file}) + ADD_CUSTOM_COMMAND( + OUTPUT ${_pyc_file} ${_pyo_file} + 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)" + DEPENDS ${PREFIX}${file} + VERBATIM + ) + # Install the .pyo and the .pyc + INSTALL(FILES ${_pyc_file} DESTINATION ${path}/__pycache__ PERMISSIONS ${PERMS}) + INSTALL(FILES ${_pyo_file} DESTINATION ${path}/__pycache__ PERMISSIONS ${PERMS}) + ENDIF(ext STREQUAL .py) + + # get relative path (from CMAKE_SOURCE_DIR to CMAKE_CURRENT_SOURCE_DIR) + STRING(REGEX REPLACE ${CMAKE_SOURCE_DIR} "" rel_dir ${CMAKE_CURRENT_SOURCE_DIR}) + # convert "/" to "_" + IF(rel_dir) + STRING(REGEX REPLACE "/" "_" unique_name ${rel_dir}) + ELSE(rel_dir) + SET(unique_name _) + ENDIF(rel_dir) + + ENDFOREACH(file ${file_list}) + # Generate only one target for all requested Python script compilation. + # Make sure that the target name is unique too. + IF(_all_pyc) + SET(_cnt 0) + WHILE(TARGET "PYCOMPILE${unique_name}_${_cnt}") + MATH(EXPR _cnt ${_cnt}+1) + ENDWHILE() + SET(_target_name "PYCOMPILE${unique_name}_${_cnt}") + ADD_CUSTOM_TARGET(${_target_name} ALL DEPENDS ${_all_pyc} ${_all_pyo}) + IF(SALOME_INSTALL_SCRIPTS_TARGET_NAME) + SET(${SALOME_INSTALL_SCRIPTS_TARGET_NAME} ${_target_name}) + ENDIF(SALOME_INSTALL_SCRIPTS_TARGET_NAME) + IF(SALOME_INSTALL_SCRIPTS_EXTRA_DPYS) + ADD_DEPENDENCIES(${_target_name} ${SALOME_INSTALL_SCRIPTS_EXTRA_DPYS}) + ENDIF(SALOME_INSTALL_SCRIPTS_EXTRA_DPYS) + ENDIF() +ENDMACRO(SALOME_INSTALL_SCRIPTS) + +#---------------------------------------------------------------------------- +# SALOME_CONFIGURE_FILE is a macro useful for copying a file to another location +# and modify its contents. +# +# USAGE: SALOME_CONFIGURE_FILE(in_file out_file [INSTALL dir [EXEC_PERMS]]) +# +# ARGUMENTS: +# 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. +# In this case, EXEC_PERMS can be used to set execution permission for installed file. +#---------------------------------------------------------------------------- +MACRO(SALOME_CONFIGURE_FILE IN_FILE OUT_FILE) + 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" "EXEC_PERMS" ${ARGN}) + IF(SALOME_CONFIGURE_FILE_INSTALL) + SET(PERMS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) + IF(SALOME_CONFIGURE_FILE_EXEC_PERMS) + SET(PERMS ${PERMS} OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE) + ENDIF(SALOME_CONFIGURE_FILE_EXEC_PERMS) + INSTALL(FILES ${_out_file} DESTINATION ${SALOME_CONFIGURE_FILE_INSTALL} PERMISSIONS ${PERMS}) + ENDIF(SALOME_CONFIGURE_FILE_INSTALL) +ENDMACRO(SALOME_CONFIGURE_FILE) + + +####################################################################################### +# Useful macros for SALOME own package detection system +# + +### +# SALOME_CHECK_EQUAL_PATHS(result path1 path2) +# Check if two paths are identical, resolving links. If the paths do not exist a simple +# text comparison is performed. +# result is a boolean. +### +MACRO(SALOME_CHECK_EQUAL_PATHS varRes path1 path2) + SET("${varRes}" OFF) + IF(EXISTS "${path1}") + GET_FILENAME_COMPONENT(_tmp1 "${path1}" REALPATH) + ELSE() + SET(_tmp1 "${path1}") + ENDIF() + + IF(EXISTS "${path2}") + GET_FILENAME_COMPONENT(_tmp2 "${path2}" REALPATH) + ELSE() + SET(_tmp2 "${path2}") + ENDIF() + + IF("${_tmp1}" STREQUAL "${_tmp2}") + SET("${varRes}" ON) + ENDIF() +# 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() + IF(DEFINED _SALOME_OPTIONAL_PACKAGES_names) + MESSAGE(STATUS "") + MESSAGE(STATUS " Optional packages - Detection report ") + MESSAGE(STATUS " ==================================== ") + MESSAGE(STATUS "") + 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() + MESSAGE(STATUS "") + MESSAGE(STATUS "") + ENDIF(DEFINED _SALOME_OPTIONAL_PACKAGES_names) + + # 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]) +# +# example: SALOME_FIND_PACKAGE(SalomeVTK VTK CONFIG) +# +# Encapsulate the call to the standard FIND_PACKAGE(standardPackageName) passing all the options +# 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. +# +#### +MACRO(SALOME_FIND_PACKAGE englobPkg stdPkg mode) + SET(_OPT_ARG ${ARGV3}) + # Only bother if the package was not already found: + # Some old packages use the lower case version - standard should be to always use + # upper case: + STRING(TOUPPER ${stdPkg} stdPkgUC) + IF(NOT (${stdPkg}_FOUND OR ${stdPkgUC}_FOUND)) + IF(${englobPkg}_FIND_QUIETLY OR _OPT_ARG) + SET(_tmp_quiet "QUIET") + ELSE() + SET(_tmp_quiet) + ENDIF() + IF(${englobPkg}_FIND_REQUIRED AND NOT _OPT_ARG) + SET(_tmp_req "REQUIRED") + ELSE() + SET(_tmp_req) + ENDIF() + IF(${englobPkg}_FIND_VERSION_EXACT) + SET(_tmp_exact "EXACT") + ELSE() + SET(_tmp_exact) + ENDIF() + + # Call the CMake FIND_PACKAGE() command: + 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 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. + # 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? + IF(${englobPkg}_FIND_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" "adm/cmake" + 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" "adm/cmake" + 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) + + ELSEIF("${mode}" STREQUAL "MODULE") + + # Do we need to call the signature using components? + IF(${englobPkg}_FIND_COMPONENTS) + FIND_PACKAGE(${stdPkg} ${${englobPkg}_FIND_VERSION} ${_tmp_exact} + MODULE ${_tmp_quiet} ${_tmp_req} COMPONENTS ${${englobPkg}_FIND_COMPONENTS}) + ELSE() + FIND_PACKAGE(${stdPkg} ${${englobPkg}_FIND_VERSION} ${_tmp_exact} + MODULE ${_tmp_quiet} ${_tmp_req}) + ENDIF() + + ELSE() + + MESSAGE(FATAL_ERROR "Invalid mode argument in the call to the macro SALOME_FIND_PACKAGE. Should be CONFIG or MODULE.") + + ENDIF() + + ENDIF() +ENDMACRO() + + +#################################################################### +# SALOME_FIND_PACKAGE_AND_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 +# to obtain the package root directory. +# If this is a path to a file, going up one time gives the directory containing the file +# going up 2 times gives the parent directory. +# +# For example: SALOME_FIND_PACKAGE_DETECT_CONFLICTS(SWIG SWIG_EXECUTABLE 2) +# with SWIG_EXECUTABLE set to '/usr/bin/swig' +# will produce '/usr' +# +# Generic detection (and conflict check) procedure for package XYZ: +# 1. Load a potential env variable XYZ_ROOT_DIR as a default choice for the cache entry XYZ_ROOT_DIR +# If empty, load a potential XYZ_ROOT_DIR_EXP as default value (path exposed by another package depending +# directly on XYZ) +# 2. Invoke FIND_PACKAGE() in this order: +# * in CONFIG mode first (if possible): priority is given to a potential +# "XYZ-config.cmake" file +# * then switch to the standard MODULE mode, appending on CMAKE_PREFIX_PATH +# the above XYZ_ROOT_DIR variable +# 3. Extract the path actually found into a temp variable _XYZ_TMP_DIR +# 4. Warn if XYZ_ROOT_DIR is set and doesn't match what was found (e.g. when CMake found the system installation +# instead of what is pointed to by XYZ_ROOT_DIR - happens when a typo in the content of XYZ_ROOT_DIR). +# 5. Conflict detection: +# * check the temp variable against a potentially existing XYZ_ROOT_DIR_EXP +# 6. Finally expose what was *actually* found in XYZ_ROOT_DIR. +# 7. Specific stuff: for example exposing a prerequisite of XYZ to the rest of the world for future +# conflict detection. This is added after the call to the macro by the callee. +# +MACRO(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS pkg referenceVariable upCount) + ## + ## 0. Initialization + ## + PARSE_ARGUMENTS(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS "ENVVAR" "" ${ARGN}) + + # Package name, upper case + STRING(TOUPPER ${pkg} pkg_UC) + + ## + ## 1. Load environment or any previously detected root dir for the package + ## + SET(_envvar ${pkg_UC}_ROOT_DIR) + IF(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS_ENVVAR) + SET(_envvar "${SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS_ENVVAR}") + ENDIF() + IF(DEFINED ENV{${_envvar}}) + FILE(TO_CMAKE_PATH "$ENV{${_envvar}}" _${pkg_UC}_ROOT_DIR_ENV) + SET(_dflt_value "${_${pkg_UC}_ROOT_DIR_ENV}") + ELSE() + # will be blank if no package was previously loaded: + SET(_dflt_value "${${pkg_UC}_ROOT_DIR_EXP}") + ENDIF() + # Detect if the variable has been set on the command line or elsewhere: + IF(DEFINED ${_envvar}) + SET(_var_already_there TRUE) + ELSE() + SET(_var_already_there FALSE) + ENDIF() + # Make cache entry + SET(${_envvar} "${_dflt_value}" CACHE PATH "Path to ${pkg_UC} directory") + + ## + ## 2. Find package - try CONFIG mode first (i.e. looking for XYZ-config.cmake) + ## + + # Override the variable - don't append to it, as it would give precedence + # to what was stored there before! + IF(DEFINED ${_envvar}) + SET(CMAKE_PREFIX_PATH "${${_envvar}}") + ENDIF() + + # Try find_package in config mode. This has the priority, but is + # performed QUIET and not REQUIRED: + SALOME_FIND_PACKAGE("Salome${pkg}" ${pkg} NO_MODULE TRUE) + + IF (${pkg_UC}_FOUND OR ${pkg}_FOUND) + MESSAGE(STATUS "Found ${pkg} in CONFIG mode!") + ENDIF() + + # Otherwise try the standard way (module mode, with the standard CMake Find*** macro): + # 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 ${_envvar}=${${_envvar}} " + "Append -DSALOME_CMAKE_DEBUG=ON on the command line if you want to see the original CMake error.") + ELSE() + MESSAGE(WARNING "Package ${pkg} couldn't be found - did you set the corresponing root dir correctly? " + "It currently contains ${_envvar}=${${_envvar}} " + "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) + ELSE() + # Note the double de-reference of "referenceVariable": + SET(_tmp_ROOT_DIR "${${referenceVariable}}") + ENDIF() + # Up count can be reset by detection procedure + SET(_upCount ${upCount}) + IF(DEFINED ${pkg_UC}_UPCOUNT) + SET(_upCount ${${pkg_UC}_UPCOUNT}) + ENDIF() + IF(${_upCount} GREATER 0) + FOREACH(_unused RANGE 1 ${_upCount}) + GET_FILENAME_COMPONENT(_tmp_ROOT_DIR "${_tmp_ROOT_DIR}" PATH) + ENDFOREACH() + ENDIF() + + ## + ## 4. Warn if CMake found something not located under ENV(XYZ_ROOT_DIR) + ## + IF(DEFINED ENV{${_envvar}}) + SALOME_CHECK_EQUAL_PATHS(_res "${_tmp_ROOT_DIR}" "${_${pkg_UC}_ROOT_DIR_ENV}") + IF(NOT _res) + MESSAGE(WARNING "${pkg} was found, but not at the path given by the " + "environment ${_envvar}! Is the variable correctly set? " + "The two paths are: ${_tmp_ROOT_DIR} and: ${_${pkg_UC}_ROOT_DIR_ENV}") + + ELSE() + MESSAGE(STATUS "${pkg} found directory matches what was specified in the ${_envvar} variable, all good!") + ENDIF() + ELSE() + IF(NOT _var_already_there) + MESSAGE(STATUS "Variable ${_envvar} was not explicitly defined. " + "An installation was found anyway: ${_tmp_ROOT_DIR}") + ENDIF() + ENDIF() + + ## + ## 5. Conflict detection + ## From another prerequisite using the package: + ## + IF(${pkg_UC}_ROOT_DIR_EXP) + SALOME_CHECK_EQUAL_PATHS(_res "${_tmp_ROOT_DIR}" "${${pkg_UC}_ROOT_DIR_EXP}") + IF(NOT _res) + MESSAGE(WARNING "Warning: ${pkg}: detected version conflicts with a previously found ${pkg}!" + " The two paths are " ${_tmp_ROOT_DIR} " vs " ${${pkg_UC}_ROOT_DIR_EXP}) + ELSE() + MESSAGE(STATUS "${pkg} directory matches what was previously exposed by another prereq, all good!") + ENDIF() + ENDIF() + + ## + ## 6. Save the detected installation + ## + SET(${_envvar} "${_tmp_ROOT_DIR}") + + ELSE() + MESSAGE(STATUS "${pkg} was not found.") + 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_TOHEXA() +# Convert a number (smaller than 16) into hexadecimal representation +# with a leading 0. +MACRO(SALOME_TOHEXA num result) + SET(_hexa_map a b c d e f) + IF(${num} LESS 10) + SET(${result} "0${num}") + ELSE() + MATH(EXPR _res "${num}-10" ) + LIST(GET _hexa_map ${_res} _out) + SET(${result} "0${_out}") + ENDIF() +ENDMACRO(SALOME_TOHEXA) + +#################################################################### +# 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) + SET(_major) + SET(_minor) + SET(_patch) + SALOME_TOHEXA(${${_pkg_UC}_MAJOR_VERSION} _major) + SALOME_TOHEXA(${${_pkg_UC}_MINOR_VERSION} _minor) + SALOME_TOHEXA(${${_pkg_UC}_PATCH_VERSION} _patch) + SET(${_pkg_UC}_XVERSION "0x${_major}${_minor}${_patch}") + 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) + +######################################################################### +# SALOME_ACCUMULATE_ENVIRONMENT() +# +# USAGE: SALOME_ACCUMULATE_ENVIRONMENT(envvar value [value ...]) +# +# ARGUMENTS: +# envvar [in] environment variable name, e.g. PATH +# value [in] value(s) to be added to environment variable +# +# This macro is called in the various FindSalomeXYZ.cmake modules to +# accumulate environment variables, to be used later to run some command +# in proper environment. +# +# 1. Each envrironment variable is stored in specific CMake variable +# _${PROJECT_NAME}_EXTRA_ENV_, where is name of variable. +# 2. Full list of environment variable names is stored in CMake variable +# _${PROJECT_NAME}_EXTRA_ENV. +# +# Notes: +# - The arguments list can include optional CHECK or NOCHECK keywords: +# * For all arguments following CHECK keyword the macro perform an +# additional check (see below); this is the default mode, it is suitable +# for path variables (PATH, LD_LIBRARY_PATH, etc). +# * For all arguments following NOCHECK keyword, no additional check is +# performed. +# Checking an argument means that we check: +# - That the path actually exists +# - That this is not a standard system path (starting with "/usr"); this avoids +# polluting LD_LIBRARY_PATH or PATH with things like "/usr/lib64" ... +# +MACRO(SALOME_ACCUMULATE_ENVIRONMENT envvar) + SET(_is_check ON) + FOREACH(_item ${ARGN}) + IF(${_item} STREQUAL "NOCHECK") + SET(_is_check OFF) + ELSEIF(${_item} STREQUAL "CHECK") + SET(_is_check ON) + ELSE() + IF(_is_check) + IF(NOT IS_DIRECTORY ${_item}) + IF(TARGET ${_item}) + GET_TARGET_PROPERTY(_target_type ${_item} TYPE) + IF(NOT ${_target_type} STREQUAL "INTERFACE_LIBRARY") + GET_TARGET_PROPERTY(_item ${_item} LOCATION) + ENDIF() + ENDIF() + GET_FILENAME_COMPONENT(_item ${_item} PATH) + ENDIF() + IF(EXISTS ${_item}) + STRING(REGEX MATCH "^(/usr|/lib|/bin)" _usr_find ${_item}) + LIST(FIND _${PROJECT_NAME}_EXTRA_ENV_${envvar} ${_item} _res) + IF(NOT _usr_find AND _res EQUAL -1) + LIST(APPEND _${PROJECT_NAME}_EXTRA_ENV_${envvar} ${_item}) + ENDIF() + ENDIF() + ELSE(_is_check) + LIST(FIND _${PROJECT_NAME}_EXTRA_ENV_${envvar} ${_item} _res) + IF( _res EQUAL -1) + LIST(APPEND _${PROJECT_NAME}_EXTRA_ENV_${envvar} ${_item}) + ENDIF() + ENDIF(_is_check) + ENDIF() + ENDFOREACH() + + LIST(FIND _${PROJECT_NAME}_EXTRA_ENV ${envvar} _res) + IF(_res EQUAL -1) + LIST(APPEND _${PROJECT_NAME}_EXTRA_ENV ${envvar}) + ENDIF() + SET(_${PROJECT_NAME}_EXTRA_ENV_FULL "SET\(${PROJECT_NAME}_EXTRA_ENV ${_${PROJECT_NAME}_EXTRA_ENV}\)") + FOREACH(_res ${_${PROJECT_NAME}_EXTRA_ENV}) + STRING(REPLACE "${CMAKE_INSTALL_PREFIX}" "\${PACKAGE_PREFIX_DIR}" _res_path "${_${PROJECT_NAME}_EXTRA_ENV_${_res}}") + SET(_${PROJECT_NAME}_EXTRA_ENV_FULL "${_${PROJECT_NAME}_EXTRA_ENV_FULL}\nSET\(${PROJECT_NAME}_EXTRA_ENV_${_res} ${_res_path}\)") + ENDFOREACH() +ENDMACRO(SALOME_ACCUMULATE_ENVIRONMENT) + +######################################################################### +# SALOME_GENERATE_ENVIRONMENT_SCRIPT() +# +# USAGE: SALOME_GENERATE_ENVIRONMENT_SCRIPT(output script cmd opts) +# +# ARGUMENTS: +# output [out] output command, e.g. for creation of target. +# script [in] output environement script name +# cmd [in] input command, e.g. sphinx or python command. +# opts [in] options for input command (cmd). +# +# This macro is called when it's necessary to use given environment to run some command. +# Macro generates environement script using previously created variables +# _${PROJECT_NAME}_EXTRA_ENV_, where is name of variable and +# _${PROJECT_NAME}_EXTRA_ENV (see marco SALOME_ACCUMULATE_ENVIRONMENT); +# and puts generated command in proper environment into argument. To ignore +# _${PROJECT_NAME}_EXTRA_ENV_ and _${PROJECT_NAME}_EXTRA_ENV variables set +# environment variable 'SALOME_HAS_GLOBAL_ENV=1' +# +# NAMED ARGUMENTS: +# CONTEXT: is used under Windows platform only to generate command file. See explanations +# below. +# CONTEXT_NAME: is used under Windows platform only to generate command file. See +# explanations below. +# ADDITIONAL_VARIABLES: list of the additional variables to write into environment script. +# Each item of this list should be in the 'Variable=Value' format. +# +# +# Notes: +# - If