diff --git a/mesonbuild/modules/cmake.py b/mesonbuild/modules/cmake.py index c390b01c3..cc259dcdc 100644 --- a/mesonbuild/modules/cmake.py +++ b/mesonbuild/modules/cmake.py @@ -109,6 +109,8 @@ class CMakeSubproject(ModuleObject): @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 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 index 000000000..bfb03ef20 --- /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 index 000000000..006787986 --- /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 index 000000000..9b6bdc2ec --- /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 index 000000000..d11cfa76b --- /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." + } + ] +}