diff options
-rw-r--r-- | mesonbuild/cmake/traceparser.py | 11 | ||||
-rw-r--r-- | test cases/linuxlike/13 cmake dependency/cmake/FindImportedTarget.cmake | 4 | ||||
-rw-r--r-- | test cases/linuxlike/13 cmake dependency/meson.build | 9 |
3 files changed, 19 insertions, 5 deletions
diff --git a/mesonbuild/cmake/traceparser.py b/mesonbuild/cmake/traceparser.py index 3a3f269..878c6a3 100644 --- a/mesonbuild/cmake/traceparser.py +++ b/mesonbuild/cmake/traceparser.py @@ -214,11 +214,20 @@ class CMakeTraceParser: elif 'IMPORTED' in args: args.remove('IMPORTED') - # No only look at the first two arguments (target_name and target_type) and ignore the rest + # Now, only look at the first two arguments (target_name and target_type) and ignore the rest if len(args) < 2: return self._gen_exception('add_library', 'requires at least 2 arguments', tline) self.targets[args[0]] = CMakeTarget(args[0], args[1], {}) + elif 'ALIAS' in args: + args.remove('ALIAS') + + # Now, only look at the first two arguments (target_name and target_ref) and ignore the rest + if len(args) < 2: + return self._gen_exception('add_library', 'requires at least 2 arguments', tline) + + # Simulate the ALIAS with INTERFACE_LINK_LIBRARIES + self.targets[args[0]] = CMakeTarget(args[0], 'ALIAS', {'INTERFACE_LINK_LIBRARIES': [args[1]]}) else: return self._gen_exception('add_library', 'non imported / interface libraries are not supported', tline) diff --git a/test cases/linuxlike/13 cmake dependency/cmake/FindImportedTarget.cmake b/test cases/linuxlike/13 cmake dependency/cmake/FindImportedTarget.cmake index d65c6fb..753df5b 100644 --- a/test cases/linuxlike/13 cmake dependency/cmake/FindImportedTarget.cmake +++ b/test cases/linuxlike/13 cmake dependency/cmake/FindImportedTarget.cmake @@ -2,12 +2,14 @@ find_package(ZLIB) if(ZLIB_FOUND OR ZLIB_Found) set(ImportedTarget_FOUND ON) - add_library(mesonTestLibDefs UNKNOWN IMPORTED) + add_library(mesonTestLibDefs SHARED 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) + set_target_properties(mesonTestLibDefs PROPERTIES IMPORTED_GLOBAL TRUE) + add_library(MesonTest::TestLibDefs ALIAS mesonTestLibDefs) 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 411b7a3..7d99764 100644 --- a/test cases/linuxlike/13 cmake dependency/meson.build +++ b/test cases/linuxlike/13 cmake dependency/meson.build @@ -48,9 +48,12 @@ depm3 = dependency('SomethingLikeZLIB', required : true, cmake_module_path : 'cm # 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) +testDep1 = dependency('ImportedTarget', required : true, method : 'cmake', cmake_module_path : 'cmake', modules: 'mesonTestLibDefs') +testDep2 = dependency('ImportedTarget', required : true, method : 'cmake', cmake_module_path : 'cmake', modules : ['MesonTest::TestLibDefs']) +testFlagSet1 = executable('testFlagSet1', ['testFlagSet.c'], dependencies: [testDep1]) +testFlagSet2 = executable('testFlagSet2', ['testFlagSet.c'], dependencies: [testDep2]) +test('testFlagSetTest1', testFlagSet1) +test('testFlagSetTest2', testFlagSet2) # Try to compile a test that takes a dep and an include_directories |