ENH: add test for build depends

This commit is contained in:
Bill Hoffman 2007-05-10 10:05:52 -04:00
parent 3e3413dadc
commit 1f286c067f
2 changed files with 31 additions and 16 deletions

View File

@ -13,19 +13,24 @@ try_compile(RESULT
${BuildDepends_SOURCE_DIR}/Project ${BuildDepends_SOURCE_DIR}/Project
testRebuild testRebuild
OUTPUT_VARIABLE OUTPUT) OUTPUT_VARIABLE OUTPUT)
set(bar ${BuildDepends_BINARY_DIR}/Project/bar${CMAKE_EXECUTABLE_SUFFIX})
set(bar ${BuildDepends_BINARY_DIR}/Project/bar.exe) message("${BuildDepends_BINARY_DIR}/Project/Debug/bar${CMAKE_EXECUTABLE_SUFFIX}")
if(EXISTS ${BuildDepends_BINARY_DIR}/Project/Debug/bar.exe ) if(EXISTS
set(bar ${BuildDepends_BINARY_DIR}/Project/Debug/bar.exe) "${BuildDepends_BINARY_DIR}/Project/Debug/bar${CMAKE_EXECUTABLE_SUFFIX}" )
endif(EXISTS ${BuildDepends_BINARY_DIR}/Project/Debug/bar.exe ) message("found debug")
set(bar
execute_process(COMMAND ${bar} OUTPUT_VARIABLE out) "${BuildDepends_BINARY_DIR}/Project/Debug/bar${CMAKE_EXECUTABLE_SUFFIX}")
endif(EXISTS
"${BuildDepends_BINARY_DIR}/Project/Debug/bar${CMAKE_EXECUTABLE_SUFFIX}")
message("running ${bar} ")
execute_process(COMMAND ${bar} OUTPUT_VARIABLE out TIMEOUT 3)
string(REGEX REPLACE "[\r\n]" " " out "${out}")
message("${out}") message("${out}")
if("${out}" STREQUAL "foo") if("${out}" STREQUAL "foo ")
message("Worked!") message("Worked!")
else("${out}" STREQUAL "foo") else("${out}" STREQUAL "foo ")
message(SEND_ERROR "Program did not rebuild with changed file") message(SEND_ERROR "Program did not rebuild with changed file: ${out}")
endif("${out}" STREQUAL "foo") endif("${out}" STREQUAL "foo ")
write_file(${BuildDepends_BINARY_DIR}/Project/foo.c write_file(${BuildDepends_BINARY_DIR}/Project/foo.c
"const char* foo() { return \"foo changed\";}" ) "const char* foo() { return \"foo changed\";}" )
@ -35,11 +40,18 @@ try_compile(RESULT
testRebuild testRebuild
OUTPUT_VARIABLE OUTPUT) OUTPUT_VARIABLE OUTPUT)
execute_process(COMMAND ${bar} OUTPUT_VARIABLE out) if(EXISTS
"${BuildDepends_BINARY_DIR}/Project/Debug/bar${CMAKE_EXECUTABLE_SUFFIX}" )
message("found debug")
endif(EXISTS
"${BuildDepends_BINARY_DIR}/Project/Debug/bar${CMAKE_EXECUTABLE_SUFFIX}")
execute_process(COMMAND ${bar} OUTPUT_VARIABLE out TIMEOUT 3)
string(REGEX REPLACE "[\r\n]" " " out "${out}")
message("${out}") message("${out}")
if("${out}" STREQUAL "foo changed") if("${out}" STREQUAL "foo changed ")
message("Worked!") message("Worked!")
else("${out}" STREQUAL "foo changed") else("${out}" STREQUAL "foo changed ")
message(SEND_ERROR "Program did not rebuild with changed file") message(SEND_ERROR "Program did not rebuild with changed file")
endif("${out}" STREQUAL "foo changed") endif("${out}" STREQUAL "foo changed ")

View File

@ -3,6 +3,9 @@
const char* foo(); const char* foo();
int main() int main()
{ {
printf("%s", foo()); int i;
printf("%s\n", foo());
fflush(stdout);
for(;;);
return 0; return 0;
} }