From: SONOLET Aymeric Date: Wed, 20 Dec 2023 09:19:59 +0000 (+0100) Subject: format(CMake): Add CMake format pre-commit and format CMakeLists X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=aecc29d51d9790aa9df297bf94e1e7b1a0a32591;p=modules%2Fshaper.git format(CMake): Add CMake format pre-commit and format CMakeLists --- diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2b2bedf9b..488820581 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -62,3 +62,8 @@ repos: # rev: v6.2.0 # Use the sha / tag you want to point at # hooks: # - id: rstcheck + - repo: https://github.com/cheshirekow/cmake-format-precommit + rev: v0.6.10 + hooks: + - id: cmake-format + # - id: cmake-lint diff --git a/CMakeCommon/CodeCoverage.cmake b/CMakeCommon/CodeCoverage.cmake index d60e1af9b..7c2e1f53d 100644 --- a/CMakeCommon/CodeCoverage.cmake +++ b/CMakeCommon/CodeCoverage.cmake @@ -1,193 +1,188 @@ -# Copyright (c) 2012 - 2013, Lars Bilke -# All rights reserved. +# Copyright (c) 2012 - 2013, Lars Bilke All rights reserved. # -# Redistribution and use in source and binary forms, with or without modification, -# are permitted provided that the following conditions are met: +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of its contributors -# may be used to endorse or promote products derived from this software without -# specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# list of conditions and the following disclaimer. +# +# 1. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 1. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # CHANGES: # -# 2012-01-31, Lars Bilke -# - Enable Code Coverage +# 2012-01-31, Lars Bilke - Enable Code Coverage # -# 2013-09-17, Joakim Söderberg -# - Added support for Clang. -# - Some additional usage instructions. +# 2013-09-17, Joakim Söderberg - Added support for Clang. - Some additional +# usage instructions. # # USAGE: -# 0. (Mac only) If you use Xcode 5.1 make sure to patch geninfo as described here: -# http://stackoverflow.com/a/22404544/80480 +# 1. (Mac only) If you use Xcode 5.1 make sure to patch geninfo as described +# here: http://stackoverflow.com/a/22404544/80480 # # 1. Copy this file into your cmake modules path. # -# 2. Add the following line to your CMakeLists.txt: -# INCLUDE(CodeCoverage) -# -# 3. Set compiler flags to turn off optimization and enable coverage: -# SET(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage") -# SET(CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage") +# 1. Add the following line to your CMakeLists.txt: INCLUDE(CodeCoverage) # -# 3. Use the function SETUP_TARGET_FOR_COVERAGE to create a custom make target -# which runs your test executable and produces a lcov code coverage report: -# Example: -# SETUP_TARGET_FOR_COVERAGE( -# my_coverage_target # Name for custom target. -# test_driver # Name of the test driver executable that runs the tests. -# # NOTE! This should always have a ZERO as exit code -# # otherwise the coverage generation will not complete. -# coverage # Name of output directory. -# ) +# 1. Set compiler flags to turn off optimization and enable coverage: +# SET(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage") +# SET(CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage") # -# 4. Build a Debug build: -# cmake -DCMAKE_BUILD_TYPE=Debug .. -# make -# make my_coverage_target +# 1. Use the function SETUP_TARGET_FOR_COVERAGE to create a custom make target +# which runs your test executable and produces a lcov code coverage report: +# Example: SETUP_TARGET_FOR_COVERAGE( my_coverage_target # Name for custom +# target. test_driver # Name of the test driver executable that runs +# the tests. # NOTE! This should always have a ZERO as exit code # otherwise +# the coverage generation will not complete. coverage # Name of +# output directory. ) # +# 1. Build a Debug build: cmake -DCMAKE_BUILD_TYPE=Debug .. make make +# my_coverage_target # # Check prereqs -FIND_PROGRAM( GCOV_PATH gcov ) -FIND_PROGRAM( LCOV_PATH lcov ) -FIND_PROGRAM( GENHTML_PATH genhtml ) -FIND_PROGRAM( GCOVR_PATH gcovr PATHS ${CMAKE_SOURCE_DIR}/tests) - -IF(NOT GCOV_PATH) - MESSAGE(FATAL_ERROR "gcov not found! Aborting...") -ENDIF() # NOT GCOV_PATH - -IF(NOT CMAKE_COMPILER_IS_GNUCXX) - # Clang version 3.0.0 and greater now supports gcov as well. - MESSAGE(WARNING "Compiler is not GNU gcc! Clang Version 3.0.0 and greater supports gcov as well, but older versions don't.") - - IF(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - MESSAGE(FATAL_ERROR "Compiler is not GNU gcc! Aborting...") - ENDIF() -ENDIF() # NOT CMAKE_COMPILER_IS_GNUCXX - -SET(CMAKE_CXX_FLAGS_COVERAGE +find_program(GCOV_PATH gcov) +find_program(LCOV_PATH lcov) +find_program(GENHTML_PATH genhtml) +find_program(GCOVR_PATH gcovr PATHS ${CMAKE_SOURCE_DIR}/tests) + +if(NOT GCOV_PATH) + message(FATAL_ERROR "gcov not found! Aborting...") +endif() # NOT GCOV_PATH + +if(NOT CMAKE_COMPILER_IS_GNUCXX) + # Clang version 3.0.0 and greater now supports gcov as well. + message( + WARNING + "Compiler is not GNU gcc! Clang Version 3.0.0 and greater supports gcov as well, but older versions don't." + ) + + if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + message(FATAL_ERROR "Compiler is not GNU gcc! Aborting...") + endif() +endif() # NOT CMAKE_COMPILER_IS_GNUCXX + +set(CMAKE_CXX_FLAGS_COVERAGE "-g -O0 --coverage -fprofile-arcs -ftest-coverage" - CACHE STRING "Flags used by the C++ compiler during coverage builds." - FORCE ) -SET(CMAKE_C_FLAGS_COVERAGE + CACHE STRING "Flags used by the C++ compiler during coverage builds." FORCE) +set(CMAKE_C_FLAGS_COVERAGE "-g -O0 --coverage -fprofile-arcs -ftest-coverage" - CACHE STRING "Flags used by the C compiler during coverage builds." - FORCE ) -SET(CMAKE_EXE_LINKER_FLAGS_COVERAGE + CACHE STRING "Flags used by the C compiler during coverage builds." FORCE) +set(CMAKE_EXE_LINKER_FLAGS_COVERAGE "" CACHE STRING "Flags used for linking binaries during coverage builds." - FORCE ) -SET(CMAKE_SHARED_LINKER_FLAGS_COVERAGE + FORCE) +set(CMAKE_SHARED_LINKER_FLAGS_COVERAGE "" - CACHE STRING "Flags used by the shared libraries linker during coverage builds." - FORCE ) -MARK_AS_ADVANCED( - CMAKE_CXX_FLAGS_COVERAGE - CMAKE_C_FLAGS_COVERAGE - CMAKE_EXE_LINKER_FLAGS_COVERAGE - CMAKE_SHARED_LINKER_FLAGS_COVERAGE ) - -IF ( NOT (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "Coverage")) - MESSAGE( WARNING "Code coverage results with an optimized (non-Debug) build may be misleading" ) -ENDIF() # NOT CMAKE_BUILD_TYPE STREQUAL "Debug" - - -# Param _targetname The name of new the custom make target -# Param _testrunner The name of the target which runs the tests. -# MUST return ZERO always, even on errors. -# If not, no coverage report will be created! -# Param _outputname lcov output is generated as _outputname.info -# HTML report is generated in _outputname/index.html -# Optional fourth parameter is passed as arguments to _testrunner -# Pass them in list form, e.g.: "-j;2" for -j 2 -FUNCTION(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname) - - IF(NOT LCOV_PATH) - MESSAGE(FATAL_ERROR "lcov not found! Aborting...") - ENDIF() # NOT LCOV_PATH - - IF(NOT GENHTML_PATH) - MESSAGE(FATAL_ERROR "genhtml not found! Aborting...") - ENDIF() # NOT GENHTML_PATH - - # Setup target - ADD_CUSTOM_TARGET(${_targetname} - - # Cleanup lcov - ${LCOV_PATH} --directory . --zerocounters - - # Run tests - COMMAND ${_testrunner} ${ARGV3} - - # Capturing lcov counters and generating report - COMMAND ${LCOV_PATH} --directory . --capture --output-file ${_outputname}.info - COMMAND ${LCOV_PATH} --remove ${_outputname}.info 'tests/*' '/usr/*' --output-file ${_outputname}.info.cleaned - COMMAND ${GENHTML_PATH} -o ${_outputname} ${_outputname}.info.cleaned - COMMAND ${CMAKE_COMMAND} -E remove ${_outputname}.info ${_outputname}.info.cleaned - - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - COMMENT "Resetting code coverage counters to zero.\nProcessing code coverage counters and generating report." - ) - - # Show info where to find the report - ADD_CUSTOM_COMMAND(TARGET ${_targetname} POST_BUILD - COMMAND ; - COMMENT "Open ./${_outputname}/index.html in your browser to view the coverage report." - ) - -ENDFUNCTION() # SETUP_TARGET_FOR_COVERAGE - -# Param _targetname The name of new the custom make target -# Param _testrunner The name of the target which runs the tests -# Param _outputname cobertura output is generated as _outputname.xml -# Optional fourth parameter is passed as arguments to _testrunner -# Pass them in list form, e.g.: "-j;2" for -j 2 -FUNCTION(SETUP_TARGET_FOR_COVERAGE_COBERTURA _targetname _testrunner _outputname) - - IF(NOT PYTHON_EXECUTABLE) - MESSAGE(FATAL_ERROR "Python not found! Aborting...") - ENDIF() # NOT PYTHON_EXECUTABLE - - IF(NOT GCOVR_PATH) - MESSAGE(FATAL_ERROR "gcovr not found! Aborting...") - ENDIF() # NOT GCOVR_PATH - - ADD_CUSTOM_TARGET(${_targetname} - - # Run tests - ${_testrunner} ${ARGV3} - - # Running gcovr - COMMAND ${GCOVR_PATH} -x -r ${CMAKE_SOURCE_DIR} -e '${CMAKE_SOURCE_DIR}/tests/' -o ${_outputname}.xml - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - COMMENT "Running gcovr to produce Cobertura code coverage report." - ) - - # Show info where to find the report - ADD_CUSTOM_COMMAND(TARGET ${_targetname} POST_BUILD - COMMAND ; - COMMENT "Cobertura code coverage report saved in ${_outputname}.xml." - ) - -ENDFUNCTION() # SETUP_TARGET_FOR_COVERAGE_COBERTURA + CACHE STRING + "Flags used by the shared libraries linker during coverage builds." + FORCE) +mark_as_advanced( + CMAKE_CXX_FLAGS_COVERAGE CMAKE_C_FLAGS_COVERAGE + CMAKE_EXE_LINKER_FLAGS_COVERAGE CMAKE_SHARED_LINKER_FLAGS_COVERAGE) + +if(NOT (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL + "Coverage")) + message( + WARNING + "Code coverage results with an optimized (non-Debug) build may be misleading" + ) +endif() # NOT CMAKE_BUILD_TYPE STREQUAL "Debug" + +# Param _targetname The name of new the custom make target Param _testrunner +# The name of the target which runs the tests. MUST return ZERO always, even on +# errors. If not, no coverage report will be created! Param _outputname lcov +# output is generated as _outputname.info HTML report is generated in +# _outputname/index.html Optional fourth parameter is passed as arguments to +# _testrunner Pass them in list form, e.g.: "-j;2" for -j 2 +function(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname) + + if(NOT LCOV_PATH) + message(FATAL_ERROR "lcov not found! Aborting...") + endif() # NOT LCOV_PATH + + if(NOT GENHTML_PATH) + message(FATAL_ERROR "genhtml not found! Aborting...") + endif() # NOT GENHTML_PATH + + # Setup target + add_custom_target( + ${_targetname} + # Cleanup lcov + ${LCOV_PATH} --directory . --zerocounters + # Run tests + COMMAND ${_testrunner} ${ARGV3} + # Capturing lcov counters and generating report + COMMAND ${LCOV_PATH} --directory . --capture --output-file + ${_outputname}.info + COMMAND ${LCOV_PATH} --remove ${_outputname}.info 'tests/*' '/usr/*' + --output-file ${_outputname}.info.cleaned + COMMAND ${GENHTML_PATH} -o ${_outputname} ${_outputname}.info.cleaned + COMMAND ${CMAKE_COMMAND} -E remove ${_outputname}.info + ${_outputname}.info.cleaned + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + COMMENT + "Resetting code coverage counters to zero.\nProcessing code coverage counters and generating report." + ) + + # Show info where to find the report + add_custom_command( + TARGET ${_targetname} + POST_BUILD + COMMAND ; + COMMENT + "Open ./${_outputname}/index.html in your browser to view the coverage report." + ) + +endfunction() # SETUP_TARGET_FOR_COVERAGE + +# Param _targetname The name of new the custom make target Param _testrunner +# The name of the target which runs the tests Param _outputname cobertura +# output is generated as _outputname.xml Optional fourth parameter is passed as +# arguments to _testrunner Pass them in list form, e.g.: "-j;2" for -j 2 +function(SETUP_TARGET_FOR_COVERAGE_COBERTURA _targetname _testrunner + _outputname) + + if(NOT PYTHON_EXECUTABLE) + message(FATAL_ERROR "Python not found! Aborting...") + endif() # NOT PYTHON_EXECUTABLE + + if(NOT GCOVR_PATH) + message(FATAL_ERROR "gcovr not found! Aborting...") + endif() # NOT GCOVR_PATH + + add_custom_target( + ${_targetname} + # Run tests + ${_testrunner} ${ARGV3} + # Running gcovr + COMMAND ${GCOVR_PATH} -x -r ${CMAKE_SOURCE_DIR} -e + '${CMAKE_SOURCE_DIR}/tests/' -o ${_outputname}.xml + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + COMMENT "Running gcovr to produce Cobertura code coverage report.") + + # Show info where to find the report + add_custom_command( + TARGET ${_targetname} + POST_BUILD + COMMAND ; + COMMENT "Cobertura code coverage report saved in ${_outputname}.xml.") + +endfunction() # SETUP_TARGET_FOR_COVERAGE_COBERTURA diff --git a/CMakeCommon/Common.cmake b/CMakeCommon/Common.cmake index 724051951..5ad8d6a46 100644 --- a/CMakeCommon/Common.cmake +++ b/CMakeCommon/Common.cmake @@ -1,23 +1,24 @@ # Copyright (C) 2014-2023 CEA, EDF # -# 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 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. +# 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 +# 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 +# See http://www.salome-platform.org/ or email : +# webmaster.salome@opencascade.com # -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required(VERSION 2.6) cmake_policy(SET CMP0011 NEW) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) @@ -26,45 +27,48 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) set(CMAKE_INCLUDE_CURRENT_DIR ON) -IF(WIN32) - ## Specific definitions: EHsc to avoid exceptions-linkage unresolved symbols - ADD_DEFINITIONS(-DWIN32 -D_WINDOWS /EHsc) -ENDIF(WIN32) +if(WIN32) + # Specific definitions: EHsc to avoid exceptions-linkage unresolved symbols + add_definitions(-DWIN32 -D_WINDOWS /EHsc) +endif(WIN32) -IF(UNIX) - IF(CMAKE_COMPILER_IS_GNUCC) - #C++11 is not supported on some platforms, disable it - #MESSAGE(STATUS "Setting -std=c++0x flag for the gcc...") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") +if(UNIX) + if(CMAKE_COMPILER_IS_GNUCC) + # C++11 is not supported on some platforms, disable it MESSAGE(STATUS + # "Setting -std=c++0x flag for the gcc...") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") - #Supporting test coverage checks (gcov) in the DEBUG mode - IF(USE_TEST_COVERAGE) - INCLUDE(CodeCoverage) - MESSAGE(STATUS "Setting flags for gcov support the gcc...") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") - SET(CMAKE_SHARED_LINKER_FLAGS "-lgcov") + # Supporting test coverage checks (gcov) in the DEBUG mode + if(USE_TEST_COVERAGE) + include(CodeCoverage) + message(STATUS "Setting flags for gcov support the gcc...") + set(CMAKE_CXX_FLAGS + "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") + set(CMAKE_C_FLAGS + "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") + set(CMAKE_SHARED_LINKER_FLAGS "-lgcov") - SETUP_TARGET_FOR_COVERAGE(test_coverage # Name for custom target. - ctest # Name of the test driver executable that runs the tests. - coverage) # Name of output directory. + setup_target_for_coverage( + test_coverage # Name for custom target. + ctest # Name of the test driver executable that runs the tests. + coverage) # Name of output directory. - SET(USE_TEST_COVERAGE False) - ENDIF(USE_TEST_COVERAGE) + set(USE_TEST_COVERAGE False) + endif(USE_TEST_COVERAGE) - #SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -E") - #MESSAGE(STATUS "gcc flags are: " ${CMAKE_CXX_FLAGS}) - #MESSAGE(STATUS "linker flags are: " ${CMAKE_SHARED_LINKER_FLAGS}) - ENDIF(CMAKE_COMPILER_IS_GNUCC) -ENDIF(UNIX) + # SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -E") + # MESSAGE(STATUS "gcc flags are: " ${CMAKE_CXX_FLAGS}) MESSAGE(STATUS + # "linker flags are: " ${CMAKE_SHARED_LINKER_FLAGS}) + endif(CMAKE_COMPILER_IS_GNUCC) +endif(UNIX) # Set highest warnings level -IF(MSVC) - IF(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") +if(MSVC) + if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") endif() -ELSE() +else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") -ENDIF() +endif() diff --git a/CMakeCommon/FindEclipse.cmake b/CMakeCommon/FindEclipse.cmake index c4a88ffd5..9e844f72b 100644 --- a/CMakeCommon/FindEclipse.cmake +++ b/CMakeCommon/FindEclipse.cmake @@ -1,28 +1,29 @@ # Copyright (C) 2014-2023 CEA, EDF # -# 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 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. +# 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 +# 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 +# See http://www.salome-platform.org/ or email : +# webmaster.salome@opencascade.com # -IF (CMAKE_GENERATOR MATCHES "NMake Makefiles") - IF(CMAKE_BUILD_TYPE STREQUAL "Debug") - ADD_DEFINITIONS(-D_DEBUG) - ENDIF(CMAKE_BUILD_TYPE STREQUAL "Debug") - IF(WIN32) - FIND_PATH(VC_INCLUDE_PATH stdio.h) - INCLUDE_DIRECTORIES(${VC_INCLUDE_PATH}) - ENDIF(WIN32) -ENDIF (CMAKE_GENERATOR MATCHES "NMake Makefiles") +if(CMAKE_GENERATOR MATCHES "NMake Makefiles") + if(CMAKE_BUILD_TYPE STREQUAL "Debug") + add_definitions(-D_DEBUG) + endif(CMAKE_BUILD_TYPE STREQUAL "Debug") + if(WIN32) + find_path(VC_INCLUDE_PATH stdio.h) + include_directories(${VC_INCLUDE_PATH}) + endif(WIN32) +endif(CMAKE_GENERATOR MATCHES "NMake Makefiles") diff --git a/CMakeCommon/FindPlaneGCS.cmake b/CMakeCommon/FindPlaneGCS.cmake index d89508c5c..300cdcf3f 100644 --- a/CMakeCommon/FindPlaneGCS.cmake +++ b/CMakeCommon/FindPlaneGCS.cmake @@ -1,64 +1,66 @@ # Copyright (C) 2014-2023 CEA, EDF # -# 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 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. +# 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 +# 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 +# See http://www.salome-platform.org/ or email : +# webmaster.salome@opencascade.com # -# - Try to find PlaneGCS (sketcher part of FreeCAD) -# Once done this will define +# * Try to find PlaneGCS (sketcher part of FreeCAD) Once done this will define # -# PLANEGCS_FOUND - system has PlaneGCS -# PLANEGCS_INCLUDE_DIRS - the Plaine include directory -# PLANEGCS_LIBRARIES - Link these to use PlaneGCS +# PLANEGCS_FOUND - system has PlaneGCS PLANEGCS_INCLUDE_DIRS - the Plaine +# include directory PLANEGCS_LIBRARIES - Link these to use PlaneGCS -IF(NOT PLANEGCS_FIND_QUIETLY) - MESSAGE(STATUS "Try to find PlainGCS at $ENV{PLANEGCS_ROOT_DIR}...") -ENDIF() +if(NOT PLANEGCS_FIND_QUIETLY) + message(STATUS "Try to find PlainGCS at $ENV{PLANEGCS_ROOT_DIR}...") +endif() -FIND_PATH(PLANEGCS_INCLUDE_DIR NAMES GCS.h +find_path( + PLANEGCS_INCLUDE_DIR + NAMES GCS.h HINTS ENV PLANEGCS_ROOT_DIR - PATH_SUFFIXES include -) + PATH_SUFFIXES include) -FIND_PATH(PLANEGCS_CMAKE_DIR NAMES FindEigen3.cmake +find_path( + PLANEGCS_CMAKE_DIR + NAMES FindEigen3.cmake HINTS ENV PLANEGCS_ROOT_DIR - PATH_SUFFIXES cmake -) + PATH_SUFFIXES cmake) -FIND_LIBRARY(PLANEGCS_LIBRARY NAMES PlaneGCS +find_library( + PLANEGCS_LIBRARY + NAMES PlaneGCS HINTS ENV PLANEGCS_ROOT_DIR - PATH_SUFFIXES lib -) + PATH_SUFFIXES lib) # verify Eigen and Boost libraries are found -FILE(TO_CMAKE_PATH "$ENV{EIGEN_ROOT_DIR}/include/eigen3" EIGEN3_INCLUDE_DIR) -FILE(TO_CMAKE_PATH "$ENV{BOOST_ROOT_DIR}" BOOST_ROOT) -SET(CMAKE_MODULE_PATH "${PLANEGCS_CMAKE_DIR}" ${CMAKE_MODULE_PATH}) -FIND_PACKAGE(Eigen3 3.2.5 REQUIRED) -FIND_PACKAGE(Boost COMPONENTS graph REQUIRED) +file(TO_CMAKE_PATH "$ENV{EIGEN_ROOT_DIR}/include/eigen3" EIGEN3_INCLUDE_DIR) +file(TO_CMAKE_PATH "$ENV{BOOST_ROOT_DIR}" BOOST_ROOT) +set(CMAKE_MODULE_PATH "${PLANEGCS_CMAKE_DIR}" ${CMAKE_MODULE_PATH}) +find_package(Eigen3 3.2.5 REQUIRED) +find_package(Boost COMPONENTS graph REQUIRED) -IF(Boost_FOUND AND EIGEN3_FOUND) - SET(PLANEGCS_INCLUDE_DIRS ${PLANEGCS_INCLUDE_DIR}) - SET(PLANEGCS_LIBRARIES ${PLANEGCS_LIBRARY}) -ENDIF() +if(Boost_FOUND AND EIGEN3_FOUND) + set(PLANEGCS_INCLUDE_DIRS ${PLANEGCS_INCLUDE_DIR}) + set(PLANEGCS_LIBRARIES ${PLANEGCS_LIBRARY}) +endif() -# handle the QUIETLY and REQUIRED arguments and set PLANEGCS_FOUND to TRUE -# if all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(PlaneGCS - REQUIRED_VARS PLANEGCS_LIBRARY PLANEGCS_INCLUDE_DIR) +# handle the QUIETLY and REQUIRED arguments and set PLANEGCS_FOUND to TRUE if +# all listed variables are TRUE +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(PlaneGCS REQUIRED_VARS PLANEGCS_LIBRARY + PLANEGCS_INCLUDE_DIR) -MARK_AS_ADVANCED(PLANEGCS_LIBRARY PLANEGCS_INCLUDE_DIR) +mark_as_advanced(PLANEGCS_LIBRARY PLANEGCS_INCLUDE_DIR) diff --git a/CMakeCommon/FindPython.cmake b/CMakeCommon/FindPython.cmake index b085cbee1..72c9aad72 100644 --- a/CMakeCommon/FindPython.cmake +++ b/CMakeCommon/FindPython.cmake @@ -1,57 +1,66 @@ # Copyright (C) 2014-2023 CEA, EDF # -# 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 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. +# 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 +# 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 +# See http://www.salome-platform.org/ or email : +# webmaster.salome@opencascade.com # -UNSET(PYTHON_INCLUDE_DIRS) -UNSET(PYTHON_LIBRARIES) +unset(PYTHON_INCLUDE_DIRS) +unset(PYTHON_LIBRARIES) -IF(WIN32) - IF(CMAKE_BUILD_TYPE STREQUAL "Debug") - SET(PYTHON_LIBRARY_FILE "python36_d.lib") - ElSE() - SET(PYTHON_LIBRARY_FILE "python36.lib") - ENDIF() -ElSE() - SET(PYTHON_LIBRARY_FILE "libpython3.6.so") -ENDIF() +if(WIN32) + if(CMAKE_BUILD_TYPE STREQUAL "Debug") + set(PYTHON_LIBRARY_FILE "python36_d.lib") + else() + set(PYTHON_LIBRARY_FILE "python36.lib") + endif() +else() + set(PYTHON_LIBRARY_FILE "libpython3.6.so") +endif() -IF(DEFINED ENV{PYTHONHOME}) - IF(WIN32) - FILE(TO_CMAKE_PATH "$ENV{PYTHONHOME}/libs/${PYTHON_LIBRARY_FILE}" PATH_PYTHON_LIBRARY) - ElSE() - FILE(TO_CMAKE_PATH "$ENV{PYTHONHOME}/lib/${PYTHON_LIBRARY_FILE}" PATH_PYTHON_LIBRARY) - ENDIF() - SET(PYTHON_LIBRARY ${PATH_PYTHON_LIBRARY} CACHE FILEPATH "path to the python library" FORCE) -ENDIF() +if(DEFINED ENV{PYTHONHOME}) + if(WIN32) + file(TO_CMAKE_PATH "$ENV{PYTHONHOME}/libs/${PYTHON_LIBRARY_FILE}" + PATH_PYTHON_LIBRARY) + else() + file(TO_CMAKE_PATH "$ENV{PYTHONHOME}/lib/${PYTHON_LIBRARY_FILE}" + PATH_PYTHON_LIBRARY) + endif() + set(PYTHON_LIBRARY + ${PATH_PYTHON_LIBRARY} + CACHE FILEPATH "path to the python library" FORCE) +endif() -IF(DEFINED ENV{PYTHON_INCLUDE}) - FILE(TO_CMAKE_PATH $ENV{PYTHON_INCLUDE} PATH_PYTHON_INCLUDE_DIR) - SET(PYTHON_INCLUDE_DIR ${PATH_PYTHON_INCLUDE_DIR} CACHE PATH "path to where Python.h is found" FORCE) -ELSE() - IF(WIN32) - IF(DEFINED ENV{PYTHON_ROOT_DIR}) - SET(PYTHON_ROOT_DIR $ENV{PYTHON_ROOT_DIR}) - SET(PYTHON_INCLUDE_DIR ${PYTHON_ROOT_DIR} CACHE PATH "path to where Python.h is found" FORCE) - ENDIF() - ENDIF() -ENDIF() +if(DEFINED ENV{PYTHON_INCLUDE}) + file(TO_CMAKE_PATH $ENV{PYTHON_INCLUDE} PATH_PYTHON_INCLUDE_DIR) + set(PYTHON_INCLUDE_DIR + ${PATH_PYTHON_INCLUDE_DIR} + CACHE PATH "path to where Python.h is found" FORCE) +else() + if(WIN32) + if(DEFINED ENV{PYTHON_ROOT_DIR}) + set(PYTHON_ROOT_DIR $ENV{PYTHON_ROOT_DIR}) + set(PYTHON_INCLUDE_DIR + ${PYTHON_ROOT_DIR} + CACHE PATH "path to where Python.h is found" FORCE) + endif() + endif() +endif() -FIND_PACKAGE(PythonInterp REQUIRED) -FIND_PACKAGE(PythonLibs REQUIRED) +find_package(PythonInterp REQUIRED) +find_package(PythonLibs REQUIRED) -INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIR}) +include_directories(${PYTHON_INCLUDE_DIR}) diff --git a/CMakeCommon/FindSUIT.cmake b/CMakeCommon/FindSUIT.cmake index 303ba5495..afa918ae3 100644 --- a/CMakeCommon/FindSUIT.cmake +++ b/CMakeCommon/FindSUIT.cmake @@ -1,51 +1,52 @@ # Copyright (C) 2014-2023 CEA, EDF # -# 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 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. +# 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 +# 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 +# See http://www.salome-platform.org/ or email : +# webmaster.salome@opencascade.com # -IF(HAVE_SALOME) - SET(SUIT_INCLUDE "${GUI_ROOT_DIR}/include/salome") - SET(SUIT_LIB_DIR "${GUI_ROOT_DIR}/lib/salome") -ELSE(HAVE_SALOME) - SET(SUIT_DIR $ENV{SUIT_DIR}) - IF(EXISTS ${SUIT_DIR}) - MESSAGE(STATUS "SUIT found at ${SUIT_DIR}") - IF(WIN32) - SET(SUIT_LIB_DIR ${SUIT_DIR}/lib) - ElSE() - SET(SUIT_LIB_DIR ${SUIT_DIR}/lib/salome) - ENDIF() +if(HAVE_SALOME) + set(SUIT_INCLUDE "${GUI_ROOT_DIR}/include/salome") + set(SUIT_LIB_DIR "${GUI_ROOT_DIR}/lib/salome") +else(HAVE_SALOME) + set(SUIT_DIR $ENV{SUIT_DIR}) + if(EXISTS ${SUIT_DIR}) + message(STATUS "SUIT found at ${SUIT_DIR}") + if(WIN32) + set(SUIT_LIB_DIR ${SUIT_DIR}/lib) + else() + set(SUIT_LIB_DIR ${SUIT_DIR}/lib/salome) + endif() - FIND_LIBRARY(Event Event ${SUIT_LIB_DIR}) - FIND_LIBRARY(PyConsole PyConsole ${SUIT_LIB_DIR}) - FIND_LIBRARY(PyInterp PyInterp ${SUIT_LIB_DIR}) - FIND_LIBRARY(qtx qtx ${SUIT_LIB_DIR}) - FIND_LIBRARY(suit suit ${SUIT_LIB_DIR}) - FIND_LIBRARY(ViewerData ViewerData ${SUIT_LIB_DIR}) + find_library(Event Event ${SUIT_LIB_DIR}) + find_library(PyConsole PyConsole ${SUIT_LIB_DIR}) + find_library(PyInterp PyInterp ${SUIT_LIB_DIR}) + find_library(qtx qtx ${SUIT_LIB_DIR}) + find_library(suit suit ${SUIT_LIB_DIR}) + find_library(ViewerData ViewerData ${SUIT_LIB_DIR}) - IF(WIN32) - SET(SUIT_INCLUDE ${SUIT_DIR}/include) - ElSE() - SET(SUIT_INCLUDE ${SUIT_DIR}/include/salome) - ENDIF() - ENDIF(EXISTS ${SUIT_DIR}) -ENDIF(HAVE_SALOME) + if(WIN32) + set(SUIT_INCLUDE ${SUIT_DIR}/include) + else() + set(SUIT_INCLUDE ${SUIT_DIR}/include/salome) + endif() + endif(EXISTS ${SUIT_DIR}) +endif(HAVE_SALOME) -FILE(TO_CMAKE_PATH ${SUIT_LIB_DIR} SUIT_LIB_DIR) -FILE(TO_CMAKE_PATH ${SUIT_INCLUDE} SUIT_INCLUDE) -MESSAGE(STATUS "SUIT includes: ${SUIT_INCLUDE}") -MESSAGE(STATUS "SUIT libraries: ${SUIT_LIB_DIR}") +file(TO_CMAKE_PATH ${SUIT_LIB_DIR} SUIT_LIB_DIR) +file(TO_CMAKE_PATH ${SUIT_INCLUDE} SUIT_INCLUDE) +message(STATUS "SUIT includes: ${SUIT_INCLUDE}") +message(STATUS "SUIT libraries: ${SUIT_LIB_DIR}") diff --git a/CMakeCommon/FindSalome.cmake b/CMakeCommon/FindSalome.cmake index 47906ef8b..148fcf7d3 100644 --- a/CMakeCommon/FindSalome.cmake +++ b/CMakeCommon/FindSalome.cmake @@ -1,62 +1,63 @@ # Copyright (C) 2014-2023 CEA, EDF # -# 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 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. +# 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 +# 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 +# See http://www.salome-platform.org/ or email : +# webmaster.salome@opencascade.com # -IF(${HAVE_SALOME}) - FIND_LIBRARY(caf caf ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(CAM CAM ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(CASCatch CASCatch ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(DDS DDS ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(Event Event ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(GLViewer GLViewer ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(LightApp LightApp ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(LogWindow LogWindow ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(ObjBrowser ObjBrowser ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(OCCViewer OCCViewer ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(OpenGLUtils OpenGLUtils ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(Plot2d Plot2d ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(PyConsole PyConsole ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(PyInterp PyInterp ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(QDS QDS ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(qtx qtx ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(QxScene QxScene ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(SalomeApp SalomeApp ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(SalomeIDLGUI SalomeIDLGUI ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(SalomeObject SalomeObject ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(SalomePrs SalomePrs ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(SalomePyQtGUILight SalomePyQtGUILight ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(SalomePyQtGUI SalomePyQtGUI ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(SalomePyQt SalomePyQt ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(SalomePy SalomePy ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(SalomeSession SalomeSession ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(SalomeStyle SalomeStyle ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(SOCC SOCC ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(SPlot2d SPlot2d ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(std std ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(SUITApp SUITApp ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(suit suit ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(SVTK SVTK ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(ToolsGUI ToolsGUI ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(ViewerTools ViewerTools ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(ViewerData ViewerData ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(VTKViewer VTKViewer ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(vtkEDFOverloads vtkEDFOverloads ${GUI_ROOT_DIR}/lib/paraview) - FIND_LIBRARY(vtkTools vtkTools ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(SalomeGuiHelpers SalomeGuiHelpers ${GUI_ROOT_DIR}/lib/salome) - FIND_LIBRARY(SalomeTreeData SalomeTreeData ${GUI_ROOT_DIR}/lib/salome) -ENDIF() +if(${HAVE_SALOME}) + find_library(caf caf ${GUI_ROOT_DIR}/lib/salome) + find_library(CAM CAM ${GUI_ROOT_DIR}/lib/salome) + find_library(CASCatch CASCatch ${GUI_ROOT_DIR}/lib/salome) + find_library(DDS DDS ${GUI_ROOT_DIR}/lib/salome) + find_library(Event Event ${GUI_ROOT_DIR}/lib/salome) + find_library(GLViewer GLViewer ${GUI_ROOT_DIR}/lib/salome) + find_library(LightApp LightApp ${GUI_ROOT_DIR}/lib/salome) + find_library(LogWindow LogWindow ${GUI_ROOT_DIR}/lib/salome) + find_library(ObjBrowser ObjBrowser ${GUI_ROOT_DIR}/lib/salome) + find_library(OCCViewer OCCViewer ${GUI_ROOT_DIR}/lib/salome) + find_library(OpenGLUtils OpenGLUtils ${GUI_ROOT_DIR}/lib/salome) + find_library(Plot2d Plot2d ${GUI_ROOT_DIR}/lib/salome) + find_library(PyConsole PyConsole ${GUI_ROOT_DIR}/lib/salome) + find_library(PyInterp PyInterp ${GUI_ROOT_DIR}/lib/salome) + find_library(QDS QDS ${GUI_ROOT_DIR}/lib/salome) + find_library(qtx qtx ${GUI_ROOT_DIR}/lib/salome) + find_library(QxScene QxScene ${GUI_ROOT_DIR}/lib/salome) + find_library(SalomeApp SalomeApp ${GUI_ROOT_DIR}/lib/salome) + find_library(SalomeIDLGUI SalomeIDLGUI ${GUI_ROOT_DIR}/lib/salome) + find_library(SalomeObject SalomeObject ${GUI_ROOT_DIR}/lib/salome) + find_library(SalomePrs SalomePrs ${GUI_ROOT_DIR}/lib/salome) + find_library(SalomePyQtGUILight SalomePyQtGUILight ${GUI_ROOT_DIR}/lib/salome) + find_library(SalomePyQtGUI SalomePyQtGUI ${GUI_ROOT_DIR}/lib/salome) + find_library(SalomePyQt SalomePyQt ${GUI_ROOT_DIR}/lib/salome) + find_library(SalomePy SalomePy ${GUI_ROOT_DIR}/lib/salome) + find_library(SalomeSession SalomeSession ${GUI_ROOT_DIR}/lib/salome) + find_library(SalomeStyle SalomeStyle ${GUI_ROOT_DIR}/lib/salome) + find_library(SOCC SOCC ${GUI_ROOT_DIR}/lib/salome) + find_library(SPlot2d SPlot2d ${GUI_ROOT_DIR}/lib/salome) + find_library(std std ${GUI_ROOT_DIR}/lib/salome) + find_library(SUITApp SUITApp ${GUI_ROOT_DIR}/lib/salome) + find_library(suit suit ${GUI_ROOT_DIR}/lib/salome) + find_library(SVTK SVTK ${GUI_ROOT_DIR}/lib/salome) + find_library(ToolsGUI ToolsGUI ${GUI_ROOT_DIR}/lib/salome) + find_library(ViewerTools ViewerTools ${GUI_ROOT_DIR}/lib/salome) + find_library(ViewerData ViewerData ${GUI_ROOT_DIR}/lib/salome) + find_library(VTKViewer VTKViewer ${GUI_ROOT_DIR}/lib/salome) + find_library(vtkEDFOverloads vtkEDFOverloads ${GUI_ROOT_DIR}/lib/paraview) + find_library(vtkTools vtkTools ${GUI_ROOT_DIR}/lib/salome) + find_library(SalomeGuiHelpers SalomeGuiHelpers ${GUI_ROOT_DIR}/lib/salome) + find_library(SalomeTreeData SalomeTreeData ${GUI_ROOT_DIR}/lib/salome) +endif() diff --git a/CMakeCommon/FindSalomeOpenCASCADE.cmake b/CMakeCommon/FindSalomeOpenCASCADE.cmake index 54b890ff9..b4dc41fc2 100644 --- a/CMakeCommon/FindSalomeOpenCASCADE.cmake +++ b/CMakeCommon/FindSalomeOpenCASCADE.cmake @@ -1,48 +1,49 @@ # Copyright (C) 2013-2023 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 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. +# 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 +# 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 +# See http://www.salome-platform.org/ or email : +# webmaster.salome@opencascade.com # # Author: Roman NIKOLAEV # # OpenCascade detection for Salome # -# !! Please read the generic detection procedure in SalomeMacros.cmake !! +# !! Please read the generic detection procedure in SalomeMacros.cmake !! # # TODO: RNV: Check different OCCT layouts !!! -SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(OpenCASCADE OpenCASCADE_INCLUDE_DIR 2) +salome_find_package_and_detect_conflicts(OpenCASCADE OpenCASCADE_INCLUDE_DIR 2) -IF(OpenCASCADE_FOUND) +if(OpenCASCADE_FOUND) - IF(NOT CAS_FIND_QUIETLY) - MESSAGE(STATUS "Found OpenCascade version: ${OpenCASCADE_VERSION}") - ENDIF() + if(NOT CAS_FIND_QUIETLY) + message(STATUS "Found OpenCascade version: ${OpenCASCADE_VERSION}") + endif() # OPENCASCADE definitions - SET(OpenCascade_DEFINITIONS ${OpenCASCADE_C_FLAGS} ${OpenCASCADE_CXX_FLAGS}) - SET(OpenCascade_LDFLAGS ${OpenCASCADE_LINKER_FLAGS}) + set(OpenCascade_DEFINITIONS ${OpenCASCADE_C_FLAGS} ${OpenCASCADE_CXX_FLAGS}) + set(OpenCascade_LDFLAGS ${OpenCASCADE_LINKER_FLAGS}) - SALOME_ACCUMULATE_HEADERS(OpenCASCADE_INCLUDE_DIR) - SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${OpenCASCADE_LIBRARY_DIR}) + salome_accumulate_headers(OpenCASCADE_INCLUDE_DIR) + salome_accumulate_environment(LD_LIBRARY_PATH ${OpenCASCADE_LIBRARY_DIR}) -ELSE() +else() # TODO: Detect OpenCASCADE if it is distributed without CMake configuration. - IF(NOT CAS_FIND_QUIETLY) - MESSAGE(STATUS "Could not find OpenCASCADE ...") - ENDIF() -ENDIF() + if(NOT CAS_FIND_QUIETLY) + message(STATUS "Could not find OpenCASCADE ...") + endif() +endif() diff --git a/CMakeCommon/FindSalomeQt5.cmake b/CMakeCommon/FindSalomeQt5.cmake index f0ae4be7e..ffe5c7c06 100644 --- a/CMakeCommon/FindSalomeQt5.cmake +++ b/CMakeCommon/FindSalomeQt5.cmake @@ -1,99 +1,109 @@ # Copyright (C) 2013-2023 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 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. +# 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 +# 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 +# See http://www.salome-platform.org/ or email : +# webmaster.salome@opencascade.com # # Author: Adrien Bruneton # # Qt5 detection for Salome # -# !! Please read the generic detection procedure in SalomeMacros.cmake !! +# !! Please read the generic detection procedure in SalomeMacros.cmake !! # -# Qt5_FIND_COMPONENTS variable is set here to prevent ParaView to reset list of Qt5 modules, -# just to avoid extra dependencies +# Qt5_FIND_COMPONENTS variable is set here to prevent ParaView to reset list of +# Qt5 modules, just to avoid extra dependencies -SET(QT_INCLUDES) -SET(QT_DEFINITIONS) -SET(QT_LIBRARIES) +set(QT_INCLUDES) +set(QT_DEFINITIONS) +set(QT_LIBRARIES) # Find Qt5Core to get Qt version -SET(Qt5_FIND_COMPONENTS QtCore) -SET(Qt5_OPTIONAL_COMPONENTS) -SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(Qt5Core Qt5Core_INCLUDE_DIRS 1 ENVVAR QT5_ROOT_DIR) -IF(Qt5Core_FOUND) - LIST(APPEND QT_INCLUDES ${Qt5Core_INCLUDE_DIRS}) - LIST(APPEND QT_DEFINITIONS ${Qt5Core_DEFINITIONS}) - LIST(APPEND QT_LIBRARIES ${Qt5Core_LIBRARIES}) - SET(QT_VERSION "${Qt5Core_VERSION}") -ENDIF() +set(Qt5_FIND_COMPONENTS QtCore) +set(Qt5_OPTIONAL_COMPONENTS) +salome_find_package_and_detect_conflicts(Qt5Core Qt5Core_INCLUDE_DIRS 1 ENVVAR + QT5_ROOT_DIR) +if(Qt5Core_FOUND) + list(APPEND QT_INCLUDES ${Qt5Core_INCLUDE_DIRS}) + list(APPEND QT_DEFINITIONS ${Qt5Core_DEFINITIONS}) + list(APPEND QT_LIBRARIES ${Qt5Core_LIBRARIES}) + set(QT_VERSION "${Qt5Core_VERSION}") +endif() # Add mandatory Qt 5 components below -SET(Qt5_FIND_COMPONENTS Gui Widgets Network Xml OpenGL PrintSupport Help Test) +set(Qt5_FIND_COMPONENTS + Gui + Widgets + Network + Xml + OpenGL + PrintSupport + Help + Test) # Add optional Qt 5 components below -SET(Qt5_OPTIONAL_COMPONENTS) +set(Qt5_OPTIONAL_COMPONENTS) -IF ("${QT_VERSION}" VERSION_LESS "5.6.0") +if("${QT_VERSION}" VERSION_LESS "5.6.0") # QtWebKit package is used with Qt < 5.6 - LIST(APPEND Qt5_FIND_COMPONENTS WebKit WebKitWidgets) -ELSE() - # QtWebEngine package is (optionally) used with Qt >= 5.6 - # Anyway, not available with Python 3 - LIST(APPEND Qt5_OPTIONAL_COMPONENTS WebEngineCore WebEngine WebEngineWidgets) -ENDIF() + list(APPEND Qt5_FIND_COMPONENTS WebKit WebKitWidgets) +else() + # QtWebEngine package is (optionally) used with Qt >= 5.6 Anyway, not + # available with Python 3 + list(APPEND Qt5_OPTIONAL_COMPONENTS WebEngineCore WebEngine WebEngineWidgets) +endif() -IF(NOT WIN32) - ## QtX11Extras package is used on Linux only - LIST(APPEND Qt5_FIND_COMPONENTS X11Extras) -ENDIF() +if(NOT WIN32) + # QtX11Extras package is used on Linux only + list(APPEND Qt5_FIND_COMPONENTS X11Extras) +endif() -FOREACH(_Qt5_COMPONENT_ ${Qt5_FIND_COMPONENTS} ${Qt5_OPTIONAL_COMPONENTS}) - SET(_Qt5_COMPONENT Qt5${_Qt5_COMPONENT_}) - LIST(FIND Qt5_OPTIONAL_COMPONENTS ${_Qt5_COMPONENT_} idx) - IF(${idx} GREATER -1) - SET(Salome${_Qt5_COMPONENT}_FIND_QUIETLY TRUE) - ENDIF() - FIND_PACKAGE(${_Qt5_COMPONENT}) - LIST(APPEND QT_INCLUDES ${${_Qt5_COMPONENT}_INCLUDE_DIRS}) - LIST(APPEND QT_DEFINITIONS ${${_Qt5_COMPONENT}_DEFINITIONS}) - LIST(APPEND QT_LIBRARIES ${${_Qt5_COMPONENT}_LIBRARIES}) -ENDFOREACH() +foreach(_Qt5_COMPONENT_ ${Qt5_FIND_COMPONENTS} ${Qt5_OPTIONAL_COMPONENTS}) + set(_Qt5_COMPONENT Qt5${_Qt5_COMPONENT_}) + list(FIND Qt5_OPTIONAL_COMPONENTS ${_Qt5_COMPONENT_} idx) + if(${idx} GREATER -1) + set(Salome${_Qt5_COMPONENT}_FIND_QUIETLY TRUE) + endif() + find_package(${_Qt5_COMPONENT}) + list(APPEND QT_INCLUDES ${${_Qt5_COMPONENT}_INCLUDE_DIRS}) + list(APPEND QT_DEFINITIONS ${${_Qt5_COMPONENT}_DEFINITIONS}) + list(APPEND QT_LIBRARIES ${${_Qt5_COMPONENT}_LIBRARIES}) +endforeach() -FIND_PACKAGE(Qt5LinguistTools) -GET_TARGET_PROPERTY(QT_LRELEASE_EXECUTABLE Qt5::lrelease LOCATION) -MARK_AS_ADVANCED(QT_LRELEASE_EXECUTABLE) +find_package(Qt5LinguistTools) +get_target_property(QT_LRELEASE_EXECUTABLE Qt5::lrelease LOCATION) +mark_as_advanced(QT_LRELEASE_EXECUTABLE) -GET_FILENAME_COMPONENT(QT_BINARY_DIR ${QT_LRELEASE_EXECUTABLE} DIRECTORY) -MARK_AS_ADVANCED(QT_BINARY_DIR) +get_filename_component(QT_BINARY_DIR ${QT_LRELEASE_EXECUTABLE} DIRECTORY) +mark_as_advanced(QT_BINARY_DIR) -# This is only needed to correctly detect Qt help generator tool, to workaround an error -# coming from ParaView detection procedure -FIND_PROGRAM(QT_HELP_GENERATOR - qhelpgenerator - PATHS "${QT_BINARY_DIR}" - NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH - DOC "qhelpgenerator used to compile Qt help project files") -MARK_AS_ADVANCED(QT_HELP_GENERATOR) +# This is only needed to correctly detect Qt help generator tool, to workaround +# an error coming from ParaView detection procedure +find_program( + QT_HELP_GENERATOR qhelpgenerator + PATHS "${QT_BINARY_DIR}" + NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH + DOC "qhelpgenerator used to compile Qt help project files") +mark_as_advanced(QT_HELP_GENERATOR) -IF(Qt5Core_FOUND) - SALOME_ACCUMULATE_HEADERS(QT_INCLUDES) - SALOME_ACCUMULATE_ENVIRONMENT(PATH ${LINGUIST_PATH}) - SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${Qt5Core_LIBRARIES}) - GET_FILENAME_COMPONENT(Qt5_DIR ${Qt5Core_DIR} PATH) - FILE(TO_NATIVE_PATH "${Qt5_DIR}/Qt5" Qt5_DIR) - SET(SalomeQt5_COMPONENTS ${Qt5_FIND_COMPONENTS}) - MESSAGE(STATUS "Qt version is ${QT_VERSION}") -ENDIF() +if(Qt5Core_FOUND) + salome_accumulate_headers(QT_INCLUDES) + salome_accumulate_environment(PATH ${LINGUIST_PATH}) + salome_accumulate_environment(LD_LIBRARY_PATH ${Qt5Core_LIBRARIES}) + get_filename_component(Qt5_DIR ${Qt5Core_DIR} PATH) + file(TO_NATIVE_PATH "${Qt5_DIR}/Qt5" Qt5_DIR) + set(SalomeQt5_COMPONENTS ${Qt5_FIND_COMPONENTS}) + message(STATUS "Qt version is ${QT_VERSION}") +endif() diff --git a/CMakeCommon/FindSolveSpace.cmake b/CMakeCommon/FindSolveSpace.cmake index 43bfd0bdd..e157bb35c 100644 --- a/CMakeCommon/FindSolveSpace.cmake +++ b/CMakeCommon/FindSolveSpace.cmake @@ -1,50 +1,52 @@ # Copyright (C) 2014-2023 CEA, EDF # -# 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 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. +# 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 +# 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 +# See http://www.salome-platform.org/ or email : +# webmaster.salome@opencascade.com # -# - Try to find SolveSpace -# Once done this will define +# * Try to find SolveSpace Once done this will define # -# SOLVESPACE_FOUND - system has SolveSpace -# SOLVESPACE_INCLUDE_DIRS - the SolveSpace include directory -# SOLVESPACE_LIBRARIES - Link these to use SolveSpace +# SOLVESPACE_FOUND - system has SolveSpace SOLVESPACE_INCLUDE_DIRS - the +# SolveSpace include directory SOLVESPACE_LIBRARIES - Link these to use +# SolveSpace -IF(NOT SOLVESPACE_FIND_QUIETLY) - MESSAGE(STATUS "Try to find SolveSpace at $ENV{SOLVESPACE_ROOT_DIR}...") -ENDIF() +if(NOT SOLVESPACE_FIND_QUIETLY) + message(STATUS "Try to find SolveSpace at $ENV{SOLVESPACE_ROOT_DIR}...") +endif() -FIND_PATH(SOLVESPACE_INCLUDE_DIR NAMES slvs.h +find_path( + SOLVESPACE_INCLUDE_DIR + NAMES slvs.h HINTS ENV SOLVESPACE_ROOT_DIR - PATH_SUFFIXES include -) + PATH_SUFFIXES include) -FIND_LIBRARY(SOLVESPACE_LIBRARY NAMES slvs +find_library( + SOLVESPACE_LIBRARY + NAMES slvs HINTS ENV SOLVESPACE_ROOT_DIR - PATH_SUFFIXES lib -) + PATH_SUFFIXES lib) -SET(SOLVESPACE_INCLUDE_DIRS ${SOLVESPACE_INCLUDE_DIR}) -SET(SOLVESPACE_LIBRARIES ${SOLVESPACE_LIBRARY}) +set(SOLVESPACE_INCLUDE_DIRS ${SOLVESPACE_INCLUDE_DIR}) +set(SOLVESPACE_LIBRARIES ${SOLVESPACE_LIBRARY}) -# handle the QUIETLY and REQUIRED arguments and set SOLVESPACE_FOUND to TRUE -# if all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(SolveSpace - REQUIRED_VARS SOLVESPACE_LIBRARY SOLVESPACE_INCLUDE_DIR) +# handle the QUIETLY and REQUIRED arguments and set SOLVESPACE_FOUND to TRUE if +# all listed variables are TRUE +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + SolveSpace REQUIRED_VARS SOLVESPACE_LIBRARY SOLVESPACE_INCLUDE_DIR) -MARK_AS_ADVANCED(SOLVESPACE_LIBRARY SOLVESPACE_INCLUDE_DIR) +mark_as_advanced(SOLVESPACE_LIBRARY SOLVESPACE_INCLUDE_DIR) diff --git a/CMakeCommon/FindSphinx.cmake b/CMakeCommon/FindSphinx.cmake index 9a4bff888..1ea8d8baf 100644 --- a/CMakeCommon/FindSphinx.cmake +++ b/CMakeCommon/FindSphinx.cmake @@ -1,63 +1,75 @@ -# - Sphinx detection +# * Sphinx detection # -# Output variables: -# SPHINX_EXECUTABLE - path to the Sphinx executable -# SPHINX_PYTHONPATH - path to the Sphinx Python modules +# Output variables: SPHINX_EXECUTABLE - path to the Sphinx executable +# SPHINX_PYTHONPATH - path to the Sphinx Python modules # -########################################################################### +# ############################################################################## # Copyright (C) 2013-2023 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 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. +# 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 +# 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 +# See http://www.salome-platform.org/ or email : +# webmaster.salome@opencascade.com # -FIND_PROGRAM(SPHINX_EXECUTABLE - NAMES sphinx-build sphinx-build-${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} - PATH_SUFFIXES Scripts) -FIND_PROGRAM(SPHINX_APIDOC_EXECUTABLE - NAMES sphinx-apidoc sphinx-apidoc-${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} - PATH_SUFFIXES Scripts) +find_program( + SPHINX_EXECUTABLE + NAMES sphinx-build + sphinx-build-${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} + PATH_SUFFIXES Scripts) +find_program( + SPHINX_APIDOC_EXECUTABLE + NAMES sphinx-apidoc + sphinx-apidoc-${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} + PATH_SUFFIXES Scripts) # Get root dir locally, going up two levels from the exec: -GET_FILENAME_COMPONENT(_tmp_ROOT_DIR "${SPHINX_EXECUTABLE}" PATH) -GET_FILENAME_COMPONENT(_tmp_ROOT_DIR "${_tmp_ROOT_DIR}" PATH) -IF(WIN32) - SET(SPHINX_PYTHONPATH "${_tmp_ROOT_DIR}/lib/site-packages") -ELSE() - SET(SPHINX_PYTHONPATH "${_tmp_ROOT_DIR}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages") -ENDIF() +get_filename_component(_tmp_ROOT_DIR "${SPHINX_EXECUTABLE}" PATH) +get_filename_component(_tmp_ROOT_DIR "${_tmp_ROOT_DIR}" PATH) +if(WIN32) + set(SPHINX_PYTHONPATH "${_tmp_ROOT_DIR}/lib/site-packages") +else() + set(SPHINX_PYTHONPATH + "${_tmp_ROOT_DIR}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages" + ) +endif() # Handle the standard arguments of the find_package() command: -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Sphinx REQUIRED_VARS SPHINX_EXECUTABLE SPHINX_APIDOC_EXECUTABLE) +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Sphinx REQUIRED_VARS SPHINX_EXECUTABLE + SPHINX_APIDOC_EXECUTABLE) -IF(SPHINX_EXECUTABLE) - IF(WIN32) - # Call Sphinx through the Python executable to eliminate the problem related to starting the Sphinx's process. - GET_FILENAME_COMPONENT(_tmp_ROOT_DIR "${SPHINX_EXECUTABLE}" PATH) - GET_FILENAME_COMPONENT(_tmp_FILENAME "${SPHINX_EXECUTABLE}" NAME_WE) - SET(SPHINX_EXECUTABLE "${PYTHON_EXECUTABLE}" "${_tmp_ROOT_DIR}/${_tmp_FILENAME}-script.py") - ENDIF() +if(SPHINX_EXECUTABLE) + if(WIN32) + # Call Sphinx through the Python executable to eliminate the problem related + # to starting the Sphinx's process. + get_filename_component(_tmp_ROOT_DIR "${SPHINX_EXECUTABLE}" PATH) + get_filename_component(_tmp_FILENAME "${SPHINX_EXECUTABLE}" NAME_WE) + set(SPHINX_EXECUTABLE "${PYTHON_EXECUTABLE}" + "${_tmp_ROOT_DIR}/${_tmp_FILENAME}-script.py") + endif() - EXECUTE_PROCESS(COMMAND ${SPHINX_EXECUTABLE} "--version" OUTPUT_VARIABLE SPHINX_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) - STRING(REGEX REPLACE ".* ([0-9.]+)$" "\\1" SPHINX_VERSION "${SPHINX_VERSION}" ) - MESSAGE(STATUS "Sphinx version is ${SPHINX_VERSION}") - IF(SPHINX_VERSION VERSION_LESS "1.3") - SET(SPHINX_THEME "default") - ELSE() - SET(SPHINX_THEME "classic") - ENDIF() -ENDIF(SPHINX_EXECUTABLE) + execute_process( + COMMAND ${SPHINX_EXECUTABLE} "--version" + OUTPUT_VARIABLE SPHINX_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE) + string(REGEX REPLACE ".* ([0-9.]+)$" "\\1" SPHINX_VERSION "${SPHINX_VERSION}") + message(STATUS "Sphinx version is ${SPHINX_VERSION}") + if(SPHINX_VERSION VERSION_LESS "1.3") + set(SPHINX_THEME "default") + else() + set(SPHINX_THEME "classic") + endif() +endif(SPHINX_EXECUTABLE) diff --git a/CMakeCommon/FindTInspector.cmake b/CMakeCommon/FindTInspector.cmake index 9817c4f2f..c38536ede 100644 --- a/CMakeCommon/FindTInspector.cmake +++ b/CMakeCommon/FindTInspector.cmake @@ -1,53 +1,55 @@ # Copyright (C) 2014-2023 CEA, EDF # -# 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 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. +# 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 +# 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 +# See http://www.salome-platform.org/ or email : +# webmaster.salome@opencascade.com # -# - Try to find TInspector -# Once done this will define +# * Try to find TInspector Once done this will define # -# TInspector - system has OCCT tool inspector -# TINSPECTOR_INCLUDE_DIRS - the tool inspector include directory -# TINSPECTOR_LIBRARIES - Link these to use TInspector +# TInspector - system has OCCT tool inspector TINSPECTOR_INCLUDE_DIRS - the tool +# inspector include directory TINSPECTOR_LIBRARIES - Link these to use +# TInspector -SET(TINSPECTOR_ROOT_DIR $ENV{TINSPECTOR_ROOT_DIR} CACHE PATH "Path to the TInspector directory") -IF(EXISTS ${TINSPECTOR_ROOT_DIR}) - SET(TINSPECTOR_INCLUDE_DIR "${TINSPECTOR_ROOT_DIR}/inc") - SET(TINSPECTOR_LIB_DIR "${TINSPECTOR_ROOT_DIR}/lib") +set(TINSPECTOR_ROOT_DIR + $ENV{TINSPECTOR_ROOT_DIR} + CACHE PATH "Path to the TInspector directory") +if(EXISTS ${TINSPECTOR_ROOT_DIR}) + set(TINSPECTOR_INCLUDE_DIR "${TINSPECTOR_ROOT_DIR}/inc") + set(TINSPECTOR_LIB_DIR "${TINSPECTOR_ROOT_DIR}/lib") - FIND_LIBRARY(TKTInspector TKTInspector "${TINSPECTOR_LIB_DIR}") - IF(TKTInspector) - SET(TKTInspector ${TKTInspector}) - MESSAGE(STATUS "TInspector is found at ${TINSPECTOR_ROOT_DIR}") - MESSAGE(STATUS "TInspector include dir is ${TINSPECTOR_INCLUDE_DIR}") - MESSAGE(STATUS "TInspector lib dir is ${TINSPECTOR_LIB_DIR}") + find_library(TKTInspector TKTInspector "${TINSPECTOR_LIB_DIR}") + if(TKTInspector) + set(TKTInspector ${TKTInspector}) + message(STATUS "TInspector is found at ${TINSPECTOR_ROOT_DIR}") + message(STATUS "TInspector include dir is ${TINSPECTOR_INCLUDE_DIR}") + message(STATUS "TInspector lib dir is ${TINSPECTOR_LIB_DIR}") - FIND_LIBRARY(TKVInspector TKVInspector "${TINSPECTOR_LIB_DIR}") - SET(TKVInspector ${TKVInspector}) + find_library(TKVInspector TKVInspector "${TINSPECTOR_LIB_DIR}") + set(TKVInspector ${TKVInspector}) - FIND_LIBRARY(TKTInspectorAPI TKTInspectorAPI "${TINSPECTOR_LIB_DIR}") - SET(TKTInspectorAPI ${TKTInspectorAPI}) + find_library(TKTInspectorAPI TKTInspectorAPI "${TINSPECTOR_LIB_DIR}") + set(TKTInspectorAPI ${TKTInspectorAPI}) - FIND_LIBRARY(TKTreeModel TKTreeModel "${TINSPECTOR_LIB_DIR}") - SET(TKTreeModel ${TKTreeModel}) + find_library(TKTreeModel TKTreeModel "${TINSPECTOR_LIB_DIR}") + set(TKTreeModel ${TKTreeModel}) - FIND_LIBRARY(TKVInspector TKVInspector "${TINSPECTOR_LIB_DIR}") - SET(TKVInspector ${TKVInspector}) + find_library(TKVInspector TKVInspector "${TINSPECTOR_LIB_DIR}") + set(TKVInspector ${TKVInspector}) - ENDIF(TKTInspector) + endif(TKTInspector) -ENDIF(EXISTS ${TINSPECTOR_ROOT_DIR}) +endif(EXISTS ${TINSPECTOR_ROOT_DIR}) diff --git a/CMakeCommon/Logger.cmake b/CMakeCommon/Logger.cmake index 6ef2b9b3a..24863b5c2 100644 --- a/CMakeCommon/Logger.cmake +++ b/CMakeCommon/Logger.cmake @@ -1,169 +1,179 @@ # Copyright (C) 2014-2023 CEA, EDF # -# 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 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. +# 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 +# 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 +# See http://www.salome-platform.org/ or email : +# webmaster.salome@opencascade.com # -# /* C++ comment style not allowed */ - +# /* C++ comment style not allowed */ # if you are building in-source, this is the same as CMAKE_SOURCE_DIR, otherwise # this is the top level directory of your build tree -MESSAGE( STATUS "CMAKE_BINARY_DIR: " ${CMAKE_BINARY_DIR} ) +message(STATUS "CMAKE_BINARY_DIR: " ${CMAKE_BINARY_DIR}) -# if you are building in-source, this is the same as CMAKE_CURRENT_SOURCE_DIR, otherwise this -# is the directory where the compiled or generated files from the current CMakeLists.txt will go to -MESSAGE( STATUS "CMAKE_CURRENT_BINARY_DIR: " ${CMAKE_CURRENT_BINARY_DIR} ) +# if you are building in-source, this is the same as CMAKE_CURRENT_SOURCE_DIR, +# otherwise this is the directory where the compiled or generated files from the +# current CMakeLists.txt will go to +message(STATUS "CMAKE_CURRENT_BINARY_DIR: " ${CMAKE_CURRENT_BINARY_DIR}) -# this is the directory, from which cmake was started, i.e. the top level source directory -MESSAGE( STATUS "CMAKE_SOURCE_DIR: " ${CMAKE_SOURCE_DIR} ) +# this is the directory, from which cmake was started, i.e. the top level source +# directory +message(STATUS "CMAKE_SOURCE_DIR: " ${CMAKE_SOURCE_DIR}) -# this is the directory where the currently processed CMakeLists.txt is located in -MESSAGE( STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR} ) +# this is the directory where the currently processed CMakeLists.txt is located +# in +message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR}) # contains the full path to the top level directory of your build tree -MESSAGE( STATUS "PROJECT_BINARY_DIR: " ${PROJECT_BINARY_DIR} ) +message(STATUS "PROJECT_BINARY_DIR: " ${PROJECT_BINARY_DIR}) -# contains the full path to the root of your project source directory, -# i.e. to the nearest directory where CMakeLists.txt contains the PROJECT() command -MESSAGE( STATUS "PROJECT_SOURCE_DIR: " ${PROJECT_SOURCE_DIR} ) +# contains the full path to the root of your project source directory, i.e. to +# the nearest directory where CMakeLists.txt contains the PROJECT() command +message(STATUS "PROJECT_SOURCE_DIR: " ${PROJECT_SOURCE_DIR}) -# set this variable to specify a common place where CMake should put all executable files -# (instead of CMAKE_CURRENT_BINARY_DIR) -MESSAGE( STATUS "EXECUTABLE_OUTPUT_PATH: " ${EXECUTABLE_OUTPUT_PATH} ) +# set this variable to specify a common place where CMake should put all +# executable files (instead of CMAKE_CURRENT_BINARY_DIR) +message(STATUS "EXECUTABLE_OUTPUT_PATH: " ${EXECUTABLE_OUTPUT_PATH}) -# set this variable to specify a common place where CMake should put all libraries -# (instead of CMAKE_CURRENT_BINARY_DIR) -MESSAGE( STATUS "LIBRARY_OUTPUT_PATH: " ${LIBRARY_OUTPUT_PATH} ) +# set this variable to specify a common place where CMake should put all +# libraries (instead of CMAKE_CURRENT_BINARY_DIR) +message(STATUS "LIBRARY_OUTPUT_PATH: " ${LIBRARY_OUTPUT_PATH}) -# tell CMake to search first in directories listed in CMAKE_MODULE_PATH -# when you use FIND_PACKAGE() or INCLUDE() -MESSAGE( STATUS "CMAKE_MODULE_PATH: " ${CMAKE_MODULE_PATH} ) +# tell CMake to search first in directories listed in CMAKE_MODULE_PATH when you +# use FIND_PACKAGE() or INCLUDE() +message(STATUS "CMAKE_MODULE_PATH: " ${CMAKE_MODULE_PATH}) -# this is the complete path of the cmake which runs currently (e.g. /usr/local/bin/cmake) -MESSAGE( STATUS "CMAKE_COMMAND: " ${CMAKE_COMMAND} ) +# this is the complete path of the cmake which runs currently (e.g. +# /usr/local/bin/cmake) +message(STATUS "CMAKE_COMMAND: " ${CMAKE_COMMAND}) # this is the CMake installation directory -MESSAGE( STATUS "CMAKE_ROOT: " ${CMAKE_ROOT} ) +message(STATUS "CMAKE_ROOT: " ${CMAKE_ROOT}) -# this is the filename including the complete path of the file where this variable is used. -MESSAGE( STATUS "CMAKE_CURRENT_LIST_FILE: " ${CMAKE_CURRENT_LIST_FILE} ) +# this is the filename including the complete path of the file where this +# variable is used. +message(STATUS "CMAKE_CURRENT_LIST_FILE: " ${CMAKE_CURRENT_LIST_FILE}) # this is linenumber where the variable is used -MESSAGE( STATUS "CMAKE_CURRENT_LIST_LINE: " ${CMAKE_CURRENT_LIST_LINE} ) +message(STATUS "CMAKE_CURRENT_LIST_LINE: " ${CMAKE_CURRENT_LIST_LINE}) -# this is used when searching for include files e.g. using the FIND_PATH() command. -MESSAGE( STATUS "CMAKE_INCLUDE_PATH: " ${CMAKE_INCLUDE_PATH} ) +# this is used when searching for include files e.g. using the FIND_PATH() +# command. +message(STATUS "CMAKE_INCLUDE_PATH: " ${CMAKE_INCLUDE_PATH}) -# this is used when searching for libraries e.g. using the FIND_LIBRARY() command. -MESSAGE( STATUS "CMAKE_LIBRARY_PATH: " ${CMAKE_LIBRARY_PATH} ) +# this is used when searching for libraries e.g. using the FIND_LIBRARY() +# command. +message(STATUS "CMAKE_LIBRARY_PATH: " ${CMAKE_LIBRARY_PATH}) -# the complete system name, e.g. "Linux-2.4.22", "FreeBSD-5.4-RELEASE" or "Windows 5.1" -MESSAGE( STATUS "CMAKE_SYSTEM: " ${CMAKE_SYSTEM} ) +# the complete system name, e.g. "Linux-2.4.22", "FreeBSD-5.4-RELEASE" or +# "Windows 5.1" +message(STATUS "CMAKE_SYSTEM: " ${CMAKE_SYSTEM}) # the short system name, e.g. "Linux", "FreeBSD" or "Windows" -MESSAGE( STATUS "CMAKE_SYSTEM_NAME: " ${CMAKE_SYSTEM_NAME} ) +message(STATUS "CMAKE_SYSTEM_NAME: " ${CMAKE_SYSTEM_NAME}) # only the version part of CMAKE_SYSTEM -MESSAGE( STATUS "CMAKE_SYSTEM_VERSION: " ${CMAKE_SYSTEM_VERSION} ) +message(STATUS "CMAKE_SYSTEM_VERSION: " ${CMAKE_SYSTEM_VERSION}) # the processor name (e.g. "Intel(R) Pentium(R) M processor 2.00GHz") -MESSAGE( STATUS "CMAKE_SYSTEM_PROCESSOR: " ${CMAKE_SYSTEM_PROCESSOR} ) +message(STATUS "CMAKE_SYSTEM_PROCESSOR: " ${CMAKE_SYSTEM_PROCESSOR}) # is TRUE on all UNIX-like OS's, including Apple OS X and CygWin -MESSAGE( STATUS "UNIX: " ${UNIX} ) +message(STATUS "UNIX: " ${UNIX}) # is TRUE on Windows, including CygWin -MESSAGE( STATUS "WIN32: " ${WIN32} ) +message(STATUS "WIN32: " ${WIN32}) # is TRUE on Apple OS X -MESSAGE( STATUS "APPLE: " ${APPLE} ) +message(STATUS "APPLE: " ${APPLE}) # is TRUE when using the MinGW compiler in Windows -MESSAGE( STATUS "MINGW: " ${MINGW} ) +message(STATUS "MINGW: " ${MINGW}) # is TRUE on Windows when using the CygWin version of cmake -MESSAGE( STATUS "CYGWIN: " ${CYGWIN} ) +message(STATUS "CYGWIN: " ${CYGWIN}) # is TRUE on Windows when using a Borland compiler -MESSAGE( STATUS "BORLAND: " ${BORLAND} ) +message(STATUS "BORLAND: " ${BORLAND}) # Microsoft compiler -MESSAGE( STATUS "MSVC: " ${MSVC} ) -MESSAGE( STATUS "MSVC_IDE: " ${MSVC_IDE} ) -MESSAGE( STATUS "MSVC60: " ${MSVC60} ) -MESSAGE( STATUS "MSVC70: " ${MSVC70} ) -MESSAGE( STATUS "MSVC71: " ${MSVC71} ) -MESSAGE( STATUS "MSVC80: " ${MSVC80} ) -MESSAGE( STATUS "CMAKE_COMPILER_2005: " ${CMAKE_COMPILER_2005} ) - - -# set this to true if you don't want to rebuild the object files if the rules have changed, -# but not the actual source files or headers (e.g. if you changed the some compiler switches) -MESSAGE( STATUS "CMAKE_SKIP_RULE_DEPENDENCY: " ${CMAKE_SKIP_RULE_DEPENDENCY} ) - -# since CMake 2.1 the install rule depends on all, i.e. everything will be built before installing. -# If you don't like this, set this one to true. -MESSAGE( STATUS "CMAKE_SKIP_INSTALL_ALL_DEPENDENCY: " ${CMAKE_SKIP_INSTALL_ALL_DEPENDENCY} ) - -# If set, runtime paths are not added when using shared libraries. Default it is set to OFF -MESSAGE( STATUS "CMAKE_SKIP_RPATH: " ${CMAKE_SKIP_RPATH} ) - -# set this to true if you are using makefiles and want to see the full compile and link -# commands instead of only the shortened ones -MESSAGE( STATUS "CMAKE_VERBOSE_MAKEFILE: " ${CMAKE_VERBOSE_MAKEFILE} ) - -# this will cause CMake to not put in the rules that re-run CMake. This might be useful if -# you want to use the generated build files on another machine. -MESSAGE( STATUS "CMAKE_SUPPRESS_REGENERATION: " ${CMAKE_SUPPRESS_REGENERATION} ) - - -# A simple way to get switches to the compiler is to use ADD_DEFINITIONS(). -# But there are also two variables exactly for this purpose: +message(STATUS "MSVC: " ${MSVC}) +message(STATUS "MSVC_IDE: " ${MSVC_IDE}) +message(STATUS "MSVC60: " ${MSVC60}) +message(STATUS "MSVC70: " ${MSVC70}) +message(STATUS "MSVC71: " ${MSVC71}) +message(STATUS "MSVC80: " ${MSVC80}) +message(STATUS "CMAKE_COMPILER_2005: " ${CMAKE_COMPILER_2005}) + +# set this to true if you don't want to rebuild the object files if the rules +# have changed, but not the actual source files or headers (e.g. if you changed +# the some compiler switches) +message(STATUS "CMAKE_SKIP_RULE_DEPENDENCY: " ${CMAKE_SKIP_RULE_DEPENDENCY}) + +# since CMake 2.1 the install rule depends on all, i.e. everything will be built +# before installing. If you don't like this, set this one to true. +message(STATUS "CMAKE_SKIP_INSTALL_ALL_DEPENDENCY: " + ${CMAKE_SKIP_INSTALL_ALL_DEPENDENCY}) + +# If set, runtime paths are not added when using shared libraries. Default it is +# set to OFF +message(STATUS "CMAKE_SKIP_RPATH: " ${CMAKE_SKIP_RPATH}) + +# set this to true if you are using makefiles and want to see the full compile +# and link commands instead of only the shortened ones +message(STATUS "CMAKE_VERBOSE_MAKEFILE: " ${CMAKE_VERBOSE_MAKEFILE}) + +# this will cause CMake to not put in the rules that re-run CMake. This might be +# useful if you want to use the generated build files on another machine. +message(STATUS "CMAKE_SUPPRESS_REGENERATION: " ${CMAKE_SUPPRESS_REGENERATION}) + +# A simple way to get switches to the compiler is to use ADD_DEFINITIONS(). But +# there are also two variables exactly for this purpose: # the compiler flags for compiling C sources -MESSAGE( STATUS "CMAKE_C_FLAGS: " ${CMAKE_C_FLAGS} ) +message(STATUS "CMAKE_C_FLAGS: " ${CMAKE_C_FLAGS}) # the compiler flags for compiling C++ sources -MESSAGE( STATUS "CMAKE_CXX_FLAGS: " ${CMAKE_CXX_FLAGS} ) - +message(STATUS "CMAKE_CXX_FLAGS: " ${CMAKE_CXX_FLAGS}) # Choose the type of build. Example: SET(CMAKE_BUILD_TYPE Debug) -MESSAGE( STATUS "CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE} ) +message(STATUS "CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE}) -# if this is set to ON, then all libraries are built as shared libraries by default. -MESSAGE( STATUS "BUILD_SHARED_LIBS: " ${BUILD_SHARED_LIBS} ) +# if this is set to ON, then all libraries are built as shared libraries by +# default. +message(STATUS "BUILD_SHARED_LIBS: " ${BUILD_SHARED_LIBS}) # the compiler used for C files -MESSAGE( STATUS "CMAKE_C_COMPILER: " ${CMAKE_C_COMPILER} ) +message(STATUS "CMAKE_C_COMPILER: " ${CMAKE_C_COMPILER}) # the compiler used for C++ files -MESSAGE( STATUS "CMAKE_CXX_COMPILER: " ${CMAKE_CXX_COMPILER} ) +message(STATUS "CMAKE_CXX_COMPILER: " ${CMAKE_CXX_COMPILER}) # if the compiler is a variant of gcc, this should be set to 1 -MESSAGE( STATUS "CMAKE_COMPILER_IS_GNUCC: " ${CMAKE_COMPILER_IS_GNUCC} ) +message(STATUS "CMAKE_COMPILER_IS_GNUCC: " ${CMAKE_COMPILER_IS_GNUCC}) # if the compiler is a variant of g++, this should be set to 1 -MESSAGE( STATUS "CMAKE_COMPILER_IS_GNUCXX : " ${CMAKE_COMPILER_IS_GNUCXX} ) +message(STATUS "CMAKE_COMPILER_IS_GNUCXX : " ${CMAKE_COMPILER_IS_GNUCXX}) # the tools for creating libraries -MESSAGE( STATUS "CMAKE_AR: " ${CMAKE_AR} ) -MESSAGE( STATUS "CMAKE_RANLIB: " ${CMAKE_RANLIB} ) +message(STATUS "CMAKE_AR: " ${CMAKE_AR}) +message(STATUS "CMAKE_RANLIB: " ${CMAKE_RANLIB}) # -#MESSAGE( STATUS ": " ${} ) +# MESSAGE( STATUS ": " ${} ) -# ------------------------- End of Generic CMake Variable Logging ------------------ +# ------------------------- End of Generic CMake Variable Logging +# ------------------ diff --git a/CMakeCommon/PythonAPI.cmake b/CMakeCommon/PythonAPI.cmake index 92ac1138b..f277c99b3 100644 --- a/CMakeCommon/PythonAPI.cmake +++ b/CMakeCommon/PythonAPI.cmake @@ -1,35 +1,35 @@ # Copyright (C) 2014-2023 CEA, EDF # -# 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 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. +# 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 +# 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 +# See http://www.salome-platform.org/ or email : +# webmaster.salome@opencascade.com # find_package(SWIG REQUIRED) include(${SWIG_USE_FILE}) -#TODO(spo): is -threads necessary? +# TODO(spo): is -threads necessary? set(CMAKE_SWIG_FLAGS -threads -Wall) -# Using doxy2swig: -# Add to ModuleName.i before any %inlcude: -# %include "doxyhelp.i" -# Add to CMakeLists.txt before SWIG_ADD_MODULE(...): -# SET(SWIG_MODULE_ModuleName_EXTRA_DEPS ${SWIG_MODULE_ModuleName_EXTRA_DEPS} doxyhelp.i) +# Using doxy2swig: Add to ModuleName.i before any %inlcude: %include +# "doxyhelp.i" Add to CMakeLists.txt before SWIG_ADD_MODULE(...): +# SET(SWIG_MODULE_ModuleName_EXTRA_DEPS ${SWIG_MODULE_ModuleName_EXTRA_DEPS} +# doxyhelp.i) -#TODO(spo): why not use FindDoxygen.cmake module? +# TODO(spo): why not use FindDoxygen.cmake module? if(WIN32) find_program(DOXYGEN_EXECUTABLE Doxygen) else() @@ -42,13 +42,17 @@ configure_file(${PROJECT_SOURCE_DIR}/doc/swig/doxyfile.in doxyfile @ONLY) set(doc_sources) foreach(it "*.h;*.cpp;*.hpp;*.cxx") - file(GLOB doc_source RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${it}) + file( + GLOB doc_source + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${it}) list(APPEND doc_sources ${doc_source}) endforeach() -#message(STATUS "${doc_sources}") +# message(STATUS "${doc_sources}") -add_custom_command(OUTPUT doxyhelp.i +add_custom_command( + OUTPUT doxyhelp.i COMMAND "${DOXYGEN_EXECUTABLE}" - COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/scripts/doxy2swig.py xml/index.xml doxyhelp.i - DEPENDS ${doc_sources} ${PROJECT_SOURCE_DIR}/doc/swig/doxyfile.in -) + COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/scripts/doxy2swig.py + xml/index.xml doxyhelp.i + DEPENDS ${doc_sources} ${PROJECT_SOURCE_DIR}/doc/swig/doxyfile.in) diff --git a/CMakeCommon/SalomeMacros.cmake b/CMakeCommon/SalomeMacros.cmake index 764b1762e..32dd23bf9 100644 --- a/CMakeCommon/SalomeMacros.cmake +++ b/CMakeCommon/SalomeMacros.cmake @@ -1,40 +1,41 @@ # Copyright (C) 2012-2023 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 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. +# 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 +# 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 +# See http://www.salome-platform.org/ or email : +# webmaster.salome@opencascade.com # # Author: A.Geay, V. Sandler, A. Bruneton # -#---------------------------------------------------------------------------- +# ---------------------------------------------------------------------------- # 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. +# ---------------------------------------------------------------------------- +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...) # @@ -42,613 +43,671 @@ ENDMACRO(LIST_CONTAINS) # # 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. +# 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) - -#---------------------------------------------------------------------------- +# ---------------------------------------------------------------------------- +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" "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}) - IF(SALOME_INSTALL_SCRIPTS_WORKING_DIRECTORY) - SET(PREFIX "${SALOME_INSTALL_SCRIPTS_WORKING_DIRECTORY}/") - ENDIF(SALOME_INSTALL_SCRIPTS_WORKING_DIRECTORY) - SET(_source_prefix "${CMAKE_CURRENT_SOURCE_DIR}/") - 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 +# 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" + "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}) + if(SALOME_INSTALL_SCRIPTS_WORKING_DIRECTORY) + set(PREFIX "${SALOME_INSTALL_SCRIPTS_WORKING_DIRECTORY}/") + endif(SALOME_INSTALL_SCRIPTS_WORKING_DIRECTORY) + set(_source_prefix "${CMAKE_CURRENT_SOURCE_DIR}/") + 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( + 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)" + 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 - ) + 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) - ENDIF() -ENDMACRO(SALOME_INSTALL_SCRIPTS) - -#---------------------------------------------------------------------------- + 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) + 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]) # -# 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. -#---------------------------------------------------------------------------- -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" "" ${ARGN}) - IF(SALOME_CONFIGURE_FILE_INSTALL) - INSTALL(FILES ${_out_file} DESTINATION ${SALOME_CONFIGURE_FILE_INSTALL}) - ENDIF(SALOME_CONFIGURE_FILE_INSTALL) -ENDMACRO(SALOME_CONFIGURE_FILE) - - -####################################################################################### +# 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. +# ---------------------------------------------------------------------------- +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" "" ${ARGN}) + if(SALOME_CONFIGURE_FILE_INSTALL) + install(FILES ${_out_file} DESTINATION ${SALOME_CONFIGURE_FILE_INSTALL}) + 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_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) +# 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() + 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() + 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() + 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) +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. +# 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) - -#### +# 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. +# 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. +# 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) +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 "") + 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) + 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]) +# +# 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 ... +# 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. +# 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 +# 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() +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. + 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") + 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() + 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() -ENDMACRO() + 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. +# ############################################################################## +# 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 +# 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}) +macro(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS pkg referenceVariable upCount) + # + # 1. 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() + 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() + 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() + 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") + + # + # 1. 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. + 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) + # 1. 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() + 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 cound can be reset by detection procedure - SET(_upCount ${upCount}) - IF(DEFINED ${pkg_UC}_UPCOUNT) - SET(_upCount ${${pkg_UC}_UPCOUNT}) - ENDIF() - IF(${_upCount}) - 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 " + set(_upCount ${upCount}) + if(DEFINED ${pkg_UC}_UPCOUNT) + set(_upCount ${${pkg_UC}_UPCOUNT}) + endif() + if(${_upCount}) + foreach(_unused RANGE 1 ${_upCount}) + get_filename_component(_tmp_ROOT_DIR "${_tmp_ROOT_DIR}" PATH) + endforeach() + endif() + + # + # 1. 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) - - -#################################################################### + "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() + + # + # 1. 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() + + # + # 1. 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) - -#################################################################### +# 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 @@ -659,347 +718,349 @@ ENDMACRO(SALOME_TOHEXA) # # 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) - - -######################################################################### +# 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) - -######################################################################### +# 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 +# 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. +# 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(_item ${_item} LOCATION) - 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) - -######################################################################### +# 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(_item ${_item} LOCATION) + 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. -# -# Notes: -# - If