cmake: Support ALIAS libraries

vsmodtest
Daniel Mensinger 5 years ago committed by Jussi Pakkanen
parent fbddeeb4ac
commit 534e94ffc3
  1. 11
      mesonbuild/cmake/traceparser.py
  2. 4
      test cases/linuxlike/13 cmake dependency/cmake/FindImportedTarget.cmake
  3. 9
      test cases/linuxlike/13 cmake dependency/meson.build

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

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

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

Loading…
Cancel
Save