92270d5bf8
probably because the process was killed before the fflush() worked because the busy loop blocked the processor (failing midworld test) Alex
106 lines
3.5 KiB
CMake
106 lines
3.5 KiB
CMake
# this test creates a static library and an executable
|
|
# the source to the library is then changed
|
|
# and the build is done on the executable and if things
|
|
# are working the executable should relink with the new
|
|
# value. The subdir Project contains the CMakelists.txt
|
|
# and source files for the test project.
|
|
project(BuildDepends)
|
|
|
|
file(REMOVE_RECURSE ${BuildDepends_BINARY_DIR}/Project)
|
|
file(MAKE_DIRECTORY ${BuildDepends_BINARY_DIR}/Project)
|
|
message("Creating Project/foo.cxx")
|
|
write_file(${BuildDepends_BINARY_DIR}/Project/foo.cxx
|
|
"const char* foo() { return \"foo\";}" )
|
|
|
|
message("Building project first time")
|
|
try_compile(RESULT
|
|
${BuildDepends_BINARY_DIR}/Project
|
|
${BuildDepends_SOURCE_DIR}/Project
|
|
testRebuild
|
|
OUTPUT_VARIABLE OUTPUT)
|
|
if("${CMAKE_GENERATOR}" MATCHES "Xcode")
|
|
try_compile(RESULT
|
|
${BuildDepends_BINARY_DIR}/Project
|
|
${BuildDepends_SOURCE_DIR}/Project
|
|
testRebuild
|
|
OUTPUT_VARIABLE OUTPUT)
|
|
try_compile(RESULT
|
|
${BuildDepends_BINARY_DIR}/Project
|
|
${BuildDepends_SOURCE_DIR}/Project
|
|
testRebuild
|
|
OUTPUT_VARIABLE OUTPUT)
|
|
endif("${CMAKE_GENERATOR}" MATCHES "Xcode")
|
|
|
|
if(NOT RESULT)
|
|
message(SEND_ERROR "Could not build test project: ${OUTPUT}")
|
|
endif(NOT RESULT)
|
|
|
|
set(bar ${BuildDepends_BINARY_DIR}/Project/bar${CMAKE_EXECUTABLE_SUFFIX})
|
|
if(EXISTS
|
|
"${BuildDepends_BINARY_DIR}/Project/Debug/bar${CMAKE_EXECUTABLE_SUFFIX}" )
|
|
message("found debug")
|
|
set(bar
|
|
"${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 RESULT_VARIABLE runResult)
|
|
string(REGEX REPLACE "[\r\n]" " " out "${out}")
|
|
message("Run result: ${runResult} Output: \"${out}\"")
|
|
|
|
if("${out}" STREQUAL "foo ")
|
|
message("Worked!")
|
|
else("${out}" STREQUAL "foo ")
|
|
message(SEND_ERROR "Project did not initially build properly: ${out}")
|
|
endif("${out}" STREQUAL "foo ")
|
|
|
|
message("Waiting 3 seconds...")
|
|
# any additional argument will cause ${bar} to wait forever
|
|
execute_process(COMMAND ${bar} -infinite TIMEOUT 3 OUTPUT_VARIABLE out)
|
|
|
|
message("Modifying Project/foo.cxx")
|
|
write_file(${BuildDepends_BINARY_DIR}/Project/foo.cxx
|
|
"const char* foo() { return \"foo changed\";}" )
|
|
|
|
message("Building project second time")
|
|
try_compile(RESULT
|
|
${BuildDepends_BINARY_DIR}/Project
|
|
${BuildDepends_SOURCE_DIR}/Project
|
|
testRebuild
|
|
OUTPUT_VARIABLE OUTPUT)
|
|
|
|
# Xcode is in serious need of help here
|
|
if("${CMAKE_GENERATOR}" MATCHES "Xcode")
|
|
try_compile(RESULT
|
|
${BuildDepends_BINARY_DIR}/Project
|
|
${BuildDepends_SOURCE_DIR}/Project
|
|
testRebuild
|
|
OUTPUT_VARIABLE OUTPUT)
|
|
try_compile(RESULT
|
|
${BuildDepends_BINARY_DIR}/Project
|
|
${BuildDepends_SOURCE_DIR}/Project
|
|
testRebuild
|
|
OUTPUT_VARIABLE OUTPUT)
|
|
endif("${CMAKE_GENERATOR}" MATCHES "Xcode")
|
|
|
|
if(NOT RESULT)
|
|
message(SEND_ERROR "Could not build test project: ${OUTPUT}")
|
|
endif(NOT RESULT)
|
|
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}")
|
|
|
|
message("Running ${bar} ")
|
|
execute_process(COMMAND ${bar} OUTPUT_VARIABLE out RESULT_VARIABLE runResult)
|
|
string(REGEX REPLACE "[\r\n]" " " out "${out}")
|
|
message("Run result: ${runResult} Output: \"${out}\"")
|
|
|
|
if("${out}" STREQUAL "foo changed ")
|
|
message("Worked!")
|
|
else("${out}" STREQUAL "foo changed ")
|
|
message(SEND_ERROR "Project did not rebuild properly!")
|
|
endif("${out}" STREQUAL "foo changed ")
|