File size: 3,243 Bytes
68ce2fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#
# (C) Copyright 2005-2024 Johns Hopkins University (JHU), All Rights Reserved.
#
# --- begin cisst license - do not edit ---
#
# This software is provided "as is" under an open source license, with
# no warranty.  The complete license can be found in license.txt and
# http://www.cisst.org/cisst/license.txt.
#
# --- end cisst license ---

# CMakeLists.txt for cisstVector wrapping tests

# Keep a list all tests for ctest
set (CTEST_TEST_FILE ${CMAKE_CURRENT_BINARY_DIR}/CTestTestfile-cisstVectorPython.txt)
set (CTEST_TEST_FILE_AUTO ${CMAKE_CURRENT_BINARY_DIR}/CTestTestfile-cisstVectorPython-auto.txt)
file (WRITE ${CTEST_TEST_FILE} "# File generated by CMake, do not modify\n")

# Allow generated c++ code to find header files
include_directories (${CMAKE_CURRENT_SOURCE_DIR})

# We are using C++ code
cisst_add_swig_module (MODULE cisstVectorPythonTest
                       FOLDER "cisstVector/tests"
                       MODULE_LINK_LIBRARIES cisstCommon cisstVector)

# Copy the .py file generated to wherever the libraries are
add_custom_command (TARGET cisstVectorPythonTestPython
                    POST_BUILD
                    COMMAND ${CMAKE_COMMAND}
                    ARGS -E copy
                          ${CMAKE_CURRENT_BINARY_DIR}/cisstVectorPythonTest.py
                          ${LIBRARY_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/cisstVectorPythonTest.py)

# Create the scripts from .in
set (LIB cisstVector)
if (CMAKE_CONFIGURATION_TYPES)
  foreach (config ${CMAKE_CONFIGURATION_TYPES})
    configure_file (${cisst_SOURCE_DIR}/cisstTestsDriver/cisstTestsDriver.py.in
                    ${EXECUTABLE_OUTPUT_PATH}/${config}/cisstVectorTests.py
                    IMMEDIATE @ONLY)
  endforeach (config)
else (CMAKE_CONFIGURATION_TYPES)
  configure_file (${cisst_SOURCE_DIR}/cisstTestsDriver/cisstTestsDriver.py.in
                  ${EXECUTABLE_OUTPUT_PATH}/cisstVectorTests.py
                  IMMEDIATE @ONLY)
endif (CMAKE_CONFIGURATION_TYPES)

# Run the script to generate the list of tests automatically
if (WIN32)
  add_custom_target (cisstVector_CREATE_PYTHON_TESTS_LIST ALL
                     COMMAND ${cisstTestsDriver_BINARY_DIR}/cisstTestsDriverPython.bat ${CMAKE_CFG_INTDIR}
                             ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/cisstVectorTests.py ${CTEST_TEST_FILE_AUTO}
                     SOURCES ${TEST_PROGRAMS})
else (WIN32)
  add_custom_target (cisstVector_CREATE_PYTHON_TESTS_LIST ALL
                     COMMAND ${Python_EXECUTABLE} ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/cisstVectorTests.py
                             -d ${Python_EXECUTABLE} > ${CTEST_TEST_FILE_AUTO}
                     SOURCES ${TEST_PROGRAMS})
endif (WIN32)

set_property (TARGET cisstVector_CREATE_PYTHON_TESTS_LIST PROPERTY FOLDER "cisstVector/tests")

add_dependencies (cisstVector_CREATE_PYTHON_TESTS_LIST
                  cisstCommon
                  cisstVector
                  cisstCommonPython
                  cisstVectorPython
                  cisstVectorPythonTestPython)

file (APPEND ${CTEST_TEST_FILE} "include (\"${CTEST_TEST_FILE_AUTO}\")\n")

# Add all the test lists
set_directory_properties (PROPERTIES TEST_INCLUDE_FILE
                          ${CTEST_TEST_FILE})