summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-07-23 12:47:21 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2015-07-23 12:47:21 (GMT)
commit51f818bf24cbfc542489edf6e0dbdda2d35a4787 (patch)
tree841bd9803498dcbec69b520e74a5380dc9f4c42b
parent900554b021b00f9e64d21cb1aabf01b27cf800cd (diff)
parent783c375766b1e5656dd34dd99281fceb7ed7aab2 (diff)
downloadCMake-51f818bf24cbfc542489edf6e0dbdda2d35a4787.zip
CMake-51f818bf24cbfc542489edf6e0dbdda2d35a4787.tar.gz
CMake-51f818bf24cbfc542489edf6e0dbdda2d35a4787.tar.bz2
Merge topic 'test-OBJECT_DEPENDS'
783c3757 Tests: Extend BuildDepends test to cover OBJECT_DEPENDS
-rw-r--r--Tests/BuildDepends/CMakeLists.txt19
-rw-r--r--Tests/BuildDepends/Project/CMakeLists.txt12
-rw-r--r--Tests/BuildDepends/Project/object_depends.cxx1
-rw-r--r--Tests/BuildDepends/Project/object_depends_check.cmake7
4 files changed, 39 insertions, 0 deletions
diff --git a/Tests/BuildDepends/CMakeLists.txt b/Tests/BuildDepends/CMakeLists.txt
index 2be59b6..7b7353c 100644
--- a/Tests/BuildDepends/CMakeLists.txt
+++ b/Tests/BuildDepends/CMakeLists.txt
@@ -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")
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/multi1-in.txt "multi1-in 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
"#define link_depends_no_shared_lib_value 0\n")
+file(WRITE ${BuildDepends_BINARY_DIR}/Project/object_depends.txt "1\n")
+
if(TEST_LINK_DEPENDS)
file(WRITE ${TEST_LINK_DEPENDS} "2")
endif()
@@ -359,6 +364,20 @@ else()
"Targets link_depends_no_shared_lib and link_depends_no_shared_exe not both built.")
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)
file(STRINGS ${BuildDepends_BINARY_DIR}/Project/external.out external_out)
if("${external_out}" STREQUAL "external changed")
diff --git a/Tests/BuildDepends/Project/CMakeLists.txt b/Tests/BuildDepends/Project/CMakeLists.txt
index 0db39c5..3aa57fc 100644
--- a/Tests/BuildDepends/Project/CMakeLists.txt
+++ b/Tests/BuildDepends/Project/CMakeLists.txt
@@ -182,3 +182,15 @@ if(TEST_MULTI3)
set_property(SOURCE multi3-real.txt multi3-dummy.txt PROPERTY SYMBOLIC 1)
add_custom_target(multi3 ALL DEPENDS multi3-real.txt)
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)
diff --git a/Tests/BuildDepends/Project/object_depends.cxx b/Tests/BuildDepends/Project/object_depends.cxx
new file mode 100644
index 0000000..76e8197
--- /dev/null
+++ b/Tests/BuildDepends/Project/object_depends.cxx
@@ -0,0 +1 @@
+int main() { return 0; }
diff --git a/Tests/BuildDepends/Project/object_depends_check.cmake b/Tests/BuildDepends/Project/object_depends_check.cmake
new file mode 100644
index 0000000..e009892
--- /dev/null
+++ b/Tests/BuildDepends/Project/object_depends_check.cmake
@@ -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()