diff options
author | Brad King <brad.king@kitware.com> | 2012-11-09 14:26:51 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2012-11-09 14:26:51 (GMT) |
commit | 306796e86206f2b6cf0bd3b66735f2e825c6bcbd (patch) | |
tree | 78007f8e683fa67c70432f917b38e3302bdf7ad6 /Tests/BuildDepends/Project | |
parent | ed9763136acdb8594e4b85ab7b2e4e2828d8b775 (diff) | |
download | CMake-306796e86206f2b6cf0bd3b66735f2e825c6bcbd.zip CMake-306796e86206f2b6cf0bd3b66735f2e825c6bcbd.tar.gz CMake-306796e86206f2b6cf0bd3b66735f2e825c6bcbd.tar.bz2 |
Teach BuildDepends test to cover LINK_DEPENDS_NO_SHARED
Build a shared library and an executable linking to it inside the inner
test. Set LINK_DEPENDS_NO_SHARED on the executable. Add a custom
target to compare the output file times. Verify that on the first build
the executable is newer than the library. Then modify a library source
file. Verify that on the second build the library is newer because the
executable did not have a dependency to re-link.
Diffstat (limited to 'Tests/BuildDepends/Project')
4 files changed, 39 insertions, 0 deletions
diff --git a/Tests/BuildDepends/Project/CMakeLists.txt b/Tests/BuildDepends/Project/CMakeLists.txt index 01f5f62..f47335d 100644 --- a/Tests/BuildDepends/Project/CMakeLists.txt +++ b/Tests/BuildDepends/Project/CMakeLists.txt @@ -107,3 +107,18 @@ if(TEST_LINK_DEPENDS) add_executable(linkdep linkdep.cxx) set_property(TARGET linkdep PROPERTY LINK_DEPENDS ${TEST_LINK_DEPENDS}) endif() + +add_library(link_depends_no_shared_lib SHARED link_depends_no_shared_lib.c + ${CMAKE_CURRENT_BINARY_DIR}/link_depends_no_shared_lib.h) +add_executable(link_depends_no_shared_exe link_depends_no_shared_exe.c + ${CMAKE_CURRENT_BINARY_DIR}/link_depends_no_shared_exe.h) +target_link_libraries(link_depends_no_shared_exe link_depends_no_shared_lib) +set_property(TARGET link_depends_no_shared_exe PROPERTY LINK_DEPENDS_NO_SHARED 1) +add_custom_target(link_depends_no_shared_check ALL + COMMAND ${CMAKE_COMMAND} + -Dlib=$<TARGET_FILE:link_depends_no_shared_lib> + -Dexe=$<TARGET_FILE:link_depends_no_shared_exe> + -Dout=${CMAKE_CURRENT_BINARY_DIR}/link_depends_no_shared_check.txt + -P ${CMAKE_CURRENT_SOURCE_DIR}/link_depends_no_shared_check.cmake + ) +add_dependencies(link_depends_no_shared_check link_depends_no_shared_exe) diff --git a/Tests/BuildDepends/Project/link_depends_no_shared_check.cmake b/Tests/BuildDepends/Project/link_depends_no_shared_check.cmake new file mode 100644 index 0000000..3a61137 --- /dev/null +++ b/Tests/BuildDepends/Project/link_depends_no_shared_check.cmake @@ -0,0 +1,7 @@ +if(NOT EXISTS "${lib}" OR NOT EXISTS "${exe}") + file(REMOVE "${out}") +elseif("${exe}" IS_NEWER_THAN "${lib}") + file(WRITE "${out}" "1\n") +else() + file(WRITE "${out}" "0\n") +endif() diff --git a/Tests/BuildDepends/Project/link_depends_no_shared_exe.c b/Tests/BuildDepends/Project/link_depends_no_shared_exe.c new file mode 100644 index 0000000..e9113a2 --- /dev/null +++ b/Tests/BuildDepends/Project/link_depends_no_shared_exe.c @@ -0,0 +1,9 @@ +#include "link_depends_no_shared_exe.h" +#ifdef _WIN32 +__declspec(dllimport) +#endif +int link_depends_no_shared_lib(void); +int main() +{ + return link_depends_no_shared_lib() + link_depends_no_shared_exe_value; +} diff --git a/Tests/BuildDepends/Project/link_depends_no_shared_lib.c b/Tests/BuildDepends/Project/link_depends_no_shared_lib.c new file mode 100644 index 0000000..d226289 --- /dev/null +++ b/Tests/BuildDepends/Project/link_depends_no_shared_lib.c @@ -0,0 +1,8 @@ +#include "link_depends_no_shared_lib.h" +#ifdef _WIN32 +__declspec(dllexport) +#endif +int link_depends_no_shared_lib(void) +{ + return link_depends_no_shared_lib_value; +} |