AddTestsJava.cmake 5.74 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
INCLUDE(TestingSetup)

# Variables that are set externally
SET(java_binary_dir ${CMAKE_CURRENT_BINARY_DIR})
SET(java_source_dir ${CMAKE_CURRENT_SOURCE_DIR})

# Java Add Dependencies Macro
# Author: Brian Panneton
# Description: This macro adds the java test dependencies.
# Parameters:         
11
#              dependencies     = any target dependencies needed for java tests
12
13
14
15
16
17
18
19
MACRO(ADD_TEST_JAVA_DEPENDENCIES dependencies)
	IF(NOT ("${dependencies}" STREQUAL ""))
		SET_PROPERTY(GLOBAL APPEND PROPERTY JAVA_TEST_DEPENDENCIES 
        		"${dependencies}"
		)
	ENDIF(NOT ("${dependencies}" STREQUAL ""))
ENDMACRO(ADD_TEST_JAVA_DEPENDENCIES dependencies)

20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Java Add File Dependencies Macro
# Author: Brian Panneton
# Description: This macro adds the java test file dependencies.
#        Note: The tests already depend on their own file
# Parameters:         
#              dependencies     = any dependencies needed for java tests
MACRO(ADD_TEST_JAVA_FILE_DEPENDENCIES dependencies)
	IF(NOT ("${dependencies}" STREQUAL ""))
		SET_PROPERTY(GLOBAL APPEND PROPERTY JAVA_TEST_FILE_DEPENDENCIES 
        		"${dependencies}"
		)
	ENDIF(NOT ("${dependencies}" STREQUAL ""))
ENDMACRO(ADD_TEST_JAVA_FILE_DEPENDENCIES dependencies)

34
35
36
37
# Java Add Classpath Macro
# Author: Brian Panneton
# Description: This macro adds the java test classpaths.
# Parameters:         
38
#              cp   = any classpaths needed for java tests
39
40
41
42
MACRO(ADD_TEST_JAVA_CLASSPATH cp)
        GET_PROPERTY(classpath GLOBAL PROPERTY JAVA_TEST_CLASSPATH)
        IF(NOT ("${cp}" STREQUAL ""))
                SET_PROPERTY(GLOBAL PROPERTY JAVA_TEST_CLASSPATH 
43
                        "${classpath}${sep}${cp}" 
44
45
46
47
48
49
50
51
                )
        ENDIF(NOT ("${cp}" STREQUAL "")) 
ENDMACRO(ADD_TEST_JAVA_CLASSPATH cp)

# Java Add LDPath  Macro
# Author: Brian Panneton
# Description: This macro adds the java test ldpaths.
# Parameters:         
52
#               ld  = any ldpaths needed for java tests
53
54
55
56
MACRO(ADD_TEST_JAVA_LDPATH ld)
	GET_PROPERTY(ldpath GLOBAL PROPERTY JAVA_TEST_LDPATH)
	IF("${ld}" STRGREATER "")
		SET_PROPERTY(GLOBAL PROPERTY JAVA_TEST_LDPATH 
57
        		"${ldpath}${sep}${ld}" 
58
59
60
61
		)
	ENDIF("${ld}" STRGREATER "")  
ENDMACRO(ADD_TEST_JAVA_LDPATH ld)

62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Java Add Path Macro
# Author: Brian Panneton
# Description: This macro adds the java test paths.
# Parameters:         
#               p = any paths needed for java tests
MACRO(ADD_TEST_JAVA_PATH p)
    GET_PROPERTY(path GLOBAL PROPERTY JAVA_TEST_PATH)
    IF("${p}" STRGREATER "")
        SET_PROPERTY(GLOBAL PROPERTY JAVA_TEST_PATH 
                "${path}${sep}${p}" 
        )
    ENDIF("${p}" STRGREATER "")
ENDMACRO(ADD_TEST_JAVA_PATH p)

76
77
78
79
80
81
82
83
84
85
86
87
88
# Add Java Test Macro
# Author: Brian Panneton
# Description:	This macro builds and adds the java test in one shot. There is
#		no need to build a test separately, because there isn't a case 
#		that you don't want to run it.
# Parameters: 
#		executable 	= executable name 
#		${ARGN}		= any arguments for the executable
#
MACRO(ADD_TEST_JAVA executable)

	PARSE_TEST_ARGS("${ARGN}")	

89
90
	GET_PROPERTY(java_file_dependencies GLOBAL PROPERTY 
                    JAVA_TEST_FILE_DEPENDENCIES)
91
92
	GET_PROPERTY(java_classpath GLOBAL PROPERTY JAVA_TEST_CLASSPATH)
	GET_PROPERTY(java_ldpath GLOBAL PROPERTY JAVA_TEST_LDPATH)
93
    GET_PROPERTY(java_path GLOBAL PROPERTY JAVA_TEST_PATH)
94
95
96
97
98
	
	ADD_CUSTOM_COMMAND(
		OUTPUT ${java_binary_dir}/${executable}.class
		WORKING_DIRECTORY ${java_binary_dir}
		DEPENDS	${java_source_dir}/${executable}.java
99
			${java_file_dependencies}
100
		COMMAND ${JAVA_COMPILE}
101
102
		ARGS	-cp	"\"${java_classpath}\""
			-d	"\"${java_binary_dir}\""
103
104
105
106
107
			${java_source_dir}/${executable}.java
	)
	
	SET_PROPERTY(GLOBAL APPEND PROPERTY JAVA_TEST_TARGETS "${java_binary_dir}/${executable}.class")
	
108
109
110
111
112
113
    # Dlls need to be in the path dir for java
    IF(WIN32)
        IF("${java_path}" STREQUAL "")
            SET(java_path ${java_ldpath})
        ENDIF("${java_path}" STREQUAL "")
    ENDIF(WIN32)    
114

115
116
117
118
119
120
121
122
123
124
	SET_CORE("${java_binary_dir}")
    ADD_TEST(Java${is_core}_${executable}${dup} ${CMAKE_COMMAND}
            -D "EXECUTABLE=${executable}"
            -D "ARGUMENTS=${arguments}"
            -D "CLASSPATH=${java_classpath}"
            -D "LDPATH=${java_ldpath}"
            -D "PATH=${java_path}"
            -D "SEPARATOR=${sep}"
            -P "${java_binary_dir}/TestDriverJava.cmake"
    )
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
ENDMACRO(ADD_TEST_JAVA executable)

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

# Java Create Target Macro
# Author: Brian Panneton
141
# Description: This macro sets up the java test target
142
143
# Parameters:   none
MACRO(CREATE_TARGET_TEST_JAVA)
144
145
146
147
148
    IF(EXISTS JavaCore_ALLTEST)
        SET(JavaCore_ALLTEST JavaCore_ALLTEST)
    ENDIF(EXISTS JavaCore_ALLTEST)

    GET_PROPERTY(java_dependencies GLOBAL PROPERTY JAVA_TEST_DEPENDENCIES)
149
150
151

	SET_CORE("${java_binary_dir}")
	GET_PROPERTY(targets GLOBAL PROPERTY JAVA_TEST_TARGETS)
152
153
154
155
156
157
    ADD_CUSTOM_TARGET(Java${is_core}_ALLTEST ALL DEPENDS 
            ${JavaCore_ALLTEST} ${targets})
   
    IF(NOT ("${java_dependencies}" STREQUAL ""))
        ADD_DEPENDENCIES(Java${is_core}_ALLTEST ${java_dependencies})
    ENDIF(NOT ("${java_dependencies}" STREQUAL ""))
158
159

	IF(NOT ("${is_core}" STREQUAL ""))
160
161
        SET_PROPERTY(GLOBAL PROPERTY JAVA_TEST_TARGETS "")
    ENDIF(NOT ("${is_core}" STREQUAL ""))
162
163
164
165
166
167

ENDMACRO(CREATE_TARGET_TEST_JAVA)


# Configure the java 'driver' file
CONFIGURE_FILE(${TESTING_SUITE_DIR}/TestingSuite/TestDriverJava.cmake.in ${java_binary_dir}/TestDriverJava.cmake @ONLY)