ENH: add a new test to test try compile
This commit is contained in:
parent
c9cec2add5
commit
d94c0e0429
53
Tests/TryCompile/CMakeLists.txt
Normal file
53
Tests/TryCompile/CMakeLists.txt
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
PROJECT(TryCompileTest)
|
||||||
|
|
||||||
|
# try to compile a file that should compile
|
||||||
|
TRY_COMPILE(SHOULD_PASS
|
||||||
|
${TryCompileTest_BINARY_DIR}/CMakeTmp
|
||||||
|
${TryCompileTest_SOURCE_DIR}/pass.c
|
||||||
|
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
|
||||||
|
${TryCompileTest_BINARY_DIR}/CMakeTmp
|
||||||
|
${TryCompileTest_SOURCE_DIR}/fail.c
|
||||||
|
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
|
||||||
|
${TryCompileTest_BINARY_DIR}/CMakeTmp
|
||||||
|
${TryCompileTest_SOURCE_DIR}/pass.c
|
||||||
|
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
|
||||||
|
${TryCompileTest_BINARY_DIR}/CMakeTmp
|
||||||
|
${TryCompileTest_SOURCE_DIR}/fail.c
|
||||||
|
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)
|
||||||
|
|
||||||
|
|
1
Tests/TryCompile/fail.c
Normal file
1
Tests/TryCompile/fail.c
Normal file
@ -0,0 +1 @@
|
|||||||
|
asdflkjasdlj
|
6
Tests/TryCompile/pass.c
Normal file
6
Tests/TryCompile/pass.c
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
int main()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user