summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS')
-rw-r--r--Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/RunCMakeTest.cmake7
-rw-r--r--Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-check.cmake15
-rw-r--r--Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-static-result.txt1
-rw-r--r--Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-static-stderr.txt9
-rw-r--r--Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-static.cmake9
-rw-r--r--Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-target_link_libraries-cycle1-result.txt1
-rw-r--r--Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-target_link_libraries-cycle1-stderr.txt5
-rw-r--r--Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-target_link_libraries-cycle1.cmake4
-rw-r--r--Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-target_link_libraries-cycle2-result.txt1
-rw-r--r--Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-target_link_libraries-cycle2-stderr.txt5
-rw-r--r--Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-target_link_libraries-cycle2.cmake6
-rw-r--r--Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-target_link_libraries.cmake5
-rw-r--r--Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS.cmake37
-rw-r--r--Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/lib1.c12
-rw-r--r--Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/lib2.c6
-rw-r--r--Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/lib3.c6
-rw-r--r--Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/main.c4
-rw-r--r--Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/static.c3
19 files changed, 139 insertions, 0 deletions
diff --git a/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/CMakeLists.txt b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/CMakeLists.txt
new file mode 100644
index 0000000..ab1a20c
--- /dev/null
+++ b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.19)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/RunCMakeTest.cmake b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/RunCMakeTest.cmake
new file mode 100644
index 0000000..edc495c
--- /dev/null
+++ b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/RunCMakeTest.cmake
@@ -0,0 +1,7 @@
+include(RunCMake)
+
+run_cmake(TARGET_RUNTIME_DLLS)
+run_cmake(TARGET_RUNTIME_DLLS-static)
+run_cmake(TARGET_RUNTIME_DLLS-target_link_libraries)
+run_cmake(TARGET_RUNTIME_DLLS-target_link_libraries-cycle1)
+run_cmake(TARGET_RUNTIME_DLLS-target_link_libraries-cycle2)
diff --git a/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-check.cmake b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-check.cmake
new file mode 100644
index 0000000..e19598e
--- /dev/null
+++ b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-check.cmake
@@ -0,0 +1,15 @@
+function(check_genex expected actual)
+ if(NOT expected STREQUAL actual)
+ string(APPEND RunCMake_TEST_FAILED "Expected DLLs:\n")
+ foreach(dll IN LISTS expected)
+ string(APPEND RunCMake_TEST_FAILED " ${dll}\n")
+ endforeach()
+ string(APPEND RunCMake_TEST_FAILED "Actual DLLs:\n")
+ foreach(dll IN LISTS actual)
+ string(APPEND RunCMake_TEST_FAILED " ${dll}\n")
+ endforeach()
+ endif()
+ set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE)
+endfunction()
+
+include("${RunCMake_TEST_BINARY_DIR}/dlls.cmake")
diff --git a/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-static-result.txt b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-static-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-static-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-static-stderr.txt b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-static-stderr.txt
new file mode 100644
index 0000000..7ce588a
--- /dev/null
+++ b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-static-stderr.txt
@@ -0,0 +1,9 @@
+CMake Error at TARGET_RUNTIME_DLLS-static\.cmake:[0-9]+ \(file\):
+ Error evaluating generator expression:
+
+ \$<TARGET_RUNTIME_DLLS:static>
+
+ Objects of target "static" referenced but is not one of the allowed target
+ types \(EXECUTABLE, SHARED, MODULE\)\.
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-static.cmake b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-static.cmake
new file mode 100644
index 0000000..dc900dd
--- /dev/null
+++ b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-static.cmake
@@ -0,0 +1,9 @@
+enable_language(C)
+
+add_library(static STATIC static.c)
+set(condition)
+get_property(multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+if(multi_config)
+ set(condition CONDITION "$<CONFIG:Debug>")
+endif()
+file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/dlls.txt" CONTENT "$<TARGET_RUNTIME_DLLS:static>" ${condition})
diff --git a/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-target_link_libraries-cycle1-result.txt b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-target_link_libraries-cycle1-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-target_link_libraries-cycle1-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-target_link_libraries-cycle1-stderr.txt b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-target_link_libraries-cycle1-stderr.txt
new file mode 100644
index 0000000..8cfcf7e
--- /dev/null
+++ b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-target_link_libraries-cycle1-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at TARGET_RUNTIME_DLLS-target_link_libraries-cycle1\.cmake:[0-9]+ \(add_library\):
+ The SOURCES of "lib1" use a generator expression that depends on the
+ SOURCES themselves\.
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-target_link_libraries-cycle1.cmake b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-target_link_libraries-cycle1.cmake
new file mode 100644
index 0000000..f19e9e6
--- /dev/null
+++ b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-target_link_libraries-cycle1.cmake
@@ -0,0 +1,4 @@
+enable_language(C)
+
+add_library(lib1 SHARED lib1.c)
+target_link_libraries(lib1 PRIVATE $<TARGET_RUNTIME_DLLS:lib1>)
diff --git a/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-target_link_libraries-cycle2-result.txt b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-target_link_libraries-cycle2-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-target_link_libraries-cycle2-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-target_link_libraries-cycle2-stderr.txt b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-target_link_libraries-cycle2-stderr.txt
new file mode 100644
index 0000000..bacbf63
--- /dev/null
+++ b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-target_link_libraries-cycle2-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at TARGET_RUNTIME_DLLS-target_link_libraries-cycle2\.cmake:[0-9]+ \(add_library\):
+ The SOURCES of "(lib1|lib2)" use a generator expression that depends on the
+ SOURCES themselves\.
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-target_link_libraries-cycle2.cmake b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-target_link_libraries-cycle2.cmake
new file mode 100644
index 0000000..7d035bd
--- /dev/null
+++ b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-target_link_libraries-cycle2.cmake
@@ -0,0 +1,6 @@
+enable_language(C)
+
+add_library(lib1 SHARED lib1.c)
+add_library(lib2 SHARED lib2.c)
+target_link_libraries(lib1 PRIVATE $<TARGET_RUNTIME_DLLS:lib2>)
+target_link_libraries(lib2 PRIVATE $<TARGET_RUNTIME_DLLS:lib1>)
diff --git a/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-target_link_libraries.cmake b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-target_link_libraries.cmake
new file mode 100644
index 0000000..f44dbf4
--- /dev/null
+++ b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS-target_link_libraries.cmake
@@ -0,0 +1,5 @@
+enable_language(C)
+
+add_library(lib1 SHARED lib1.c)
+add_library(lib2 SHARED lib2.c)
+target_link_libraries(lib1 PRIVATE $<TARGET_RUNTIME_DLLS:lib2>)
diff --git a/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS.cmake b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS.cmake
new file mode 100644
index 0000000..806f0b6
--- /dev/null
+++ b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/TARGET_RUNTIME_DLLS.cmake
@@ -0,0 +1,37 @@
+enable_language(C)
+
+add_executable(exe main.c)
+add_library(lib1 SHARED lib1.c)
+add_library(lib2 SHARED lib2.c)
+add_library(lib3 SHARED lib3.c)
+add_library(static STATIC static.c)
+add_library(imported SHARED IMPORTED)
+set_property(TARGET imported PROPERTY IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/imported.dll")
+set_property(TARGET imported PROPERTY IMPORTED_IMPLIB "${CMAKE_SOURCE_DIR}/imported.lib")
+add_library(imported2 SHARED IMPORTED)
+if(NOT WIN32 AND NOT CYGWIN)
+ set_property(TARGET imported2 PROPERTY IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/imported2.dll")
+endif()
+set_property(TARGET imported2 PROPERTY IMPORTED_IMPLIB "${CMAKE_SOURCE_DIR}/imported2.lib")
+
+target_link_libraries(exe PRIVATE lib1 static imported imported2)
+target_link_libraries(lib1 PRIVATE lib2)
+target_link_libraries(lib1 INTERFACE lib3)
+
+set(expected_dlls "")
+if(WIN32 OR CYGWIN)
+ set(expected_dlls
+ "$<TARGET_FILE:lib1>"
+ "$<TARGET_FILE:imported>"
+ "$<TARGET_FILE:lib3>"
+ "$<TARGET_FILE:lib2>"
+ )
+endif()
+
+set(content "check_genex(\"${expected_dlls}\" \"$<TARGET_RUNTIME_DLLS:exe>\")\n")
+set(condition)
+get_property(multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+if(multi_config)
+ set(condition CONDITION "$<CONFIG:Debug>")
+endif()
+file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/dlls.cmake" CONTENT "${content}" ${condition})
diff --git a/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/lib1.c b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/lib1.c
new file mode 100644
index 0000000..524b5b2
--- /dev/null
+++ b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/lib1.c
@@ -0,0 +1,12 @@
+#ifdef _WIN32
+__declspec(dllimport)
+#endif
+ extern void lib2(void);
+
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+ void lib1(void)
+{
+ lib2();
+}
diff --git a/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/lib2.c b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/lib2.c
new file mode 100644
index 0000000..e145117
--- /dev/null
+++ b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/lib2.c
@@ -0,0 +1,6 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+ void lib2(void)
+{
+}
diff --git a/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/lib3.c b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/lib3.c
new file mode 100644
index 0000000..5392f7a
--- /dev/null
+++ b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/lib3.c
@@ -0,0 +1,6 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+ void lib3(void)
+{
+}
diff --git a/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/main.c b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/main.c
new file mode 100644
index 0000000..8488f4e
--- /dev/null
+++ b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/main.c
@@ -0,0 +1,4 @@
+int main(void)
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/static.c b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/static.c
new file mode 100644
index 0000000..7f5dab5
--- /dev/null
+++ b/Tests/RunCMake/GenEx-TARGET_RUNTIME_DLLS/static.c
@@ -0,0 +1,3 @@
+void static_func(void)
+{
+}