aboutsummaryrefslogtreecommitdiffstats
path: root/meson/test cases/cmake/11 cmake_module_path/meson.build
blob: e201936964bafdc5f131d32d39f4621056223cbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# We use Python3 as it's the only thing guaranteed to be available on any platform Meson can run on (unlike Zlib in linuxlike/13 cmake dependency).

project('user CMake find_package module using cmake_module_path', ['c', 'cpp'],
  meson_version: '>= 0.55.0')

if not find_program('cmake', required: false).found()
  error('MESON_SKIP_TEST cmake binary not available.')
endif

# NOTE: can't request Python3 via dependency('Python3', method: 'cmake')
#  Meson intercepts and wants "method: auto"

# Try to find a dependency with a custom CMake module

dependency('SomethingLikePython', required : true, method : 'cmake', cmake_module_path : 'cmake', modules: 'Python::Interpreter')

dependency('SomethingLikePython', method : 'cmake', cmake_module_path : ['doesNotExist', 'cmake'], modules: 'Python::Interpreter')

# Test a custom target with Python::Interpreter in COMMAND
cm = import('cmake')
op = cm.subproject_options()
op.add_cmake_defines({'CMAKE_MODULE_PATH': meson.source_root() / 'cmake'})
sp = cm.subproject('cmMod', options: op)
main = sp.target('main')
test('main', main)