summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-08-10 12:58:25 (GMT)
committerKitware Robot <kwrobot@kitware.com>2023-08-10 12:58:34 (GMT)
commit1233da9f4a6f1c9c7fdc4b051bbdf745b7830ba1 (patch)
tree7fd149a37f932a525f472fe547732b009e9b5c96 /Tests
parentb47b44630ba14a8cd748bee06f47645862451506 (diff)
parent84eae7aedab558a12ab009b390f74bef011a3b1b (diff)
downloadCMake-1233da9f4a6f1c9c7fdc4b051bbdf745b7830ba1.zip
CMake-1233da9f4a6f1c9c7fdc4b051bbdf745b7830ba1.tar.gz
CMake-1233da9f4a6f1c9c7fdc4b051bbdf745b7830ba1.tar.bz2
Merge topic 'OPTIMIZE_DEPENDENCIES-runtime-targets'
84eae7aeda OPTIMIZE_DEPENDENCIES: Skip order-only deps for non-linking targets Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !8685
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/DependencyGraph/RunCMakeTest.cmake2
-rw-r--r--Tests/RunCMake/DependencyGraph/RuntimeTargets.cmake18
-rw-r--r--Tests/RunCMake/DependencyGraph/bottom.c7
-rw-r--r--Tests/RunCMake/DependencyGraph/middle.c9
-rw-r--r--Tests/RunCMake/DependencyGraph/neverbuild.c1
-rw-r--r--Tests/RunCMake/DependencyGraph/top.c9
6 files changed, 46 insertions, 0 deletions
diff --git a/Tests/RunCMake/DependencyGraph/RunCMakeTest.cmake b/Tests/RunCMake/DependencyGraph/RunCMakeTest.cmake
index 891e138..6847a23 100644
--- a/Tests/RunCMake/DependencyGraph/RunCMakeTest.cmake
+++ b/Tests/RunCMake/DependencyGraph/RunCMakeTest.cmake
@@ -59,3 +59,5 @@ run_optimize_test(OptimizeStatic StaticTop)
if(CMAKE_Fortran_COMPILER)
run_optimize_test(OptimizeFortran FortranTop)
endif()
+
+run_cmake_build(RuntimeTargets mylib SharedTop)
diff --git a/Tests/RunCMake/DependencyGraph/RuntimeTargets.cmake b/Tests/RunCMake/DependencyGraph/RuntimeTargets.cmake
new file mode 100644
index 0000000..21531cd
--- /dev/null
+++ b/Tests/RunCMake/DependencyGraph/RuntimeTargets.cmake
@@ -0,0 +1,18 @@
+enable_language(C)
+
+set(CMAKE_OPTIMIZE_DEPENDENCIES TRUE)
+add_library(mylib STATIC mylib.c)
+add_library(neverbuild SHARED neverbuild.c)
+
+# Building mylib should not require building neverbuild
+target_link_libraries(mylib PRIVATE neverbuild)
+set_target_properties(neverbuild PROPERTIES EXCLUDE_FROM_ALL YES)
+
+# Building SharedTop should require SharedBottom to be built
+add_library(SharedTop SHARED top.c)
+add_library(StaticMiddle STATIC middle.c)
+add_library(SharedBottom SHARED bottom.c)
+target_link_libraries(SharedTop PRIVATE StaticMiddle)
+target_link_libraries(StaticMiddle PRIVATE SharedBottom)
+set_target_properties(StaticMiddle SharedBottom PROPERTIES EXCLUDE_FROM_ALL YES)
+set_target_properties(StaticMiddle PROPERTIES POSITION_INDEPENDENT_CODE YES)
diff --git a/Tests/RunCMake/DependencyGraph/bottom.c b/Tests/RunCMake/DependencyGraph/bottom.c
new file mode 100644
index 0000000..c8ea481
--- /dev/null
+++ b/Tests/RunCMake/DependencyGraph/bottom.c
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+ int bottom(void)
+{
+ return 23;
+}
diff --git a/Tests/RunCMake/DependencyGraph/middle.c b/Tests/RunCMake/DependencyGraph/middle.c
new file mode 100644
index 0000000..3b1b84c
--- /dev/null
+++ b/Tests/RunCMake/DependencyGraph/middle.c
@@ -0,0 +1,9 @@
+#ifdef _WIN32
+__declspec(dllimport)
+#endif
+ int bottom(void);
+
+int middle(void)
+{
+ return bottom() + 19;
+}
diff --git a/Tests/RunCMake/DependencyGraph/neverbuild.c b/Tests/RunCMake/DependencyGraph/neverbuild.c
new file mode 100644
index 0000000..e490510
--- /dev/null
+++ b/Tests/RunCMake/DependencyGraph/neverbuild.c
@@ -0,0 +1 @@
+#error I should not be built
diff --git a/Tests/RunCMake/DependencyGraph/top.c b/Tests/RunCMake/DependencyGraph/top.c
new file mode 100644
index 0000000..eceb0a5
--- /dev/null
+++ b/Tests/RunCMake/DependencyGraph/top.c
@@ -0,0 +1,9 @@
+int middle(void);
+
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+ int top(void)
+{
+ return middle() + 2;
+}