File: AddTestsC.cmake

package info (click to toggle)
xdmf 3.0%2Bgit20160803-3
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 35,388 kB
  • ctags: 36,627
  • sloc: ansic: 265,382; cpp: 162,889; python: 10,976; f90: 1,378; yacc: 687; fortran: 464; xml: 200; java: 187; lex: 125; makefile: 82; sh: 28
file content (175 lines) | stat: -rw-r--r-- 5,895 bytes parent folder | download | duplicates (5)
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
INCLUDE(TestingSetup)

# We should have one place that points to the c source directory and the c
# binary directory
SET(c_source_dir ${CMAKE_CURRENT_SOURCE_DIR})
SET(c_binary_dir ${CMAKE_CURRENT_BINARY_DIR})

# C Add Dependencies Macro
# Author: Brian Panneton
# Description: This macro adds the c test dependencies.
# 	  Note: The tests already depend on their own file
# Parameters:         
#              dependencies         = any dependencies needed for c tests
MACRO(ADD_TEST_C_DEPENDENCIES dependencies)
    IF(NOT ("${dependencies}" STREQUAL ""))
        SET_PROPERTY(GLOBAL APPEND PROPERTY C_TEST_DEPENDENCIES
            "${dependencies}"
 	)
    ENDIF()
ENDMACRO()

# C Add LDPath  Macro
# Author: Brian Panneton
# Description: This macro adds the c test ldpaths.
# Parameters:         
#               ld  = any ldpaths needed for c tests
MACRO(ADD_TEST_C_LDPATH ld)
    GET_PROPERTY(ldpath GLOBAL PROPERTY C_TEST_LDPATH)
    IF("${ld}" STRGREATER "")
        SET_PROPERTY(GLOBAL PROPERTY C_TEST_LDPATH 
                "${ldpath}${sep}${ld}" 
        )
    ENDIF()
ENDMACRO()

# C Add Path  Macro
# Author: Brian Panneton
# Description: This macro adds the c test paths.
# Parameters:         
#               p  = any paths needed for c tests
MACRO(ADD_TEST_C_PATH p)
    GET_PROPERTY(path GLOBAL PROPERTY C_TEST_PATH)
    IF("${p}" STRGREATER "")
        SET_PROPERTY(GLOBAL PROPERTY C_TEST_PATH 
                "${path}${sep}${p}" 
        )
    ENDIF()
ENDMACRO()

# C Test Macro
# Author: Brian Panneton
# Description: This macro builds and add the c test in one shot.
# Parameters:         
#		executable      = executable name
#		dup		= duplicate number
#		tdep		= test dependency (Full Test Name with Prefix)
#             	${ARGN}         = any arguments for the executable
MACRO(ADD_TEST_C executable)
    PARSE_TEST_ARGS("${ARGN}")
    
    IF(EXISTS ${c_source_dir}/${executable}.c)
        ADD_EXECUTABLE(${executable}${dup} ${c_source_dir}/${executable}.c)
    ENDIF()

    GET_PROPERTY(c_dependencies GLOBAL PROPERTY C_TEST_DEPENDENCIES)
    GET_PROPERTY(c_ldpath GLOBAL PROPERTY C_TEST_LDPATH)
    GET_PROPERTY(c_path GLOBAL PROPERTY C_TEST_PATH)
    TARGET_LINK_LIBRARIES(${executable}${dup} ${c_dependencies})
 
    # Take care of windowisims
    IF(WIN32)
        SET_TARGET_PROPERTIES(${executable}${dup} PROPERTIES 
            PREFIX ../
            RUNTIME_OUTPUT_DIRECTORY ${c_binary_dir}
            LIBRARY_OUTPUT_DIRECTORY ${c_binary_dir}
            ARCHIVE_OUTPUT_DIRECTORY ${c_binary_dir})

        IF("${c_path}" STREQUAL "")
            SET(c_path ${c_ldpath})
        ENDIF()
    ENDIF()

    SET_CORE("${c_binary_dir}")
    ADD_TEST(C${is_core}_${executable}${dup} ${CMAKE_COMMAND}
            -D "EXECUTABLE=${executable}${dup}"
            -D "ARGUMENTS=${arguments}"
            -D "LDPATH=${c_ldpath}"
            -D "PATH=${c_path}"
            -D "SEPARATOR=${sep}"
            -P "${c_binary_dir}/TestDriverC.cmake"
    )
    IF(NOT "${tdep}" STREQUAL "")
	    SET_TESTS_PROPERTIES(C${is_core}_${executable}${dup}
            PROPERTIES DEPENDS ${tdep})
    ENDIF()
ENDMACRO()

# C MPI Test Macro
# Author: Andrew Burns
# Description: This macro builds and adds a script to execute MPI tests.
# Parameters:
#               executable      = script name
#               files           = code to be compiled and executed by the script
#               tdep            = test dependency (Full Test Name with Prefix)
#               ${ARGN}         = any arguments for the executable
MACRO(ADD_MPI_TEST_C script files)
    PARSE_TEST_ARGS("${ARGN}")

    set(tempfiles ${files})

    WHILE(NOT "${tempfiles}" STREQUAL "")
        # ${executable}
        STRING(REGEX MATCH "([^ ,])+,|([^ ,])+" executable "${tempfiles}")
        STRING(REGEX REPLACE "," "" executable "${executable}")
        STRING(REGEX REPLACE "${executable},|${executable}" "" trimmed "${tempfiles}")

        set(tempfiles ${trimmed})

        IF(EXISTS ${c_source_dir}/${executable}.c)
            ADD_EXECUTABLE(${executable} ${c_source_dir}/${executable}.c)
        ENDIF()

        GET_PROPERTY(c_dependencies GLOBAL PROPERTY C_TEST_DEPENDENCIES)
        GET_PROPERTY(c_ldpath GLOBAL PROPERTY C_TEST_LDPATH)
        GET_PROPERTY(c_path GLOBAL PROPERTY C_TEST_PATH)
        TARGET_LINK_LIBRARIES(${executable} ${c_dependencies})

        # Take care of windowisims
        IF(WIN32)
            SET_TARGET_PROPERTIES(${executable} PROPERTIES
                PREFIX ../
                RUNTIME_OUTPUT_DIRECTORY ${c_binary_dir}
                LIBRARY_OUTPUT_DIRECTORY ${c_binary_dir}
                ARCHIVE_OUTPUT_DIRECTORY ${c_binary_dir})

            IF("${c_path}" STREQUAL "")
                SET(c_path ${c_ldpath})
            ENDIF()
        ENDIF()
    ENDWHILE()

    SET_CORE("${c_binary_dir}")
    ADD_TEST(C${is_core}_${script} ${CMAKE_COMMAND}
            -D "EXECUTABLE='./${script}'"
            -D "ARGUMENTS=${arguments}"
            -D "LDPATH=${c_ldpath}"
            -D "PATH=${c_path}"
            -D "SEPARATOR=${sep}"
            -P "${c_binary_dir}/TestDriverC.cmake"
    )
    IF(NOT "${tdep}" STREQUAL "")
            SET_TESTS_PROPERTIES(C${is_core}_${script}
            PROPERTIES DEPENDS ${tdep} ${script})
    ENDIF()
    file(COPY
        ${c_source_dir}/${script}
        DESTINATION ${c_binary_dir}/
    )
ENDMACRO()

# C Clean Macro
# Author: Brian Panneton
# Description: This macro sets up the c test for a make clean.
# Parameters:         
#		executable      = executable name
#             	${ARGN}         = files that the executable created
MACRO(CLEAN_TEST_C executable)
    set_property(DIRECTORY APPEND PROPERTY 
        ADDITIONAL_MAKE_CLEAN_FILES ${ARGN} 
    )
ENDMACRO()

 # Configure the c 'driver' file
CONFIGURE_FILE(${TESTING_SUITE_DIR}/TestingSuite/TestDriverC.cmake.in ${c_binary_dir}/TestDriverC.cmake @ONLY)