meson.build 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. project('whole archive', 'c')
  2. add_project_arguments('-I' + meson.source_root(), language : 'c')
  3. cc = meson.get_compiler('c')
  4. if cc.get_id() == 'msvc'
  5. if cc.version().version_compare('<19')
  6. error('MESON_SKIP_TEST link_whole only works on VS2015 or newer.')
  7. endif
  8. endif
  9. # Test 1: link_whole keeps all symbols
  10. # Make static func1
  11. subdir('st_func1')
  12. # Make shared func2 linking whole func1 archive
  13. subdir('sh_func2_linked_func1')
  14. # Link exe with shared library only
  15. subdir('exe')
  16. # Test that both func1 and func2 are accessible from shared library
  17. test('prog', exe)
  18. # Test 2: link_whole can be used instead of source list, see #2180
  19. # Make static func2
  20. subdir('st_func2')
  21. # Link both func1 and func2 into same shared library
  22. # which does not have any sources other than 2 static libraries
  23. subdir('sh_only_link_whole')
  24. # Link exe2 with shared library only
  25. subdir('exe2')
  26. # Test that both func1 and func2 are accessible from shared library
  27. test('prog2', exe2)
  28. # Test 3: link_whole can be used in declare_dependency()
  29. func1_dep = declare_dependency(link_whole : [st_func1])
  30. # Use dependency to link func1 into shared library
  31. subdir('sh_func2_dep_func1')
  32. # Link exe3 with shared library
  33. subdir('exe3')
  34. # Test that both func1 and func2 are accessible from shared library
  35. test('prog3', exe3)
  36. # Test 4: link_whole can be used in transitive declare_dependency()
  37. func1_trans_dep = declare_dependency(dependencies : func1_dep)
  38. # Use transitive dependency to link func1 into shared library
  39. subdir('sh_func2_transdep_func1')
  40. # Link exe4 with shared library
  41. subdir('exe4')
  42. # Test that both func1 and func2 are accessible from shared library
  43. test('prog4', exe4)