ENH: Renamed kwsysPlatformCxxTests to kwsysPlatformTests and generalized it for multiple language tests (C and CXX).

This commit is contained in:
Brad King 2006-10-04 16:56:32 -04:00
parent 4fc95339f7
commit a48cf7e07b
4 changed files with 70 additions and 10 deletions

View File

@ -145,7 +145,7 @@ IF(KWSYS_STANDALONE)
ENDIF(KWSYS_STANDALONE)
# Include helper macros.
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/kwsysPlatformCxxTests.cmake)
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/kwsysPlatformTests.cmake)
INCLUDE(CheckTypeSize)
# Do full dependency headers.

View File

@ -1,17 +1,20 @@
MACRO(KWSYS_PLATFORM_CXX_TEST var description invert)
SET(KWSYS_PLATFORM_TEST_FILE_C kwsysPlatformTestsC.cxx)
SET(KWSYS_PLATFORM_TEST_FILE_CXX kwsysPlatformTestsCXX.cxx)
MACRO(KWSYS_PLATFORM_TEST lang var description invert)
IF("${var}_COMPILED" MATCHES "^${var}_COMPILED$")
MESSAGE(STATUS "${description}")
TRY_COMPILE(${var}_COMPILED
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/kwsysPlatformCxxTests.cxx
COMPILE_DEFINITIONS -DTEST_${var} ${KWSYS_PLATFORM_CXX_TEST_DEFINES} ${KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS}
${CMAKE_CURRENT_SOURCE_DIR}/${KWSYS_PLATFORM_TEST_FILE_${lang}}
COMPILE_DEFINITIONS -DTEST_${var} ${KWSYS_PLATFORM_TEST_DEFINES} ${KWSYS_PLATFORM_TEST_EXTRA_FLAGS}
OUTPUT_VARIABLE OUTPUT)
IF(${var}_COMPILED)
FILE(APPEND
FILE(APPEND
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"${description} compiled with the following output:\n${OUTPUT}\n\n")
ELSE(${var}_COMPILED)
FILE(APPEND
FILE(APPEND
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"${description} failed to compile with the following output:\n${OUTPUT}\n\n")
ENDIF(${var}_COMPILED)
@ -42,15 +45,15 @@ MACRO(KWSYS_PLATFORM_CXX_TEST var description invert)
SET(${var} 0)
ENDIF(${var}_COMPILED)
ENDIF(${invert} MATCHES INVERT)
ENDMACRO(KWSYS_PLATFORM_CXX_TEST)
ENDMACRO(KWSYS_PLATFORM_TEST)
MACRO(KWSYS_PLATFORM_CXX_TEST_RUN var description invert)
MACRO(KWSYS_PLATFORM_TEST_RUN lang var description invert)
IF("${var}" MATCHES "^${var}$")
MESSAGE(STATUS "${description}")
TRY_RUN(${var} ${var}_COMPILED
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/kwsysPlatformCxxTests.cxx
COMPILE_DEFINITIONS -DTEST_${var} ${KWSYS_PLATFORM_CXX_TEST_DEFINES} ${KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS}
${CMAKE_CURRENT_SOURCE_DIR}/${KWSYS_PLATFORM_TEST_FILE_${lang}}
COMPILE_DEFINITIONS -DTEST_${var} ${KWSYS_PLATFORM_TEST_DEFINES} ${KWSYS_PLATFORM_TEST_EXTRA_FLAGS}
OUTPUT_VARIABLE OUTPUT)
# Note that ${var} will be a 0 return value on success.
@ -115,4 +118,36 @@ MACRO(KWSYS_PLATFORM_CXX_TEST_RUN var description invert)
SET(${var} 0)
ENDIF(${var}_COMPILED)
ENDIF(${invert} MATCHES INVERT)
ENDMACRO(KWSYS_PLATFORM_TEST_RUN)
MACRO(KWSYS_PLATFORM_C_TEST var description invert)
SET(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_C_TEST_DEFINES})
SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS ${KWSYS_PLATFORM_C_TEST_EXTRA_FLAGS})
KWSYS_PLATFORM_TEST(C "${var}" "${description}" "${invert}")
SET(KWSYS_PLATFORM_TEST_DEFINES)
SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
ENDMACRO(KWSYS_PLATFORM_C_TEST)
MACRO(KWSYS_PLATFORM_C_TEST_RUN var description invert)
SET(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_C_TEST_DEFINES})
SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS ${KWSYS_PLATFORM_C_TEST_EXTRA_FLAGS})
KWSYS_PLATFORM_TEST_RUN(C "${var}" "${description}" "${invert}")
SET(KWSYS_PLATFORM_TEST_DEFINES)
SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
ENDMACRO(KWSYS_PLATFORM_C_TEST_RUN)
MACRO(KWSYS_PLATFORM_CXX_TEST var description invert)
SET(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_CXX_TEST_DEFINES})
SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS ${KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS})
KWSYS_PLATFORM_TEST(CXX "${var}" "${description}" "${invert}")
SET(KWSYS_PLATFORM_TEST_DEFINES)
SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
ENDMACRO(KWSYS_PLATFORM_CXX_TEST)
MACRO(KWSYS_PLATFORM_CXX_TEST_RUN var description invert)
SET(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_CXX_TEST_DEFINES})
SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS ${KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS})
KWSYS_PLATFORM_TEST_RUN(CXX "${var}" "${description}" "${invert}")
SET(KWSYS_PLATFORM_TEST_DEFINES)
SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
ENDMACRO(KWSYS_PLATFORM_CXX_TEST_RUN)

View File

@ -0,0 +1,25 @@
/* Macros to define main() in a cross-platform way.
Usage:
int KWSYS_PLATFORM_TEST_C_MAIN()
{
return 0;
}
int KWSYS_PLATFORM_TEST_C_MAIN_ARGS(argc, argv)
{
(void)argc; (void)argv;
return 0;
}
*/
#if defined(__CLASSIC_C__)
# define KWSYS_PLATFORM_TEST_C_MAIN() \
main()
# define KWSYS_PLATFORM_TEST_C_MAIN_ARGS(argc, argv) \
main(argc,argv) int argc; char* argv[];
#else
# define KWSYS_PLATFORM_TEST_C_MAIN() \
main(void)
# define KWSYS_PLATFORM_TEST_C_MAIN_ARGS(argc, argv) \
main(int argc, char* argv[])
#endif