meson.build 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. project('glslang', 'cpp',
  2. version : '11.2.0',
  3. meson_version : '>=0.50.0',
  4. default_options : [
  5. 'cpp_std=gnu++11',
  6. ]
  7. )
  8. native_options = [
  9. 'b_lto=false',
  10. 'b_ndebug=true',
  11. 'b_sanitize=none',
  12. 'debug=false',
  13. 'optimization=0',
  14. ]
  15. cxx = meson.get_compiler('cpp')
  16. cxx_native = meson.get_compiler('cpp', native : true)
  17. compiler_args = [
  18. '-fpermissive',
  19. '-fno-strict-aliasing',
  20. ]
  21. add_project_arguments(cxx.get_supported_arguments(compiler_args), language : 'cpp', native : false)
  22. add_project_arguments(cxx_native.get_supported_arguments(compiler_args), language : 'cpp', native : true)
  23. project_args = []
  24. threads_dep = dependency('threads')
  25. threads_native_dep = dependency('threads', required : false, native : true)
  26. spvtools_dep = dependency('SPIRV-Tools', required : get_option('enable_opt'), fallback : ['SPIRV-Tools', 'spirv_tools_opt_dep'])
  27. spvtools_native_dep = dependency('SPIRV-Tools', required : false, native : true, fallback : ['SPIRV-Tools', 'spirv_tools_opt_native_dep'])
  28. if not get_option('enable_hlsl').disabled()
  29. project_args += '-DENABLE_HLSL'
  30. endif
  31. if spvtools_dep.found()
  32. project_args += '-DENABLE_OPT=1'
  33. else
  34. project_args += '-DENABLE_OPT=0'
  35. if not get_option('enable_hlsl').disabled()
  36. warning('SPIRV-Tools not linked - illegal SPIRV may be generated for HLSL')
  37. endif
  38. endif
  39. if host_machine.system() == 'windows'
  40. project_args += '-DGLSLANG_OSINCLUDE_WIN32'
  41. else
  42. project_args += '-DGLSLANG_OSINCLUDE_UNIX'
  43. endif
  44. add_project_arguments(project_args, language : 'cpp', native : false)
  45. add_project_arguments(project_args, language : 'cpp', native : true)
  46. glslang_source_root = meson.current_source_dir()
  47. glslang_changes = files('CHANGES.md')
  48. glslang_buildinfo_gen = files('build_info.py')
  49. glslang_buildinfo_tmpl = files('build_info.h.tmpl')
  50. glslang_include_dirs = include_directories('.')
  51. python = import('python').find_installation('python3').path()
  52. subdir('glslang')
  53. subdir('SPIRV')
  54. subdir('OGLCompilersDLL')
  55. glslang_libs = [libspirv, liboglcompiler]
  56. glslang_native_libs = [libspirv_native, liboglcompiler_native]
  57. glslang_args = []
  58. if not get_option('enable_hlsl').disabled()
  59. glslang_libs += libhlsl
  60. glslang_native_libs += libhlsl_native
  61. glslang_args += '-DENABLE_HLSL'
  62. endif
  63. libglslang = library('glslang',
  64. glslang_src,
  65. cpp_pch : 'glslang/MachineIndependent/pch.h',
  66. link_with : glslang_libs,
  67. cpp_args : glslang_args,
  68. dependencies : [spvtools_dep, threads_dep],
  69. build_by_default : not meson.is_subproject(),
  70. include_directories : glslang_include_dirs,
  71. )
  72. libglslang_native = library('glslang-native',
  73. glslang_src,
  74. cpp_pch : 'glslang/MachineIndependent/pch.h',
  75. link_with : glslang_native_libs,
  76. cpp_args : glslang_args,
  77. dependencies : [spvtools_native_dep, threads_native_dep],
  78. build_by_default : false,
  79. native : true,
  80. include_directories : glslang_include_dirs,
  81. override_options : native_options,
  82. )
  83. glslang_dep = declare_dependency(
  84. link_with : libglslang,
  85. compile_args : glslang_args, # because the google/khronos mouth breathers don't understand how public APIs work
  86. include_directories : glslang_include_dirs,
  87. version : meson.project_version(),
  88. )
  89. glslang_native_dep = declare_dependency(
  90. link_with : libglslang_native,
  91. compile_args : glslang_args, # because the google/khronos mouth breathers don't understand how public APIs work
  92. include_directories : glslang_include_dirs,
  93. version : meson.project_version(),
  94. )