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)
14 ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
15 "${description} compiled with the following output:\n${OUTPUT}\n\n")
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)
23 MESSAGE(STATUS "${description} - no")
25 MESSAGE(STATUS "${description} - yes")
26 ENDIF(${var}_COMPILED)
27 ELSE(${invert} MATCHES INVERT)
29 MESSAGE(STATUS "${description} - yes")
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)
40 ENDIF(${var}_COMPILED)
41 ELSE(${invert} MATCHES INVERT)
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.
63 ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
64 "${description} compiled but failed to run with the following output:\n${OUTPUT}\n\n")
67 ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
68 "${description} compiled and ran with the following output:\n${OUTPUT}\n\n")
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)
80 MESSAGE(STATUS "${description} - yes")
82 MESSAGE(STATUS "${description} - no")
85 MESSAGE(STATUS "${description} - failed to compile")
86 ENDIF(${var}_COMPILED)
87 ELSE(${invert} MATCHES INVERT)
90 MESSAGE(STATUS "${description} - no")
92 MESSAGE(STATUS "${description} - yes")
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)
107 ELSE(${var}_COMPILED)
109 ENDIF(${var}_COMPILED)
110 ELSE(${invert} MATCHES INVERT)
117 ELSE(${var}_COMPILED)
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)