cmake: Improved error message for using dependency for executables

fixes #8893
pull/8968/head
Daniel Mensinger 3 years ago committed by Jussi Pakkanen
parent bd6f46e723
commit 8e1c599c10
  1. 2
      mesonbuild/modules/cmake.py
  2. 9
      test cases/failing/116 cmake executable dependency/meson.build
  3. 5
      test cases/failing/116 cmake executable dependency/subprojects/cmlib/CMakeLists.txt
  4. 3
      test cases/failing/116 cmake executable dependency/subprojects/cmlib/main.c
  5. 7
      test cases/failing/116 cmake executable dependency/test.json

@ -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

@ -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')

@ -0,0 +1,5 @@
cmake_minimum_required(VERSION 3.5)
project(cmlib)
add_executable(main main.c)

@ -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."
}
]
}
Loading…
Cancel
Save