]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
bos #26458 Versioning of sources via git commit id (sha1)
authorvsr <vsr@opencascade.com>
Mon, 4 Oct 2021 09:09:49 +0000 (12:09 +0300)
committervsr <vsr@opencascade.com>
Mon, 4 Oct 2021 17:49:35 +0000 (20:49 +0300)
CMakeCommon/FindSUIT.cmake
CMakeCommon/FindSalome.cmake
CMakeCommon/SalomeMacros.cmake
CMakeLists.txt
src/ModuleBase/CMakeLists.txt
src/PartSet/CMakeLists.txt
src/PythonAPI/CMakeLists.txt
src/PythonAPI/__init__.py
src/SHAPERGUI/CMakeLists.txt
src/XGUI/CMakeLists.txt

index fe8e6e4e92f9d53c9d5a484204e0161e3284f1c0..42a3956a3359b258dc2c1cb1d32d94600b374c4c 100644 (file)
 #
 
 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}")
index 891a363ebf42c6b7cffedcac92bd8278f22df8c3..ff3e7d32da2b9040657aa4ec5e5b0c97e2e099c0 100644 (file)
 # 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()
index 1bbbc2b4bbbd7a5cbbed8536ea3017db825da701..e521da8a559624ec1eb8dcc5f391064d6b24b47b 100644 (file)
@@ -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()
index c566338c355ab33e7f84a192a852ffd49ca50f27..0b93f3b04a05d8afdb80ec4b3253ce21f299d4da 100644 (file)
 
 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})
index b1b93d92e85e5d09f8940521e5967a7c5f829898..3ad8e06e48ba1ec2274f4237ebee0fe49327a0ec 100644 (file)
@@ -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}
index 6bfdb34a5fb3773fa4d793bb6649c7ad3d02b48e..ebc905b4251303ca0ec6c2422c2e55bbdd14cb42 100644 (file)
@@ -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
index c31de74db858b9a89a2614d186da3205ada0b94a..7ea948ca0b6a360a7670b7dae6461d17b6866d07 100644 (file)
@@ -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)
index 5cd38a6135d95ab8a37d4236081536a7b354e833..1032880556f75355229f662fd471b4030da04d45 100644 (file)
@@ -16,3 +16,5 @@
 #
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
+
+__version__ = "@SHAPER_GIT_SHA1@"
index c54f62f8369306a0691a74681fb520c0cdb9e94a..99078ef8ddd69dcf4bce9e7bd9740ead076a951f 100644 (file)
@@ -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}
index 2d93bce21e3fa1adee474e97e50780a99830a14b..14f9b291b382a4c13dce5ab33d255c29010cb72f 100644 (file)
@@ -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})