1 ## Copyright (C) 2014-2017 CEA/DEN, EDF R&D
3 ## This library is free software; you can redistribute it and/or
4 ## modify it under the terms of the GNU Lesser General Public
5 ## License as published by the Free Software Foundation; either
6 ## version 2.1 of the License, or (at your option) any later version.
8 ## This library is distributed in the hope that it will be useful,
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 ## Lesser General Public License for more details.
13 ## You should have received a copy of the GNU Lesser General Public
14 ## License along with this library; if not, write to the Free Software
15 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 ## See http:##www.salome-platform.org/ or
18 ## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
23 file(GLOB pyFiles "*.py")
25 if (WIN32) # different separators and path to libraries variable name
26 SET(_JUSTPATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_BIN};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES};${SUIT_LIB_DIR};$ENV{PATH}")
27 STRING(REPLACE "\\" "/" _JUSTPATH "${_JUSTPATH}")
28 STRING(REPLACE ";" "\\;" _JUSTPATH "${_JUSTPATH}")
29 SET(_PYTHONPATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_ADDONS};$ENV{PYTHONPATH}")
30 STRING(REPLACE "\\" "/" _PYTHONPATH "${_PYTHONPATH}")
31 STRING(REPLACE ";" "\\;" _PYTHONPATH "${_PYTHONPATH}")
33 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}:$ENV{LD_LIBRARY_PATH}")
34 SET(_PYTHONPATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_ADDONS}:$ENV{PYTHONPATH}")
37 foreach(eachFilePath ${pyFiles})
38 # Strip the ".py" suffix
39 GET_FILENAME_COMPONENT(aTestName ${eachFilePath} NAME_WE)
41 # Add "SubprojectName_" prefix
42 GET_FILENAME_COMPONENT(aSubprojectName ${CMAKE_CURRENT_SOURCE_DIR} NAME)
43 SET(aTestName "${aSubprojectName}_${aTestName}")
45 # Full path to the python test file beeing executed
46 SET(aTestFilePath "${eachFilePath}")
47 IF(EXISTS ${aTestFilePath})
48 ADD_TEST(NAME ${aTestName} COMMAND ${PYTHON_EXECUTABLE} ${aTestFilePath})
49 if (WIN32) # different path to libraries variable name
50 SET_TESTS_PROPERTIES(${aTestName} PROPERTIES ENVIRONMENT "PATH=${_JUSTPATH};PYTHONPATH=${_PYTHONPATH}"
51 LABELS "models_tests")
53 SET_TESTS_PROPERTIES(${aTestName} PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${_LD_LIBRARY_PATH};PYTHONPATH=${_PYTHONPATH}"
54 LABELS "models_tests")
57 # MESSAGE(STATUS "Test added: ${aTestName} file: ${aTestFilePath}")
58 ELSE(EXISTS ${aTestFilePath})
59 MESSAGE(WARNING "Can not find the test file: ${aTestFilePath}")
60 ENDIF(EXISTS ${aTestFilePath})
61 endforeach(eachFilePath ${ARGN})
63 ADD_CUSTOM_TARGET(run_models_tests COMMAND ${CMAKE_CTEST_COMMAND} -C "${CMAKE_BUILD_TYPE}" -L "models_tests")