diff options
author | Gregor Jasny <gjasny@googlemail.com> | 2017-02-18 21:27:46 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-02-22 20:21:06 (GMT) |
commit | 624021a09e7850b1f6cb75af40b17a38d98c95e3 (patch) | |
tree | 5d6a3216ae39575a69f78692f847a513549c4ee8 /Tests/RunCMake/ObjectLibrary | |
parent | 5da9266af50af3c2c1a827a1d162c8a9b16e7fd9 (diff) | |
download | CMake-624021a09e7850b1f6cb75af40b17a38d98c95e3.zip CMake-624021a09e7850b1f6cb75af40b17a38d98c95e3.tar.gz CMake-624021a09e7850b1f6cb75af40b17a38d98c95e3.tar.bz2 |
Add test for object library dependencies
Issue: #16615
Diffstat (limited to 'Tests/RunCMake/ObjectLibrary')
-rw-r--r-- | Tests/RunCMake/ObjectLibrary/Dependencies.cmake | 11 | ||||
-rw-r--r-- | Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake | 19 | ||||
-rw-r--r-- | Tests/RunCMake/ObjectLibrary/depends_lib.cpp | 7 | ||||
-rw-r--r-- | Tests/RunCMake/ObjectLibrary/depends_main.cpp | 7 | ||||
-rw-r--r-- | Tests/RunCMake/ObjectLibrary/depends_obj0.cpp | 4 | ||||
-rw-r--r-- | Tests/RunCMake/ObjectLibrary/depends_obj1.cpp | 4 |
6 files changed, 52 insertions, 0 deletions
diff --git a/Tests/RunCMake/ObjectLibrary/Dependencies.cmake b/Tests/RunCMake/ObjectLibrary/Dependencies.cmake new file mode 100644 index 0000000..4e3db5f --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/Dependencies.cmake @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.7) + +project(Dependencies) + +add_library(myobj OBJECT ${CMAKE_BINARY_DIR}/depends_obj.cpp) +add_library(mylib STATIC $<TARGET_OBJECTS:myobj> depends_lib.cpp) +add_executable(myexe depends_main.cpp) +target_link_libraries(myexe mylib) + +enable_testing() +add_test(NAME myexe COMMAND $<TARGET_FILE:myexe>) diff --git a/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake b/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake index 42973f8..9291218 100644 --- a/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake +++ b/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake @@ -16,3 +16,22 @@ run_cmake(ObjWithObj) run_cmake(PostBuild) run_cmake(PreBuild) run_cmake(PreLink) + +function(run_Dependencies) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Dependencies-build) + set(RunCMake_TEST_NO_CLEAN 1) + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake_command(Dependencies-build ${CMAKE_COMMAND} -E copy ${RunCMake_SOURCE_DIR}/depends_obj1.cpp ${RunCMake_TEST_BINARY_DIR}/depends_obj.cpp) + run_cmake(Dependencies) + run_cmake_command(Dependencies-build ${CMAKE_COMMAND} --build .) + run_cmake_command(Dependencies-build ${CMAKE_COMMAND} -E copy ${RunCMake_SOURCE_DIR}/depends_obj0.cpp ${RunCMake_TEST_BINARY_DIR}/depends_obj.cpp) + run_cmake_command(Dependencies-build ${CMAKE_COMMAND} -E sleep 1) + run_cmake_command(Dependencies-build ${CMAKE_COMMAND} -E touch_nocreate ${RunCMake_TEST_BINARY_DIR}/depends_obj.cpp) + run_cmake_command(Dependencies-build ${CMAKE_COMMAND} --build .) + run_cmake_command(Dependencies-build ${CMAKE_CTEST_COMMAND} -C Debug) +endfunction() + +run_Dependencies() diff --git a/Tests/RunCMake/ObjectLibrary/depends_lib.cpp b/Tests/RunCMake/ObjectLibrary/depends_lib.cpp new file mode 100644 index 0000000..540b536 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/depends_lib.cpp @@ -0,0 +1,7 @@ +#include <stdlib.h> +int myobj_foo(); + +void mylib_foo() +{ + exit(myobj_foo()); +} diff --git a/Tests/RunCMake/ObjectLibrary/depends_main.cpp b/Tests/RunCMake/ObjectLibrary/depends_main.cpp new file mode 100644 index 0000000..a9d323d --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/depends_main.cpp @@ -0,0 +1,7 @@ +void mylib_foo(); + +int main() +{ + mylib_foo(); + return 0; +} diff --git a/Tests/RunCMake/ObjectLibrary/depends_obj0.cpp b/Tests/RunCMake/ObjectLibrary/depends_obj0.cpp new file mode 100644 index 0000000..73a17e7 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/depends_obj0.cpp @@ -0,0 +1,4 @@ +int myobj_foo() +{ + return 0; +} diff --git a/Tests/RunCMake/ObjectLibrary/depends_obj1.cpp b/Tests/RunCMake/ObjectLibrary/depends_obj1.cpp new file mode 100644 index 0000000..f62ef70 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/depends_obj1.cpp @@ -0,0 +1,4 @@ +int myobj_foo() +{ + return 1; +} |