2003-02-11 00:20:10 +03:00
|
|
|
PROJECT(TryCompile)
|
2003-02-10 21:19:34 +03:00
|
|
|
|
|
|
|
# try to compile a file that should compile
|
|
|
|
TRY_COMPILE(SHOULD_PASS
|
2003-02-11 00:20:10 +03:00
|
|
|
${TryCompile_BINARY_DIR}/CMakeTmp
|
|
|
|
${TryCompile_SOURCE_DIR}/pass.c
|
2003-02-10 21:19:34 +03:00
|
|
|
OUTPUT_VARIABLE TRY_OUT)
|
|
|
|
IF(NOT SHOULD_PASS)
|
|
|
|
MESSAGE(SEND_ERROR "should pass failed ")
|
|
|
|
ENDIF(NOT SHOULD_PASS)
|
|
|
|
MESSAGE( "output from TRY_COMPILE ${TRY_OUT} ")
|
|
|
|
|
|
|
|
# try to compile a file that should not compile
|
|
|
|
TRY_COMPILE(SHOULD_FAIL
|
2003-02-11 00:20:10 +03:00
|
|
|
${TryCompile_BINARY_DIR}/CMakeTmp
|
|
|
|
${TryCompile_SOURCE_DIR}/fail.c
|
2003-02-10 21:19:34 +03:00
|
|
|
OUTPUT_VARIABLE TRY_OUT)
|
|
|
|
IF(SHOULD_FAIL)
|
|
|
|
MESSAGE(SEND_ERROR "Should fail passed")
|
|
|
|
ENDIF(SHOULD_FAIL)
|
|
|
|
MESSAGE("output from TRY_COMPILE ${TRY_OUT} ")
|
|
|
|
|
|
|
|
# try to compile a file that should compile
|
|
|
|
TRY_COMPILE(SHOULD_PASS
|
2003-02-11 00:20:10 +03:00
|
|
|
${TryCompile_BINARY_DIR}/CMakeTmp
|
|
|
|
${TryCompile_SOURCE_DIR}/pass.c
|
2003-02-10 21:19:34 +03:00
|
|
|
OUTPUT_VARIABLE TRY_OUT)
|
|
|
|
IF(NOT SHOULD_PASS)
|
|
|
|
MESSAGE(SEND_ERROR "should pass failed ")
|
|
|
|
ENDIF(NOT SHOULD_PASS)
|
|
|
|
MESSAGE("output from TRY_COMPILE ${TRY_OUT} ")
|
|
|
|
|
|
|
|
# try to compile a file that should not compile
|
|
|
|
TRY_COMPILE(SHOULD_FAIL
|
2003-02-11 00:20:10 +03:00
|
|
|
${TryCompile_BINARY_DIR}/CMakeTmp
|
|
|
|
${TryCompile_SOURCE_DIR}/fail.c
|
2003-02-10 21:19:34 +03:00
|
|
|
OUTPUT_VARIABLE TRY_OUT)
|
|
|
|
IF(SHOULD_FAIL)
|
|
|
|
MESSAGE(SEND_ERROR "Should fail passed")
|
|
|
|
ENDIF(SHOULD_FAIL)
|
|
|
|
MESSAGE("output from TRY_COMPILE ${TRY_OUT} ")
|
|
|
|
|
|
|
|
IF(NOT SHOULD_FAIL)
|
|
|
|
IF(SHOULD_PASS)
|
|
|
|
MESSAGE("All Tests passed, ignore all previous output.")
|
|
|
|
ELSE(SHOULD_PASS)
|
|
|
|
MESSAGE("Test failed")
|
|
|
|
ENDIF(SHOULD_PASS)
|
|
|
|
ELSE(NOT SHOULD_FAIL)
|
|
|
|
MESSAGE("Test failed")
|
|
|
|
ENDIF(NOT SHOULD_FAIL)
|
2003-02-11 06:00:40 +03:00
|
|
|
TRY_COMPILE(CMAKE_ANSI_FOR_SCOPE ${TryCompile_BINARY_DIR}/CMakeTmp
|
|
|
|
${CMAKE_ROOT}/Modules/TestForAnsiForScope.cxx OUTPUT_VARIABLE OUT)
|
|
|
|
IF (CMAKE_ANSI_FOR_SCOPE)
|
|
|
|
MESSAGE("Compiler supports ansi for")
|
|
|
|
ELSE(CMAKE_ANSI_FOR_SCOPE)
|
|
|
|
MESSAGE("Compiler does not support ansi for scope")
|
|
|
|
ENDIF(CMAKE_ANSI_FOR_SCOPE)
|
|
|
|
MESSAGE("output from TRY_COMPILE ${OUT} ")
|
|
|
|
|
|
|
|
TRY_COMPILE(CMAKE_ANSI_FOR_SCOPE ${TryCompile_BINARY_DIR}/CMakeTmp
|
|
|
|
${CMAKE_ROOT}/Modules/TestForAnsiForScope.cxx OUTPUT_VARIABLE OUT)
|
|
|
|
IF (CMAKE_ANSI_FOR_SCOPE)
|
|
|
|
MESSAGE("Compiler supports ansi for")
|
|
|
|
ELSE(CMAKE_ANSI_FOR_SCOPE)
|
|
|
|
MESSAGE("Compiler does not support ansi for scope")
|
|
|
|
ENDIF(CMAKE_ANSI_FOR_SCOPE)
|
|
|
|
MESSAGE("output from TRY_COMPILE ${OUT} ")
|
|
|
|
|
|
|
|
|
|
|
|
MESSAGE("use the module now")
|
|
|
|
INCLUDE(${CMAKE_ROOT}/Modules/TestForANSIForScope.cmake)
|
|
|
|
IF (CMAKE_ANSI_FOR_SCOPE)
|
|
|
|
MESSAGE("Compiler supports ansi for")
|
|
|
|
ELSE(CMAKE_ANSI_FOR_SCOPE)
|
|
|
|
MESSAGE("Compiler does not support ansi for scope")
|
|
|
|
ENDIF(CMAKE_ANSI_FOR_SCOPE)
|
2003-02-10 21:19:34 +03:00
|
|
|
|
2003-02-11 00:20:10 +03:00
|
|
|
ADD_EXECUTABLE(TryCompile pass.c)
|