diff options
author | Daniel Mensinger <daniel@mensinger-ka.de> | 2020-12-30 10:40:25 +0100 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2021-01-10 21:48:23 +0000 |
commit | 8f1d9bb7b0cca265276c46caf928c047870b34f1 (patch) | |
tree | 01e3192d369e532f48ad054be5feca51abec7ea4 | |
parent | a8c138ebc1f9005f7c32c78eae67a6289130e9c4 (diff) | |
download | meson-8f1d9bb7b0cca265276c46caf928c047870b34f1.zip meson-8f1d9bb7b0cca265276c46caf928c047870b34f1.tar.gz meson-8f1d9bb7b0cca265276c46caf928c047870b34f1.tar.bz2 |
cmake: add PATH logic to preliminary dep check (fixes #8133)
7 files changed, 35 insertions, 5 deletions
diff --git a/docs/markdown/Contributing.md b/docs/markdown/Contributing.md index c9cebee..46fe57f 100644 --- a/docs/markdown/Contributing.md +++ b/docs/markdown/Contributing.md @@ -219,8 +219,12 @@ Exanple `test.json`: #### env The `env` key contains a dictionary which specifies additional -environment variables to be set during the configure step of the test. `@ROOT@` -is replaced with the absolute path of the source directory. +environment variables to be set during the configure step of the test. + +There is some basic support for configuring the string with the `@<VAR>@` syntax: + +- `@ROOT@`: absolute path of the source directory +- `@PATH@`: current value of the `PATH` env variable #### installed diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index e359219..9ddf6db 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -1186,7 +1186,12 @@ class CMakeDependency(ExternalDependency): return None def process_paths(l: T.List[str]) -> T.Set[str]: - l = [x.split(':') for x in l] + if mesonlib.is_windows(): + # Cannot split on ':' on Windows because its in the drive letter + l = [x.split(os.pathsep) for x in l] + else: + # https://github.com/mesonbuild/meson/issues/7294 + l = [re.split(r':|;', x) for x in l] l = [x for sublist in l for x in sublist] return set(l) @@ -1290,8 +1295,17 @@ class CMakeDependency(ExternalDependency): if search_lib_dirs(i): return True + # Check PATH + system_env = [] # type: T.List[str] + for i in os.environ.get('PATH', '').split(os.pathsep): + if i.endswith('/bin') or i.endswith('\\bin'): + i = i[:-4] + if i.endswith('/sbin') or i.endswith('\\sbin'): + i = i[:-5] + system_env += [i] + # Check the system paths - for i in self.cmakeinfo['module_paths']: + for i in self.cmakeinfo['module_paths'] + system_env: if find_module(i): return True diff --git a/run_project_tests.py b/run_project_tests.py index 1dff386..772aa2e 100755 --- a/run_project_tests.py +++ b/run_project_tests.py @@ -653,6 +653,7 @@ def gather_tests(testdir: Path, stdout_mandatory: bool) -> T.List[TestDef]: env = test_def['env'] for key, val in env.items(): val = val.replace('@ROOT@', t.path.resolve().as_posix()) + val = val.replace('@PATH@', t.env.get('PATH', '')) env[key] = val # Handle installed files diff --git a/test cases/linuxlike/13 cmake dependency/cmake_fake3/bin/.gitkeep b/test cases/linuxlike/13 cmake dependency/cmake_fake3/bin/.gitkeep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/linuxlike/13 cmake dependency/cmake_fake3/bin/.gitkeep diff --git a/test cases/linuxlike/13 cmake dependency/cmake_fake3/lib/cmake/cmMesonTestF3/cmMesonTestF3Config.cmake b/test cases/linuxlike/13 cmake dependency/cmake_fake3/lib/cmake/cmMesonTestF3/cmMesonTestF3Config.cmake new file mode 100644 index 0000000..2fab395 --- /dev/null +++ b/test cases/linuxlike/13 cmake dependency/cmake_fake3/lib/cmake/cmMesonTestF3/cmMesonTestF3Config.cmake @@ -0,0 +1,9 @@ +find_package(ZLIB) + +if(ZLIB_FOUND OR ZLIB_Found) + set(cmMesonTestF3_FOUND ON) + set(cmMesonTestF3_LIBRARIES ${ZLIB_LIBRARY}) + set(cmMesonTestF3_INCLUDE_DIRS ${ZLIB_INCLUDE_DIR}) +else() + set(cmMesonTestF3_FOUND OFF) +endif() diff --git a/test cases/linuxlike/13 cmake dependency/meson.build b/test cases/linuxlike/13 cmake dependency/meson.build index 23b34d6..67d53cf 100644 --- a/test cases/linuxlike/13 cmake dependency/meson.build +++ b/test cases/linuxlike/13 cmake dependency/meson.build @@ -46,6 +46,7 @@ assert(depf2.found() == false, 'Invalid CMake targets should fail') depPrefEnv = dependency('cmMesonTestDep', required : true, method : 'cmake') depPrefEnv1 = dependency('cmMesonTestF1', required : true, method : 'cmake') depPrefEnv2 = dependency('cmMesonTestF2', required : true, method : 'cmake') +depPrefEnv3 = dependency('cmMesonTestF3', required : true, method : 'cmake') # Try to find a dependency with a custom CMake module diff --git a/test cases/linuxlike/13 cmake dependency/test.json b/test cases/linuxlike/13 cmake dependency/test.json index fc29f72..a125536 100644 --- a/test cases/linuxlike/13 cmake dependency/test.json +++ b/test cases/linuxlike/13 cmake dependency/test.json @@ -1,5 +1,6 @@ { "env": { - "CMAKE_PREFIX_PATH": "@ROOT@/cmake_fake1;@ROOT@/cmake_fake2:@ROOT@/cmake_pref_env" + "CMAKE_PREFIX_PATH": "@ROOT@/cmake_fake1;@ROOT@/cmake_fake2:@ROOT@/cmake_pref_env", + "PATH": "@ROOT@/cmake_fake3/bin:@PATH@" } } |