aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/dependencies/base.py32
-rw-r--r--test cases/linuxlike/13 cmake dependency/cmake/FindImportedTarget.cmake13
-rw-r--r--test cases/linuxlike/13 cmake dependency/meson.build6
-rw-r--r--test cases/linuxlike/13 cmake dependency/testFlagSet.c18
4 files changed, 52 insertions, 17 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
index 8616367..76425f3 100644
--- a/mesonbuild/dependencies/base.py
+++ b/mesonbuild/dependencies/base.py
@@ -1290,9 +1290,9 @@ class CMakeDependency(ExternalDependency):
# Failed to guess a target --> try the old-style method
if len(modules) == 0:
- incDirs = self.traceparser.get_cmake_var('PACKAGE_INCLUDE_DIRS')
- defs = self.traceparser.get_cmake_var('PACKAGE_DEFINITIONS')
- libs = self.traceparser.get_cmake_var('PACKAGE_LIBRARIES')
+ incDirs = [x for x in self.traceparser.get_cmake_var('PACKAGE_INCLUDE_DIRS') if x]
+ defs = [x for x in self.traceparser.get_cmake_var('PACKAGE_DEFINITIONS') if x]
+ libs = [x for x in self.traceparser.get_cmake_var('PACKAGE_LIBRARIES') if x]
# Try to use old style variables if no module is specified
if len(libs) > 0:
@@ -1340,39 +1340,37 @@ class CMakeDependency(ExternalDependency):
mlog.debug(tgt)
if 'INTERFACE_INCLUDE_DIRECTORIES' in tgt.properies:
- incDirs += tgt.properies['INTERFACE_INCLUDE_DIRECTORIES']
+ incDirs += [x for x in tgt.properies['INTERFACE_INCLUDE_DIRECTORIES'] if x]
if 'INTERFACE_COMPILE_DEFINITIONS' in tgt.properies:
- tempDefs = list(tgt.properies['INTERFACE_COMPILE_DEFINITIONS'])
- tempDefs = list(map(lambda x: '-D{}'.format(re.sub('^-D', '', x)), tempDefs))
- compileDefinitions += tempDefs
+ compileDefinitions += ['-D' + re.sub('^-D', '', x) for x in tgt.properies['INTERFACE_COMPILE_DEFINITIONS'] if x]
if 'INTERFACE_COMPILE_OPTIONS' in tgt.properies:
- compileOptions += tgt.properies['INTERFACE_COMPILE_OPTIONS']
+ compileOptions += [x for x in tgt.properies['INTERFACE_COMPILE_OPTIONS'] if x]
if 'IMPORTED_CONFIGURATIONS' in tgt.properies:
- cfgs = tgt.properies['IMPORTED_CONFIGURATIONS']
+ cfgs = [x for x in tgt.properies['IMPORTED_CONFIGURATIONS'] if x]
cfg = cfgs[0]
if 'RELEASE' in cfgs:
cfg = 'RELEASE'
if 'IMPORTED_IMPLIB_{}'.format(cfg) in tgt.properies:
- libraries += tgt.properies['IMPORTED_IMPLIB_{}'.format(cfg)]
+ libraries += [x for x in tgt.properies['IMPORTED_IMPLIB_{}'.format(cfg)] if x]
elif 'IMPORTED_IMPLIB' in tgt.properies:
- libraries += tgt.properies['IMPORTED_IMPLIB']
+ libraries += [x for x in tgt.properies['IMPORTED_IMPLIB'] if x]
elif 'IMPORTED_LOCATION_{}'.format(cfg) in tgt.properies:
- libraries += tgt.properies['IMPORTED_LOCATION_{}'.format(cfg)]
+ libraries += [x for x in tgt.properies['IMPORTED_LOCATION_{}'.format(cfg)] if x]
elif 'IMPORTED_LOCATION' in tgt.properies:
- libraries += tgt.properies['IMPORTED_LOCATION']
+ libraries += [x for x in tgt.properies['IMPORTED_LOCATION'] if x]
if 'INTERFACE_LINK_LIBRARIES' in tgt.properies:
- otherDeps += tgt.properies['INTERFACE_LINK_LIBRARIES']
+ otherDeps += [x for x in tgt.properies['INTERFACE_LINK_LIBRARIES'] if x]
if 'IMPORTED_LINK_DEPENDENT_LIBRARIES_{}'.format(cfg) in tgt.properies:
- otherDeps += tgt.properies['IMPORTED_LINK_DEPENDENT_LIBRARIES_{}'.format(cfg)]
+ otherDeps += [x for x in tgt.properies['IMPORTED_LINK_DEPENDENT_LIBRARIES_{}'.format(cfg)] if x]
elif 'IMPORTED_LINK_DEPENDENT_LIBRARIES' in tgt.properies:
- otherDeps += tgt.properies['IMPORTED_LINK_DEPENDENT_LIBRARIES']
+ otherDeps += [x for x in tgt.properies['IMPORTED_LINK_DEPENDENT_LIBRARIES'] if x]
for j in otherDeps:
if j in self.traceparser.targets:
@@ -1391,7 +1389,7 @@ class CMakeDependency(ExternalDependency):
mlog.debug('Compiler Options: {}'.format(compileOptions))
mlog.debug('Libraries: {}'.format(libraries))
- self.compile_args = compileOptions + compileDefinitions + list(map(lambda x: '-I{}'.format(x), incDirs))
+ self.compile_args = compileOptions + compileDefinitions + ['-I{}'.format(x) for x in incDirs]
self.link_args = libraries
def _setup_cmake_dir(self, cmake_file: str) -> str:
diff --git a/test cases/linuxlike/13 cmake dependency/cmake/FindImportedTarget.cmake b/test cases/linuxlike/13 cmake dependency/cmake/FindImportedTarget.cmake
new file mode 100644
index 0000000..d65c6fb
--- /dev/null
+++ b/test cases/linuxlike/13 cmake dependency/cmake/FindImportedTarget.cmake
@@ -0,0 +1,13 @@
+find_package(ZLIB)
+
+if(ZLIB_FOUND OR ZLIB_Found)
+ set(ImportedTarget_FOUND ON)
+ add_library(mesonTestLibDefs UNKNOWN IMPORTED)
+ set_property(TARGET mesonTestLibDefs PROPERTY IMPORTED_LOCATION ${ZLIB_LIBRARY})
+ set_property(TARGET mesonTestLibDefs PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${ZLIB_INCLUDE_DIR})
+ set_property(TARGET mesonTestLibDefs APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS REQUIRED_MESON_FLAG1)
+ set_property(TARGET mesonTestLibDefs APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS $<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG>) # Error empty string
+ set_property(TARGET mesonTestLibDefs APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS REQUIRED_MESON_FLAG2)
+else()
+ set(ImportedTarget_FOUND OFF)
+endif()
diff --git a/test cases/linuxlike/13 cmake dependency/meson.build b/test cases/linuxlike/13 cmake dependency/meson.build
index a18cd84..84c1d31 100644
--- a/test cases/linuxlike/13 cmake dependency/meson.build
+++ b/test cases/linuxlike/13 cmake dependency/meson.build
@@ -42,6 +42,12 @@ depm1 = dependency('SomethingLikeZLIB', required : true, method : 'cmake', cmake
depm2 = dependency('SomethingLikeZLIB', required : true, method : 'cmake', cmake_module_path : ['cmake'])
depm3 = dependency('SomethingLikeZLIB', required : true, cmake_module_path : 'cmake')
+# Test some edge cases with spaces, etc.
+
+testDep = dependency('ImportedTarget', required : true, method : 'cmake', cmake_module_path : 'cmake', modules: 'mesonTestLibDefs')
+testFlagSet = executable('testFlagSet', ['testFlagSet.c'], dependencies: [testDep])
+test('testFlagSetTest', testFlagSet)
+
# Try to compile a test that takes a dep and an include_directories
cc = meson.get_compiler('c')
diff --git a/test cases/linuxlike/13 cmake dependency/testFlagSet.c b/test cases/linuxlike/13 cmake dependency/testFlagSet.c
new file mode 100644
index 0000000..0c92690
--- /dev/null
+++ b/test cases/linuxlike/13 cmake dependency/testFlagSet.c
@@ -0,0 +1,18 @@
+#include<stdio.h>
+#include<zlib.h>
+
+#ifndef REQUIRED_MESON_FLAG1
+#error "REQUIRED_MESON_FLAG1 not set"
+#endif
+
+#ifndef REQUIRED_MESON_FLAG2
+#error "REQUIRED_MESON_FLAG2 not set"
+#endif
+
+int main(int argc, char *argv[]) {
+ printf("Hello World\n");
+ void * something = deflate;
+ if(something != 0)
+ return 0;
+ return 1;
+}