STYLE: Nightly Date Stamp
[cmake.git] / Source / kwsys / kwsysPlatformTests.cmake
blob5c942af25657a5c77cf5500dc53ae667a4da7b38
1 SET(KWSYS_PLATFORM_TEST_FILE_C kwsysPlatformTestsC.c)
2 SET(KWSYS_PLATFORM_TEST_FILE_CXX kwsysPlatformTestsCXX.cxx)
4 MACRO(KWSYS_PLATFORM_TEST lang var description invert)
5   IF("${var}_COMPILED" MATCHES "^${var}_COMPILED$")
6     MESSAGE(STATUS "${description}")
7     TRY_COMPILE(${var}_COMPILED
8       ${CMAKE_CURRENT_BINARY_DIR}
9       ${CMAKE_CURRENT_SOURCE_DIR}/${KWSYS_PLATFORM_TEST_FILE_${lang}}
10       COMPILE_DEFINITIONS -DTEST_${var} ${KWSYS_PLATFORM_TEST_DEFINES} ${KWSYS_PLATFORM_TEST_EXTRA_FLAGS}
11       OUTPUT_VARIABLE OUTPUT)
12     IF(${var}_COMPILED)
13       FILE(APPEND
14         ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
15         "${description} compiled with the following output:\n${OUTPUT}\n\n")
16     ELSE(${var}_COMPILED)
17       FILE(APPEND
18         ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
19         "${description} failed to compile with the following output:\n${OUTPUT}\n\n")
20     ENDIF(${var}_COMPILED)
21     IF(${invert} MATCHES INVERT)
22       IF(${var}_COMPILED)
23         MESSAGE(STATUS "${description} - no")
24       ELSE(${var}_COMPILED)
25         MESSAGE(STATUS "${description} - yes")
26       ENDIF(${var}_COMPILED)
27     ELSE(${invert} MATCHES INVERT)
28       IF(${var}_COMPILED)
29         MESSAGE(STATUS "${description} - yes")
30       ELSE(${var}_COMPILED)
31         MESSAGE(STATUS "${description} - no")
32       ENDIF(${var}_COMPILED)
33     ENDIF(${invert} MATCHES INVERT)
34   ENDIF("${var}_COMPILED" MATCHES "^${var}_COMPILED$")
35   IF(${invert} MATCHES INVERT)
36     IF(${var}_COMPILED)
37       SET(${var} 0)
38     ELSE(${var}_COMPILED)
39       SET(${var} 1)
40     ENDIF(${var}_COMPILED)
41   ELSE(${invert} MATCHES INVERT)
42     IF(${var}_COMPILED)
43       SET(${var} 1)
44     ELSE(${var}_COMPILED)
45       SET(${var} 0)
46     ENDIF(${var}_COMPILED)
47   ENDIF(${invert} MATCHES INVERT)
48 ENDMACRO(KWSYS_PLATFORM_TEST)
50 MACRO(KWSYS_PLATFORM_TEST_RUN lang var description invert)
51   IF("${var}" MATCHES "^${var}$")
52     MESSAGE(STATUS "${description}")
53     TRY_RUN(${var} ${var}_COMPILED
54       ${CMAKE_CURRENT_BINARY_DIR}
55       ${CMAKE_CURRENT_SOURCE_DIR}/${KWSYS_PLATFORM_TEST_FILE_${lang}}
56       COMPILE_DEFINITIONS -DTEST_${var} ${KWSYS_PLATFORM_TEST_DEFINES} ${KWSYS_PLATFORM_TEST_EXTRA_FLAGS}
57       OUTPUT_VARIABLE OUTPUT)
59     # Note that ${var} will be a 0 return value on success.
60     IF(${var}_COMPILED)
61       IF(${var})
62         FILE(APPEND
63           ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
64           "${description} compiled but failed to run with the following output:\n${OUTPUT}\n\n")
65       ELSE(${var})
66         FILE(APPEND
67           ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
68           "${description} compiled and ran with the following output:\n${OUTPUT}\n\n")
69       ENDIF(${var})
70     ELSE(${var}_COMPILED)
71       FILE(APPEND
72         ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
73         "${description} failed to compile with the following output:\n${OUTPUT}\n\n")
74       SET(${var} -1 CACHE INTERNAL "${description} failed to compile.")
75     ENDIF(${var}_COMPILED)
77     IF(${invert} MATCHES INVERT)
78       IF(${var}_COMPILED)
79         IF(${var})
80           MESSAGE(STATUS "${description} - yes")
81         ELSE(${var})
82           MESSAGE(STATUS "${description} - no")
83         ENDIF(${var})
84       ELSE(${var}_COMPILED)
85         MESSAGE(STATUS "${description} - failed to compile")
86       ENDIF(${var}_COMPILED)
87     ELSE(${invert} MATCHES INVERT)
88       IF(${var}_COMPILED)
89         IF(${var})
90           MESSAGE(STATUS "${description} - no")
91         ELSE(${var})
92           MESSAGE(STATUS "${description} - yes")
93         ENDIF(${var})
94       ELSE(${var}_COMPILED)
95         MESSAGE(STATUS "${description} - failed to compile")
96       ENDIF(${var}_COMPILED)
97     ENDIF(${invert} MATCHES INVERT)
98   ENDIF("${var}" MATCHES "^${var}$")
100   IF(${invert} MATCHES INVERT)
101     IF(${var}_COMPILED)
102       IF(${var})
103         SET(${var} 1)
104       ELSE(${var})
105         SET(${var} 0)
106       ENDIF(${var})
107     ELSE(${var}_COMPILED)
108       SET(${var} 1)
109     ENDIF(${var}_COMPILED)
110   ELSE(${invert} MATCHES INVERT)
111     IF(${var}_COMPILED)
112       IF(${var})
113         SET(${var} 0)
114       ELSE(${var})
115         SET(${var} 1)
116       ENDIF(${var})
117     ELSE(${var}_COMPILED)
118       SET(${var} 0)
119     ENDIF(${var}_COMPILED)
120   ENDIF(${invert} MATCHES INVERT)
121 ENDMACRO(KWSYS_PLATFORM_TEST_RUN)
123 MACRO(KWSYS_PLATFORM_C_TEST var description invert)
124   SET(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_C_TEST_DEFINES})
125   SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS ${KWSYS_PLATFORM_C_TEST_EXTRA_FLAGS})
126   KWSYS_PLATFORM_TEST(C "${var}" "${description}" "${invert}")
127   SET(KWSYS_PLATFORM_TEST_DEFINES)
128   SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
129 ENDMACRO(KWSYS_PLATFORM_C_TEST)
131 MACRO(KWSYS_PLATFORM_C_TEST_RUN var description invert)
132   SET(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_C_TEST_DEFINES})
133   SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS ${KWSYS_PLATFORM_C_TEST_EXTRA_FLAGS})
134   KWSYS_PLATFORM_TEST_RUN(C "${var}" "${description}" "${invert}")
135   SET(KWSYS_PLATFORM_TEST_DEFINES)
136   SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
137 ENDMACRO(KWSYS_PLATFORM_C_TEST_RUN)
139 MACRO(KWSYS_PLATFORM_CXX_TEST var description invert)
140   SET(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_CXX_TEST_DEFINES})
141   SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS ${KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS})
142   KWSYS_PLATFORM_TEST(CXX "${var}" "${description}" "${invert}")
143   SET(KWSYS_PLATFORM_TEST_DEFINES)
144   SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
145 ENDMACRO(KWSYS_PLATFORM_CXX_TEST)
147 MACRO(KWSYS_PLATFORM_CXX_TEST_RUN var description invert)
148   SET(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_CXX_TEST_DEFINES})
149   SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS ${KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS})
150   KWSYS_PLATFORM_TEST_RUN(CXX "${var}" "${description}" "${invert}")
151   SET(KWSYS_PLATFORM_TEST_DEFINES)
152   SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
153 ENDMACRO(KWSYS_PLATFORM_CXX_TEST_RUN)