Repository: mesonbuild/meson

Issue:
cmake: cmake subproject does not configure with `ERROR: Arguments must be strings.`
**Describe the bug**
When running meson build with a cmake subproject, the command fails with 

```
Element not a string: [None]

meson.build:14:0: ERROR: Arguments must be strings.
```

Similar behaviour to https://github.com/mesonbuild/meson/issues/7715

**To Reproduce**
Relevant section of the meson.build file:

```
# telnet client
cmake = import('cmake')
telnetclient_proj = cmake.subproject('SimpleTelnetClient')
telnetclient_dep = telnetclient_proj.dependency('SimpleTelnetClient')
```

**Expected behavior**
The project configures everything correctly.

**system parameters**
Fedora 33
meson --version: 0.57.1




Discussion:
Can you please post your `meson-log.txt`, or even better, a simple project for reproducing this problem?

Resolving patch:
diff --git a/mesonbuild/modules/cmake.py b/mesonbuild/modules/cmake.py
--- a/mesonbuild/modules/cmake.py
+++ b/mesonbuild/modules/cmake.py
@@ -109,6 +109,8 @@ def get_variable(self, state, args, kwargs):
     @stringArgs
     def dependency(self, state, args, kwargs):
         info = self._args_to_info(args)
+        if info['func'] == 'executable':
+            raise InvalidArguments(f'{args[0]} is an executable and does not support the dependency() method. Use target() instead.')
         orig = self.get_variable(state, [info['dep']], {})
         assert isinstance(orig, dependencies.Dependency)
         actual = orig.include_type


Test patch:
diff --git a/test cases/failing/116 cmake executable dependency/meson.build b/test cases/failing/116 cmake executable dependency/meson.build
new file mode 100644
--- /dev/null
+++ b/test cases/failing/116 cmake executable dependency/meson.build	
@@ -0,0 +1,9 @@
+project('cmake-executable-dependency', ['c', 'cpp'])
+
+if not find_program('cmake', required: false).found()
+  error('MESON_SKIP_TEST CMake is not installed')
+endif
+
+cmake = import('cmake')
+cmlib = cmake.subproject('cmlib')
+maind = cmlib.dependency('main')
diff --git a/test cases/failing/116 cmake executable dependency/subprojects/cmlib/CMakeLists.txt b/test cases/failing/116 cmake executable dependency/subprojects/cmlib/CMakeLists.txt
new file mode 100644
--- /dev/null
+++ b/test cases/failing/116 cmake executable dependency/subprojects/cmlib/CMakeLists.txt	
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 3.5)
+
+project(cmlib)
+
+add_executable(main main.c)
diff --git a/test cases/failing/116 cmake executable dependency/subprojects/cmlib/main.c b/test cases/failing/116 cmake executable dependency/subprojects/cmlib/main.c
new file mode 100644
--- /dev/null
+++ b/test cases/failing/116 cmake executable dependency/subprojects/cmlib/main.c	
@@ -0,0 +1,3 @@
+int main(void) {
+    return 0;
+}
diff --git a/test cases/failing/116 cmake executable dependency/test.json b/test cases/failing/116 cmake executable dependency/test.json
new file mode 100644
--- /dev/null
+++ b/test cases/failing/116 cmake executable dependency/test.json	
@@ -0,0 +1,7 @@
+{
+    "stdout": [
+        {
+            "line": "test cases/failing/116 cmake executable dependency/meson.build:9:0: ERROR: main is an executable and does not support the dependency() method. Use target() instead."
+        }
+    ]
+}