From 3a7a9497b20293c49ea965de9709576f66f93627 Mon Sep 17 00:00:00 2001 From: Artem Zhidkov Date: Fri, 9 Oct 2020 22:31:35 +0300 Subject: [PATCH] Rework building procedure and testing environment --- CMakeCommon/FindSUIT.cmake | 3 + CMakeCommon/UnitTest.cmake | 121 +++--------------------- CMakeLists.txt | 44 ++++++--- doc/gui/conf.py.in | 4 +- doc/swig/doxyfile.in | 2 +- doc/tui/doxyfile.in | 2 +- src/SHAPERGUI/resources/LightApp.xml.in | 2 +- 7 files changed, 56 insertions(+), 122 deletions(-) diff --git a/CMakeCommon/FindSUIT.cmake b/CMakeCommon/FindSUIT.cmake index 43a29f809..518b31983 100644 --- a/CMakeCommon/FindSUIT.cmake +++ b/CMakeCommon/FindSUIT.cmake @@ -46,3 +46,6 @@ ELSE(HAVE_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) diff --git a/CMakeCommon/UnitTest.cmake b/CMakeCommon/UnitTest.cmake index 6e47a8072..b3abbba73 100644 --- a/CMakeCommon/UnitTest.cmake +++ b/CMakeCommon/UnitTest.cmake @@ -42,18 +42,8 @@ ENABLE_TESTING() -MACRO(ADD_UNIT_TESTS) - if (WIN32) # different separators and path to libraries variable name - SET(_JUSTPATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_BIN};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES};${SUIT_LIB_DIR};${SALOME_KERNEL_LIBDIR};$ENV{PATH}") - STRING(REPLACE "\\" "/" _JUSTPATH "${_JUSTPATH}") - STRING(REPLACE ";" "\\;" _JUSTPATH "${_JUSTPATH}") - SET(_PYTHONPATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_ADDONS};$ENV{PYTHONPATH}") - STRING(REPLACE "\\" "/" _PYTHONPATH "${_PYTHONPATH}") - STRING(REPLACE ";" "\\;" _PYTHONPATH "${_PYTHONPATH}") - else() - SET(_LD_LIBRARY_PATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_BIN}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES}:${SUIT_LIB_DIR}:${SALOME_KERNEL_LIBDIR}:$ENV{LD_LIBRARY_PATH}") - SET(_PYTHONPATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_ADDONS}:$ENV{PYTHONPATH}") - endif() +function(GENERATE_TESTS PATH testdir TESTS) + SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env) foreach(eachFileName ${ARGN}) # Strip the ".py" suffix @@ -64,117 +54,36 @@ MACRO(ADD_UNIT_TESTS) SET(aTestName "${aSubprojectName}_${aTestName}") # Full path to the python test file beeing executed - SET(aTestFileName "${CMAKE_CURRENT_SOURCE_DIR}/Test/${eachFileName}") + SET(aTestFileName "${testdir}/${eachFileName}") IF(EXISTS ${aTestFileName}) ADD_TEST(NAME ${aTestName} COMMAND ${PYTHON_EXECUTABLE} ${aTestFileName}) - if (WIN32) # different path to libraries variable name - SET_TESTS_PROPERTIES(${aTestName} PROPERTIES - ENVIRONMENT "PATH=${_JUSTPATH};PYTHONPATH=${_PYTHONPATH};SHAPER_UNIT_TEST_IN_PROGRESS=1" + SET_TESTS_PROPERTIES(${aTestName} PROPERTIES + ENVIRONMENT "${tests_env};SHAPER_UNIT_TEST_IN_PROGRESS=1" LABELS "${aSubprojectName}") - else() - SET_TESTS_PROPERTIES(${aTestName} PROPERTIES - ENVIRONMENT "LD_LIBRARY_PATH=${_LD_LIBRARY_PATH};PYTHONPATH=${_PYTHONPATH};SHAPER_UNIT_TEST_IN_PROGRESS=1" - LABELS "${aSubprojectName}") - endif() # Debug output... #MESSAGE(STATUS "Test added: ${aTestName} file: ${aTestFileName}") ELSE(EXISTS ${aTestFileName}) MESSAGE(WARNING "Can not find the test file: ${aTestFileName}") ENDIF(EXISTS ${aTestFileName}) endforeach(eachFileName ${ARGN}) -ENDMACRO(ADD_UNIT_TESTS) +endfunction(GENERATE_TESTS) -MACRO(ADD_UNIT_TESTS_API) - if (WIN32) # different separators and path to libraries variable name - SET(_JUSTPATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_BIN};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES};${SUIT_LIB_DIR};${SALOME_KERNEL_LIBDIR};$ENV{PATH}") - STRING(REPLACE "\\" "/" _JUSTPATH "${_JUSTPATH}") - STRING(REPLACE ";" "\\;" _JUSTPATH "${_JUSTPATH}") - SET(_PYTHONPATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_ADDONS};$ENV{PYTHONPATH}") - STRING(REPLACE "\\" "/" _PYTHONPATH "${_PYTHONPATH}") - STRING(REPLACE ";" "\\;" _PYTHONPATH "${_PYTHONPATH}") - else() - SET(_LD_LIBRARY_PATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_BIN}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES}:${SUIT_LIB_DIR}:${SALOME_KERNEL_LIBDIR}:$ENV{LD_LIBRARY_PATH}") - SET(_PYTHONPATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_ADDONS}:$ENV{PYTHONPATH}") - endif() - - foreach(eachFileName ${ARGN}) - # Strip the ".py" suffix - GET_FILENAME_COMPONENT(aTestName ${eachFileName} NAME_WE) - - # Add "SubprojectName_" prefix - GET_FILENAME_COMPONENT(aSubprojectName ${CMAKE_CURRENT_SOURCE_DIR} NAME) - SET(aTestName "${aSubprojectName}_${aTestName}") +function(ADD_UNIT_TESTS) + GENERATE_TESTS(PATH "${CMAKE_CURRENT_SOURCE_DIR}/Test" TESTS ${ARGN}) +endfunction(ADD_UNIT_TESTS) - # Full path to the python test file beeing executed - SET(aTestFileName "${CMAKE_CURRENT_SOURCE_DIR}/${eachFileName}") - IF(EXISTS ${aTestFileName}) - ADD_TEST(NAME ${aTestName} - COMMAND ${PYTHON_EXECUTABLE} ${aTestFileName}) - if (WIN32) # different path to libraries variable name - SET_TESTS_PROPERTIES(${aTestName} PROPERTIES - ENVIRONMENT "PATH=${_JUSTPATH};PYTHONPATH=${_PYTHONPATH};SHAPER_UNIT_TEST_IN_PROGRESS=1" - LABELS "${aSubprojectName}") - else() - SET_TESTS_PROPERTIES(${aTestName} PROPERTIES - ENVIRONMENT "LD_LIBRARY_PATH=${_LD_LIBRARY_PATH};PYTHONPATH=${_PYTHONPATH};SHAPER_UNIT_TEST_IN_PROGRESS=1" - LABELS "${aSubprojectName}") - endif() - # Debug output... - #MESSAGE(STATUS "Test added: ${aTestName} file: ${aTestFileName}") - ELSE(EXISTS ${aTestFileName}) - MESSAGE(WARNING "Can not find the test file: ${aTestFileName}") - ENDIF(EXISTS ${aTestFileName}) - endforeach(eachFileName ${ARGN}) -ENDMACRO(ADD_UNIT_TESTS_API) +function(ADD_UNIT_TESTS_API) + GENERATE_TESTS(PATH "${CMAKE_CURRENT_SOURCE_DIR}" TESTS ${ARGN}) +endfunction(ADD_UNIT_TESTS_API) function(ADD_RESTRICTED_TESTS) SET(RESTRICTED_ROOT_DIR $ENV{RESTRICTED_ROOT_DIR} CACHE PATH "Path to the restricted repository") - if (NOT EXISTS ${RESTRICTED_ROOT_DIR}) - message(WARNING "RESTRICTED_ROOT_DIR is not specified to run restricted tests") - return() - endif() - - if (WIN32) # different separators and path to libraries variable name - SET(_JUSTPATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_BIN};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES};${SUIT_LIB_DIR};${SALOME_KERNEL_LIBDIR};$ENV{PATH}") - STRING(REPLACE "\\" "/" _JUSTPATH "${_JUSTPATH}") - STRING(REPLACE ";" "\\;" _JUSTPATH "${_JUSTPATH}") - SET(_PYTHONPATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_ADDONS};$ENV{PYTHONPATH}") - STRING(REPLACE "\\" "/" _PYTHONPATH "${_PYTHONPATH}") - STRING(REPLACE ";" "\\;" _PYTHONPATH "${_PYTHONPATH}") + if (EXISTS ${RESTRICTED_ROOT_DIR}) + GENERATE_TESTS(PATH "${RESTRICTED_ROOT_DIR}/SHAPER/bugs" TESTS ${ARGN}) else() - SET(_LD_LIBRARY_PATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_BIN}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES}:${SUIT_LIB_DIR}:${SALOME_KERNEL_LIBDIR}:$ENV{LD_LIBRARY_PATH}") - SET(_PYTHONPATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_ADDONS}:$ENV{PYTHONPATH}") + message(WARNING "RESTRICTED_ROOT_DIR is not specified to run restricted tests") endif() - - foreach(eachFileName ${ARGN}) - # Strip the ".py" suffix - GET_FILENAME_COMPONENT(aTestName ${eachFileName} NAME_WE) - - # Add "SubprojectName_" prefix - GET_FILENAME_COMPONENT(aSubprojectName ${CMAKE_CURRENT_SOURCE_DIR} NAME) - SET(aTestName "${aSubprojectName}_${aTestName}") - - # Full path to the python test file beeing executed - SET(aTestFileName "${RESTRICTED_ROOT_DIR}/SHAPER/bugs/${eachFileName}") - IF(EXISTS ${aTestFileName}) - ADD_TEST(NAME ${aTestName} - COMMAND ${PYTHON_EXECUTABLE} ${aTestFileName}) - if (WIN32) # different path to libraries variable name - SET_TESTS_PROPERTIES(${aTestName} PROPERTIES - ENVIRONMENT "PATH=${_JUSTPATH};PYTHONPATH=${_PYTHONPATH};SHAPER_UNIT_TEST_IN_PROGRESS=1" - LABELS "${aSubprojectName}") - else() - SET_TESTS_PROPERTIES(${aTestName} PROPERTIES - ENVIRONMENT "LD_LIBRARY_PATH=${_LD_LIBRARY_PATH};PYTHONPATH=${_PYTHONPATH};SHAPER_UNIT_TEST_IN_PROGRESS=1" - LABELS "${aSubprojectName}") - endif() - # Debug output... - #MESSAGE(STATUS "Test added: ${aTestName} file: ${aTestFileName}") - ELSE(EXISTS ${aTestFileName}) - MESSAGE(WARNING "Can not find the test file: ${aTestFileName}") - ENDIF(EXISTS ${aTestFileName}) - endforeach(eachFileName ${ARGN}) endfunction(ADD_RESTRICTED_TESTS) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d7500c93..8baa2bfec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,25 +20,25 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8.10) PROJECT (SHAPER) +SET(${PROJECT_NAME}_MAJOR_VERSION 9) +SET(${PROJECT_NAME}_MINOR_VERSION 6) +SET(${PROJECT_NAME}_PATCH_VERSION 0) +SET(${PROJECT_NAME}_VERSION ${${PROJECT_NAME}_MAJOR_VERSION}.${${PROJECT_NAME}_MINOR_VERSION}.${${PROJECT_NAME}_PATCH_VERSION}) + # 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) -SET (SHAPER_Version 9.6.0) - SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeCommon" ${CMAKE_MODULE_PATH}) IF (NOT CADBUILDER_BUILD_DOC) OPTION(SHAPER_BUILD_DOC "Generate SHAPER documentation" ON) ENDIF(NOT CADBUILDER_BUILD_DOC) -INCLUDE(SalomeMacros) - INCLUDE(FindEclipse) INCLUDE(Common) -INCLUDE(FindSalomeQt5) INCLUDE(FindSalome) INCLUDE(FindSUIT) INCLUDE(FindTInspector) @@ -48,6 +48,7 @@ IF(${HAVE_SALOME}) IF(EXISTS ${CONFIGURATION_ROOT_DIR}) LIST(APPEND CMAKE_MODULE_PATH "${CONFIGURATION_ROOT_DIR}/cmake") INCLUDE(SalomeMacros) + INCLUDE(FindSalomeQt5) ELSE() MESSAGE(FATAL_ERROR "We absolutely need the Salome CMake configuration files, please define CONFIGURATION_ROOT_DIR !") ENDIF() @@ -68,6 +69,8 @@ IF(${HAVE_SALOME}) FIND_PACKAGE(SalomeOpenCASCADE REQUIRED) ELSE(${HAVE_SALOME}) + INCLUDE(SalomeMacros) + INCLUDE(FindSalomeQt5) INCLUDE(FindPython) INCLUDE(FindSalomeOpenCASCADE) ENDIF(${HAVE_SALOME}) @@ -81,11 +84,9 @@ IF(DEFINED ENV{LIBXML2_ROOT_DIR}) IF(WIN32) FILE(TO_CMAKE_PATH $ENV{LIBXML2_ROOT_DIR}/lib/libxml2.lib LIBXML2_LIBRARIES) FILE(TO_CMAKE_PATH $ENV{LIBXML2_ROOT_DIR}/include LIBXML2_INCLUDE_DIR) - ELSE() - IF(NOT "$ENV{LIBXML2_ROOT_DIR}" STREQUAL "/usr") - FILE(TO_CMAKE_PATH $ENV{LIBXML2_ROOT_DIR}/lib/libxml2.so LIBXML2_LIBRARIES) - FILE(TO_CMAKE_PATH $ENV{LIBXML2_ROOT_DIR}/include/libxml2 LIBXML2_INCLUDE_DIR) - ENDIF() + ELSEIF(NOT "$ENV{LIBXML2_ROOT_DIR}" STREQUAL "/usr") + FILE(TO_CMAKE_PATH $ENV{LIBXML2_ROOT_DIR}/lib/libxml2.so LIBXML2_LIBRARIES) + FILE(TO_CMAKE_PATH $ENV{LIBXML2_ROOT_DIR}/include/libxml2 LIBXML2_INCLUDE_DIR) ENDIF() ENDIF() # It could be called only once @@ -121,12 +122,33 @@ ELSE(${HAVE_SALOME}) SET(SHAPER_INSTALL_TUI_DOC doc CACHE INTERNAL "" FORCE) ENDIF(${HAVE_SALOME}) +# Test environment +# =================== + +IF(WIN32) + SALOME_ACCUMULATE_ENVIRONMENT(PATH NOCHECK "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_BIN}") + SALOME_ACCUMULATE_ENVIRONMENT(PATH NOCHECK "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG}") + SALOME_ACCUMULATE_ENVIRONMENT(PATH NOCHECK "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES}") + SALOME_ACCUMULATE_ENVIRONMENT(PATH NOCHECK "${SUIT_LIB_DIR}") + SALOME_ACCUMULATE_ENVIRONMENT(PATH NOCHECK "${SALOME_KERNEL_LIBDIR}") +ELSE(WIN32) + SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_BIN}") + SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG}") + SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES}") + SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK "${SUIT_LIB_DIR}") + SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK "${SALOME_KERNEL_LIBDIR}") +ENDIF(WIN32) + +SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG}") +SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES}") +SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_ADDONS}") + # Sketcher: Change radius of circular edges while dragging a point on the edge SET(SKETCHER_CHANGE_RADIUS_WHEN_MOVE TRUE) SET(MAKE_TRANSLATION YES) +ADD_DEFINITIONS( -DMAKE_TRANSLATION ) - ADD_DEFINITIONS( -DMAKE_TRANSLATION ) ADD_SUBDIRECTORY (src/Config) ADD_SUBDIRECTORY (src/Locale) ADD_SUBDIRECTORY (src/Events) diff --git a/doc/gui/conf.py.in b/doc/gui/conf.py.in index d6a8bebf2..d1327b144 100644 --- a/doc/gui/conf.py.in +++ b/doc/gui/conf.py.in @@ -68,9 +68,9 @@ html_show_copyright = False # built documents. # # The short X.Y version. -version = u'@SHAPER_Version@' +version = u'@SHAPER_VERSION@' # The full version, including alpha/beta/rc tags. -release = u'@SHAPER_Version@' +release = u'@SHAPER_VERSION@' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/doc/swig/doxyfile.in b/doc/swig/doxyfile.in index eded67497..0d4795380 100644 --- a/doc/swig/doxyfile.in +++ b/doc/swig/doxyfile.in @@ -3,7 +3,7 @@ #--------------------------------------------------------------------------- DOXYFILE_ENCODING = UTF-8 PROJECT_NAME = @CMAKE_PROJECT_NAME@ -PROJECT_NUMBER = @SHAPER_Version@ +PROJECT_NUMBER = @SHAPER_VERSION@ PROJECT_BRIEF = PROJECT_LOGO = OUTPUT_DIRECTORY = diff --git a/doc/tui/doxyfile.in b/doc/tui/doxyfile.in index 538e95925..4d4d34857 100644 --- a/doc/tui/doxyfile.in +++ b/doc/tui/doxyfile.in @@ -32,7 +32,7 @@ PROJECT_NAME = @CMAKE_PROJECT_NAME@ # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = @SHAPER_Version@ +PROJECT_NUMBER = @SHAPER_VERSION@ # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer diff --git a/src/SHAPERGUI/resources/LightApp.xml.in b/src/SHAPERGUI/resources/LightApp.xml.in index 081f2b03e..33908724f 100644 --- a/src/SHAPERGUI/resources/LightApp.xml.in +++ b/src/SHAPERGUI/resources/LightApp.xml.in @@ -7,7 +7,7 @@ - +
-- 2.39.2