Tests: Extend BuildDepends test to cover OBJECT_DEPENDS
The actual file timestamp dependency is known to not work on Visual Studio or Xcode generators. Tolerate such failure for these generators (Tests/CustomCommand already covers using OBJECT_DEPENDS to pull a custom command into a target, and that still works with these generators).
This commit is contained in:
parent
e00e8713de
commit
783c375766
|
@ -69,6 +69,9 @@ file(WRITE ${BuildDepends_BINARY_DIR}/Project/link_depends_no_shared_exe.h
|
||||||
"#define link_depends_no_shared_exe_value 0\n")
|
"#define link_depends_no_shared_exe_value 0\n")
|
||||||
set(link_depends_no_shared_check_txt ${BuildDepends_BINARY_DIR}/Project/link_depends_no_shared_check.txt)
|
set(link_depends_no_shared_check_txt ${BuildDepends_BINARY_DIR}/Project/link_depends_no_shared_check.txt)
|
||||||
|
|
||||||
|
file(WRITE ${BuildDepends_BINARY_DIR}/Project/object_depends.txt "0\n")
|
||||||
|
set(object_depends_check_txt ${BuildDepends_BINARY_DIR}/Project/object_depends_check.txt)
|
||||||
|
|
||||||
file(WRITE ${BuildDepends_BINARY_DIR}/Project/external.in "external original\n")
|
file(WRITE ${BuildDepends_BINARY_DIR}/Project/external.in "external original\n")
|
||||||
file(WRITE ${BuildDepends_BINARY_DIR}/Project/multi1-in.txt "multi1-in original\n")
|
file(WRITE ${BuildDepends_BINARY_DIR}/Project/multi1-in.txt "multi1-in original\n")
|
||||||
file(WRITE ${BuildDepends_BINARY_DIR}/Project/multi2-stamp.txt "multi2-stamp original\n")
|
file(WRITE ${BuildDepends_BINARY_DIR}/Project/multi2-stamp.txt "multi2-stamp original\n")
|
||||||
|
@ -246,6 +249,8 @@ file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_macro_tgt.hxx
|
||||||
file(WRITE ${BuildDepends_BINARY_DIR}/Project/link_depends_no_shared_lib.h
|
file(WRITE ${BuildDepends_BINARY_DIR}/Project/link_depends_no_shared_lib.h
|
||||||
"#define link_depends_no_shared_lib_value 0\n")
|
"#define link_depends_no_shared_lib_value 0\n")
|
||||||
|
|
||||||
|
file(WRITE ${BuildDepends_BINARY_DIR}/Project/object_depends.txt "1\n")
|
||||||
|
|
||||||
if(TEST_LINK_DEPENDS)
|
if(TEST_LINK_DEPENDS)
|
||||||
file(WRITE ${TEST_LINK_DEPENDS} "2")
|
file(WRITE ${TEST_LINK_DEPENDS} "2")
|
||||||
endif()
|
endif()
|
||||||
|
@ -359,6 +364,20 @@ else()
|
||||||
"Targets link_depends_no_shared_lib and link_depends_no_shared_exe not both built.")
|
"Targets link_depends_no_shared_lib and link_depends_no_shared_exe not both built.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(EXISTS "${object_depends_check_txt}")
|
||||||
|
file(STRINGS "${object_depends_check_txt}" object_depends_check LIMIT_COUNT 1)
|
||||||
|
if("${object_depends_check}" STREQUAL "1")
|
||||||
|
message(STATUS "object_depends exe is newer than object_depends.txt as expected.")
|
||||||
|
elseif(CMAKE_GENERATOR MATCHES "Visual Studio|Xcode")
|
||||||
|
message(STATUS "Known limitation: OBJECT_DEPENDS does not work on ${CMAKE_GENERATOR}")
|
||||||
|
else()
|
||||||
|
message(SEND_ERROR "Project did not rebuild properly: object_depends exe is not newer than object_depends.txt.")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
message(SEND_ERROR "Project did not rebuild properly. "
|
||||||
|
"object_depends exe and object_depends.txt are not both present.")
|
||||||
|
endif()
|
||||||
|
|
||||||
if(EXISTS ${BuildDepends_BINARY_DIR}/Project/external.out)
|
if(EXISTS ${BuildDepends_BINARY_DIR}/Project/external.out)
|
||||||
file(STRINGS ${BuildDepends_BINARY_DIR}/Project/external.out external_out)
|
file(STRINGS ${BuildDepends_BINARY_DIR}/Project/external.out external_out)
|
||||||
if("${external_out}" STREQUAL "external changed")
|
if("${external_out}" STREQUAL "external changed")
|
||||||
|
|
|
@ -182,3 +182,15 @@ if(TEST_MULTI3)
|
||||||
set_property(SOURCE multi3-real.txt multi3-dummy.txt PROPERTY SYMBOLIC 1)
|
set_property(SOURCE multi3-real.txt multi3-dummy.txt PROPERTY SYMBOLIC 1)
|
||||||
add_custom_target(multi3 ALL DEPENDS multi3-real.txt)
|
add_custom_target(multi3 ALL DEPENDS multi3-real.txt)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
add_executable(object_depends object_depends.cxx)
|
||||||
|
set_property(SOURCE object_depends.cxx PROPERTY OBJECT_DEPENDS
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/object_depends.txt)
|
||||||
|
add_custom_target(object_depends_check ALL
|
||||||
|
COMMAND ${CMAKE_COMMAND}
|
||||||
|
-Dexe=$<TARGET_FILE:object_depends>
|
||||||
|
-Dout=${CMAKE_CURRENT_BINARY_DIR}/object_depends_check.txt
|
||||||
|
-Dtxt=${CMAKE_CURRENT_BINARY_DIR}/object_depends.txt
|
||||||
|
-P ${CMAKE_CURRENT_SOURCE_DIR}/object_depends_check.cmake
|
||||||
|
)
|
||||||
|
add_dependencies(object_depends_check object_depends)
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
int main() { return 0; }
|
|
@ -0,0 +1,7 @@
|
||||||
|
if(NOT EXISTS "${txt}" OR NOT EXISTS "${exe}")
|
||||||
|
file(REMOVE "${out}")
|
||||||
|
elseif("${exe}" IS_NEWER_THAN "${txt}")
|
||||||
|
file(WRITE "${out}" "1\n")
|
||||||
|
else()
|
||||||
|
file(WRITE "${out}" "0\n")
|
||||||
|
endif()
|
Loading…
Reference in New Issue