2007-05-09 23:10:12 +04:00
|
|
|
# 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)
|
|
|
|
make_directory(${BuildDepends_BINARY_DIR}/Project)
|
2007-05-16 15:55:00 +04:00
|
|
|
write_file(${BuildDepends_BINARY_DIR}/Project/foo.cxx
|
2007-05-09 23:10:12 +04:00
|
|
|
"const char* foo() { return \"foo\";}" )
|
|
|
|
try_compile(RESULT
|
|
|
|
${BuildDepends_BINARY_DIR}/Project
|
|
|
|
${BuildDepends_SOURCE_DIR}/Project
|
|
|
|
testRebuild
|
|
|
|
OUTPUT_VARIABLE OUTPUT)
|
2007-05-24 01:58:14 +04:00
|
|
|
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")
|
|
|
|
|
2007-05-16 15:55:00 +04:00
|
|
|
if(NOT RESULT)
|
|
|
|
message(SEND_ERROR "Could not build test project: ${OUTPUT}")
|
|
|
|
endif(NOT RESULT)
|
|
|
|
|
2007-05-10 18:05:52 +04:00
|
|
|
set(bar ${BuildDepends_BINARY_DIR}/Project/bar${CMAKE_EXECUTABLE_SUFFIX})
|
|
|
|
message("${BuildDepends_BINARY_DIR}/Project/Debug/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 TIMEOUT 3)
|
|
|
|
string(REGEX REPLACE "[\r\n]" " " out "${out}")
|
2007-05-09 23:10:12 +04:00
|
|
|
message("${out}")
|
2007-05-10 18:05:52 +04:00
|
|
|
if("${out}" STREQUAL "foo ")
|
2007-05-09 23:10:12 +04:00
|
|
|
message("Worked!")
|
2007-05-10 18:05:52 +04:00
|
|
|
else("${out}" STREQUAL "foo ")
|
2007-05-24 01:58:14 +04:00
|
|
|
message(SEND_ERROR "Project did not initially build properly: ${out}")
|
2007-05-10 18:05:52 +04:00
|
|
|
endif("${out}" STREQUAL "foo ")
|
2007-05-09 23:10:12 +04:00
|
|
|
|
2007-05-16 15:55:00 +04:00
|
|
|
write_file(${BuildDepends_BINARY_DIR}/Project/foo.cxx
|
2007-05-09 23:10:12 +04:00
|
|
|
"const char* foo() { return \"foo changed\";}" )
|
|
|
|
try_compile(RESULT
|
|
|
|
${BuildDepends_BINARY_DIR}/Project
|
|
|
|
${BuildDepends_SOURCE_DIR}/Project
|
|
|
|
testRebuild
|
|
|
|
OUTPUT_VARIABLE OUTPUT)
|
|
|
|
|
2007-05-24 01:58:14 +04:00
|
|
|
# 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")
|
|
|
|
|
2007-05-16 15:55:00 +04:00
|
|
|
if(NOT RESULT)
|
|
|
|
message(SEND_ERROR "Could not build test project: ${OUTPUT}")
|
|
|
|
endif(NOT RESULT)
|
2007-05-10 18:05:52 +04:00
|
|
|
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}")
|
2007-05-09 23:10:12 +04:00
|
|
|
message("${out}")
|
|
|
|
|
2007-05-10 18:05:52 +04:00
|
|
|
if("${out}" STREQUAL "foo changed ")
|
2007-05-09 23:10:12 +04:00
|
|
|
message("Worked!")
|
2007-05-10 18:05:52 +04:00
|
|
|
else("${out}" STREQUAL "foo changed ")
|
2007-05-23 21:27:00 +04:00
|
|
|
message(SEND_ERROR "Project did not rebuild properly!")
|
2007-05-10 18:05:52 +04:00
|
|
|
endif("${out}" STREQUAL "foo changed ")
|