From: vsr Date: Mon, 4 Oct 2021 09:09:49 +0000 (+0300) Subject: bos #26458 Versioning of sources via git commit id (sha1) X-Git-Tag: V9_8_0a1~8^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1a63110bcc46e3964c5fa7dcd49ea6083bc3d0fb;p=modules%2Fshaper.git bos #26458 Versioning of sources via git commit id (sha1) --- diff --git a/CMakeCommon/FindSUIT.cmake b/CMakeCommon/FindSUIT.cmake index fe8e6e4e9..42a3956a3 100644 --- a/CMakeCommon/FindSUIT.cmake +++ b/CMakeCommon/FindSUIT.cmake @@ -18,13 +18,11 @@ # IF(HAVE_SALOME) - SET(SUIT_INCLUDE ${SALOME_GUI_INCLUDE}) - MESSAGE(STATUS "SUIT_INCLUDE: ${SALOME_GUI_INCLUDE}") + 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) @@ -49,3 +47,5 @@ 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}") diff --git a/CMakeCommon/FindSalome.cmake b/CMakeCommon/FindSalome.cmake index 891a363eb..ff3e7d32d 100644 --- a/CMakeCommon/FindSalome.cmake +++ b/CMakeCommon/FindSalome.cmake @@ -17,13 +17,7 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL directory") -SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI directory") -SET(HAVE_SALOME NO) -IF(EXISTS ${GUI_ROOT_DIR}) - MESSAGE("-- SALOME found at " ${GUI_ROOT_DIR}) - SET(HAVE_SALOME YES) - +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) @@ -65,9 +59,4 @@ IF(EXISTS ${GUI_ROOT_DIR}) 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) - - SET(SALOME_GUI_INCLUDE ${GUI_ROOT_DIR}/include/salome) - SET(SALOME_KERNEL_INCLUDE ${KERNEL_ROOT_DIR}/include/salome) - SET(SALOME_KERNEL_LIBDIR ${KERNEL_ROOT_DIR}/lib/salome) - ADD_DEFINITIONS( -DHAVE_SALOME ) -ENDIF(EXISTS ${GUI_ROOT_DIR}) +ENDIF() diff --git a/CMakeCommon/SalomeMacros.cmake b/CMakeCommon/SalomeMacros.cmake index 1bbbc2b4b..e521da8a5 100644 --- a/CMakeCommon/SalomeMacros.cmake +++ b/CMakeCommon/SalomeMacros.cmake @@ -1025,3 +1025,80 @@ MACRO(SWIG_CHECK_GENERATION swig_module) ENDIF() ENDIF() ENDMACRO(SWIG_CHECK_GENERATION) + +######################################################################### +# SALOME_SETUP_VERSION() +# +# USAGE: SALOME_SETUP_VERSION(version [DEVELOPMENT]) +# +# ARGUMENTS: +# version [in] Version decriptor (string). +# +# OPTIONS: +# DEVELOPMENT Forces setting development flag. +# +# The macro sets the following variables: +# - PROJECTNAME_MAJOR_VERSION - major version number +# - PROJECTNAME_MINOR_VERSION - minor version number +# - PROJECTNAME_PATCH_VERSION - release version number +# - PROJECTNAME_VERSION - full qualified version +# - PROJECTNAME_VERSION_DEV - development flag (0 value for released version) +# - PROJECTNAME_XVERSION - hexadecimal representation of version +# - PROJECTNAME_GIT_SHA1 - git commit's sha1 +# +FUNCTION(SALOME_SETUP_VERSION version) + # parse arguments + PARSE_ARGUMENTS(SALOME_SETUP_VERSION "" "DEVELOPMENT" ${ARGN}) + # project name in upper case (if not set in master CMakeLists.txt) + STRING(TOUPPER ${PROJECT_NAME} _pkg_uc) + # parse version component + STRING(REGEX MATCHALL "[^.]" _components "${version}") + LIST(LENGTH _components _length) + IF(${_length} GREATER 0) + LIST(GET _components 0 _major) + LIST(REMOVE_AT _components 0) + ELSE() + SET(_major 0) + ENDIF() + LIST(LENGTH _components _length) + IF(${_length} GREATER 0) + LIST(GET _components 0 _minor) + LIST(REMOVE_AT _components 0) + ELSE() + SET(_minor 0) + ENDIF() + LIST(LENGTH _components _length) + IF(${_length} GREATER 0) + LIST(GET _components 0 _patch) + LIST(REMOVE_AT _components 0) + ELSE() + SET(_patch 0) + ENDIF() + # set project version: 'major', 'minor' and 'patch' components + SET(${_pkg_uc}_MAJOR_VERSION ${_major} PARENT_SCOPE) + SET(${_pkg_uc}_MINOR_VERSION ${_minor} PARENT_SCOPE) + SET(${_pkg_uc}_PATCH_VERSION ${_patch} PARENT_SCOPE) + SET(${_pkg_uc}_VERSION ${_major}.${_minor}.${_patch} PARENT_SCOPE) + # set 'development' flag + IF(SALOME_SETUP_VERSION_DEVELOPMENT) + SET(${_pkg_uc}_VERSION_DEV 1 PARENT_SCOPE) + ELSE() + SET(${_pkg_uc}_VERSION_DEV 0 PARENT_SCOPE) + ENDIF() + # set hexa representation of version + SALOME_TOHEXA(${_major} _major_h) + SALOME_TOHEXA(${_minor} _minor_h) + SALOME_TOHEXA(${_patch} _patch_h) + SET(${_pkg_uc}_XVERSION "0x${_major_h}${_minor_h}${_patch_h}" PARENT_SCOPE) + # detect git sha1 + EXECUTE_PROCESS(COMMAND git describe --dirty --tags --match=V* --always + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + OUTPUT_VARIABLE _git_version + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + IF(_git_version) + SET(${_pkg_uc}_GIT_SHA1 "${_git_version}" PARENT_SCOPE) + ELSE(_) + SET(${_pkg_uc}_GIT_SHA1 "unknown" PARENT_SCOPE) + ENDIF() +ENDFUNCTION() diff --git a/CMakeLists.txt b/CMakeLists.txt index c566338c3..0b93f3b04 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,71 +19,84 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8.10) -PROJECT (SHAPER) -SET(${PROJECT_NAME}_MAJOR_VERSION 9) -SET(${PROJECT_NAME}_MINOR_VERSION 7) -SET(${PROJECT_NAME}_PATCH_VERSION 0) -SET(${PROJECT_NAME}_VERSION ${${PROJECT_NAME}_MAJOR_VERSION}.${${PROJECT_NAME}_MINOR_VERSION}.${${PROJECT_NAME}_PATCH_VERSION}) -SET(COMPONENT_NAME SHAPER) +# Project name +# ============ +PROJECT(SHAPER) -# Ensure a proper linker behavior: +# Ensure a proper linker behavior +# =============================== CMAKE_POLICY(SET CMP0003 NEW) IF(WIN32) CMAKE_POLICY(SET CMP0020 OLD) # disable automatic linking to qtmain.lib ENDIF(WIN32) +# Append path to common macros +# =========================== SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeCommon" ${CMAKE_MODULE_PATH}) +# Detect SALOME mode; append path to SALOME macros +# ================================================ +SET(HAVE_SALOME NO) +SET(CONFIGURATION_ROOT_DIR $ENV{CONFIGURATION_ROOT_DIR} CACHE PATH "Path to the Salome CMake configuration files") +IF(EXISTS ${CONFIGURATION_ROOT_DIR}) + SET(HAVE_SALOME YES) + MESSAGE(STATUS "SALOME found; building with SALOME!") + SET(CMAKE_MODULE_PATH "${CONFIGURATION_ROOT_DIR}/cmake" ${CMAKE_MODULE_PATH}) + INCLUDE(SalomeMacros) +ELSE() + MESSAGE(STATUS "SALOME is not found; building without it!") + INCLUDE(SalomeMacros) +ENDIF() + +# Versioning +# =========== +SALOME_SETUP_VERSION(9.7.0 DEVELOPMENT) +MESSAGE(STATUS "Building ${PROJECT_NAME} ${${PROJECT_NAME}_VERSION} from \"${${PROJECT_NAME}_GIT_SHA1}\"") +SET(COMPONENT_NAME SHAPER) + +# Options +# ======= IF (NOT CADBUILDER_BUILD_DOC) OPTION(SHAPER_BUILD_DOC "Generate SHAPER documentation" ON) ENDIF(NOT CADBUILDER_BUILD_DOC) INCLUDE(FindEclipse) INCLUDE(Common) -INCLUDE(FindSalome) -INCLUDE(FindSUIT) INCLUDE(FindTInspector) +INCLUDE(FindSalomeQt5) IF(HAVE_SALOME) - SET(CONFIGURATION_ROOT_DIR $ENV{CONFIGURATION_ROOT_DIR} CACHE PATH "Path to the Salome CMake configuration files") - IF(EXISTS ${CONFIGURATION_ROOT_DIR}) - SET(CMAKE_MODULE_PATH "${CONFIGURATION_ROOT_DIR}/cmake" ${CMAKE_MODULE_PATH}) - INCLUDE(SalomeMacros) - INCLUDE(FindSalomeQt5) - ELSE() - MESSAGE(FATAL_ERROR "We absolutely need the Salome CMake configuration files, please define CONFIGURATION_ROOT_DIR !") - ENDIF() + INCLUDE(SalomeSetupPlatform) # From CONFIGURATION + + ADD_DEFINITIONS(-DHAVE_SALOME) + SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL") IF(EXISTS ${KERNEL_ROOT_DIR}) FIND_PACKAGE(SalomeKERNEL REQUIRED) ADD_DEFINITIONS(${KERNEL_DEFINITIONS}) INCLUDE_DIRECTORIES(${KERNEL_INCLUDE_DIRS}) + SET(SALOME_KERNEL_LIBDIR ${KERNEL_ROOT_DIR}/lib/salome) ELSE(EXISTS ${KERNEL_ROOT_DIR}) MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR") ENDIF(EXISTS ${KERNEL_ROOT_DIR}) + SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI") IF(EXISTS ${GUI_ROOT_DIR}) FIND_PACKAGE(SalomeGUI REQUIRED) ELSE(EXISTS ${GUI_ROOT_DIR}) MESSAGE(FATAL_ERROR "We absolutely need a Salome GUI, please define GUI_ROOT_DIR") ENDIF(EXISTS ${GUI_ROOT_DIR}) - INCLUDE(SalomeSetupPlatform) # From CONFIGURATION FIND_PACKAGE(SalomePythonInterp REQUIRED) FIND_PACKAGE(SalomePythonLibs REQUIRED) - FIND_PACKAGE(SalomeOpenCASCADE REQUIRED) - + INCLUDE(FindSalome) ELSE() - INCLUDE(SalomeMacros) - INCLUDE(FindSalomeQt5) INCLUDE(FindPython) INCLUDE(FindSalomeOpenCASCADE) ENDIF() -# Common CMake macros -# =================== - +INCLUDE(FindSUIT) # Find LibXml2 IF(DEFINED ENV{LIBXML2_ROOT_DIR}) diff --git a/src/ModuleBase/CMakeLists.txt b/src/ModuleBase/CMakeLists.txt index b1b93d92e..3ad8e06e4 100644 --- a/src/ModuleBase/CMakeLists.txt +++ b/src/ModuleBase/CMakeLists.txt @@ -283,10 +283,6 @@ INCLUDE_DIRECTORIES( ${SUIT_INCLUDE} ) -IF(${HAVE_SALOME}) - INCLUDE_DIRECTORIES(${SALOME_KERNEL_INCLUDE}) -ENDIF(${HAVE_SALOME}) - ADD_DEFINITIONS(-DMODULEBASE_EXPORTS ${OpenCASCADE_DEFINITIONS}) ADD_LIBRARY(ModuleBase SHARED ${PROJECT_SOURCES} diff --git a/src/PartSet/CMakeLists.txt b/src/PartSet/CMakeLists.txt index 6bfdb34a5..ebc905b42 100644 --- a/src/PartSet/CMakeLists.txt +++ b/src/PartSet/CMakeLists.txt @@ -183,11 +183,9 @@ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/XGUI ${SUIT_INCLUDE} ) -IF(${HAVE_SALOME}) - INCLUDE_DIRECTORIES(${SALOME_KERNEL_INCLUDE}) -ELSE(${HAVE_SALOME}) +IF(NOT ${HAVE_SALOME}) INCLUDE_DIRECTORIES(${APPELEMENTS_INCLUDE_DIR}) -ENDIF(${HAVE_SALOME}) +ENDIF() ADD_DEFINITIONS(-DPARTSET_EXPORTS ${OpenCASCADE_DEFINITIONS}) ADD_LIBRARY(PartSet SHARED diff --git a/src/PythonAPI/CMakeLists.txt b/src/PythonAPI/CMakeLists.txt index c31de74db..7ea948ca0 100644 --- a/src/PythonAPI/CMakeLists.txt +++ b/src/PythonAPI/CMakeLists.txt @@ -18,9 +18,8 @@ # INSTALL(DIRECTORY geom model examples DESTINATION ${SHAPER_INSTALL_PYTHON_API}) -INSTALL(FILES __init__.py DESTINATION ${SHAPER_INSTALL_PYTHON_API}) -#INSTALL(FILES __init__.py DESTINATION ${_pydir}/salome) INSTALL(FILES initConfig.py DESTINATION ${SHAPER_INSTALL_PYTHON_API}) +SALOME_CONFIGURE_FILE(__init__.py __init__.py INSTALL ${SHAPER_INSTALL_PYTHON_API}) # --------- Unit tests ----------- INCLUDE(UnitTest) diff --git a/src/PythonAPI/__init__.py b/src/PythonAPI/__init__.py index 5cd38a613..103288055 100644 --- a/src/PythonAPI/__init__.py +++ b/src/PythonAPI/__init__.py @@ -16,3 +16,5 @@ # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # + +__version__ = "@SHAPER_GIT_SHA1@" diff --git a/src/SHAPERGUI/CMakeLists.txt b/src/SHAPERGUI/CMakeLists.txt index c54f62f83..99078ef8d 100644 --- a/src/SHAPERGUI/CMakeLists.txt +++ b/src/SHAPERGUI/CMakeLists.txt @@ -105,15 +105,10 @@ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/XGUI ${PROJECT_SOURCE_DIR}/src/GeomAPI ${PROJECT_SOURCE_DIR}/src/Config ${PROJECT_SOURCE_DIR}/src/ExchangePlugin - ${SALOME_GUI_INCLUDE} - ${SALOME_KERNEL_INCLUDE} + ${SUIT_INCLUDE} ${OpenCASCADE_INCLUDE_DIR} ) -IF(${HAVE_SALOME}) - INCLUDE_DIRECTORIES(${SALOME_KERNEL_INCLUDE}) -ENDIF(${HAVE_SALOME}) - ADD_LIBRARY(SHAPER SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS} diff --git a/src/XGUI/CMakeLists.txt b/src/XGUI/CMakeLists.txt index 2d93bce21..14f9b291b 100644 --- a/src/XGUI/CMakeLists.txt +++ b/src/XGUI/CMakeLists.txt @@ -207,10 +207,6 @@ SET(PROJECT_INCLUDES ${OpenCASCADE_INCLUDE_DIR} ${SUIT_INCLUDE}) -IF(${HAVE_SALOME}) - INCLUDE_DIRECTORIES(${SALOME_KERNEL_INCLUDE}) -ENDIF(${HAVE_SALOME}) - IF(NOT ${HAVE_SALOME}) SET(PROJECT_INCLUDES ${PROJECT_INCLUDES} ${APPELEMENTS_INCLUDE_DIR}) ENDIF(NOT ${HAVE_SALOME})