diff options
author | Craig Scott <craig.scott@crascit.com> | 2023-08-04 06:34:35 (GMT) |
---|---|---|
committer | Craig Scott <craig.scott@crascit.com> | 2023-08-09 23:17:56 (GMT) |
commit | 84eae7aedab558a12ab009b390f74bef011a3b1b (patch) | |
tree | 00409a7566aa4ef5832d03c2ee85d04d5b5425d5 /Tests | |
parent | 21edd5af1f24d12612e3f6052b9497b848566855 (diff) | |
download | CMake-84eae7aedab558a12ab009b390f74bef011a3b1b.zip CMake-84eae7aedab558a12ab009b390f74bef011a3b1b.tar.gz CMake-84eae7aedab558a12ab009b390f74bef011a3b1b.tar.bz2 |
OPTIMIZE_DEPENDENCIES: Skip order-only deps for non-linking targets
Fixes: #21517
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/RunCMake/DependencyGraph/RunCMakeTest.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/DependencyGraph/RuntimeTargets.cmake | 18 | ||||
-rw-r--r-- | Tests/RunCMake/DependencyGraph/bottom.c | 7 | ||||
-rw-r--r-- | Tests/RunCMake/DependencyGraph/middle.c | 9 | ||||
-rw-r--r-- | Tests/RunCMake/DependencyGraph/neverbuild.c | 1 | ||||
-rw-r--r-- | Tests/RunCMake/DependencyGraph/top.c | 9 |
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; +} |