meson.patch 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. diff --git a/meson.build b/meson.build
  2. index 024f1fb..b2fccd7 100644
  3. --- a/meson.build
  4. +++ b/meson.build
  5. @@ -277,18 +277,25 @@ mcfgthread_version_o = import('windows').compile_resources(
  6. args: [ '-I.', '-c65001' ],
  7. depend_files: [ 'mcfgthread/version.h.in', 'mcfgthread/version.manifest' ])
  8. -lib_mcfgthread_dll = shared_library('mcfgthread',
  9. - c_pch: 'mcfgthread/xprecompiled.h',
  10. - c_args: [ '-ffreestanding', '-fasynchronous-unwind-tables', '-DDLL_EXPORT' ],
  11. - link_args: [ '-nostdlib', '-Wl,--entry,__MCF_dll_startup@@Z',
  12. - '-Wl,--enable-auto-image-base', '-Wl,--subsystem,windows:6.1',
  13. - '-Wl,--exclude-all-symbols', '-Wl,--kill-at' ],
  14. - sources: [ mcfgthread_src, mcfgthread_version_o ],
  15. - dependencies: [ dep_kernel32, dep_ntdll ],
  16. - soversion: ver.get('abi_major'),
  17. - version: '.'.join([ ver.get('abi_major'), ver.get('abi_minor'), '0' ]),
  18. - install: true)
  19. +if get_option('default_library') == 'shared'
  20. + lib_mcfgthread_dll = shared_library('mcfgthread',
  21. + c_pch: 'mcfgthread/xprecompiled.h',
  22. + c_args: [ '-ffreestanding', '-fasynchronous-unwind-tables', '-DDLL_EXPORT' ],
  23. + link_args: [ '-nostdlib', '-Wl,--entry,__MCF_dll_startup@@Z',
  24. + '-Wl,--enable-auto-image-base', '-Wl,--subsystem,windows:6.1',
  25. + '-Wl,--exclude-all-symbols', '-Wl,--kill-at' ],
  26. + sources: [ mcfgthread_src, mcfgthread_version_o ],
  27. + dependencies: [ dep_kernel32, dep_ntdll ],
  28. + soversion: ver.get('abi_major'),
  29. + version: '.'.join([ ver.get('abi_major'), ver.get('abi_minor'), '0' ]),
  30. + install: true)
  31. + import('pkgconfig').generate(lib_mcfgthread_dll,
  32. + name: 'mcfgthread',
  33. + url: 'https://github.com/lhmouse/mcfgthread',
  34. + description: 'Cornerstone library for C++11 threading on mingw-w64',
  35. + libraries: '-lntdll')
  36. +elif get_option('default_library') == 'static'
  37. lib_mcfgthread_a = static_library('mcfgthread',
  38. c_pch: 'mcfgthread/xprecompiled.h',
  39. c_args: [ '-ffreestanding', '-fasynchronous-unwind-tables' ],
  40. @@ -296,35 +303,38 @@ lib_mcfgthread_a = static_library('mcfgthread',
  41. sources: [ mcfgthread_src ],
  42. install: true)
  43. -import('pkgconfig').generate(lib_mcfgthread_dll,
  44. - name: 'mcfgthread',
  45. - url: 'https://github.com/lhmouse/mcfgthread',
  46. - description: 'Cornerstone library for C++11 threading on mingw-w64',
  47. - libraries: '-lntdll')
  48. + import('pkgconfig').generate(lib_mcfgthread_a,
  49. + name: 'mcfgthread',
  50. + url: 'https://github.com/lhmouse/mcfgthread',
  51. + description: 'Cornerstone library for C++11 threading on mingw-w64',
  52. + libraries: '-lntdll')
  53. +endif
  54. #===========================================================
  55. # Rules for tests
  56. #===========================================================
  57. -foreach src: test_src
  58. - test(src, executable(src.replace('.c', '').underscorify(), src,
  59. - link_with: lib_mcfgthread_a))
  60. -endforeach
  61. +if get_option('build-test')
  62. + foreach src: test_src
  63. + test(src, executable(src.replace('.c', '').underscorify(), src,
  64. + link_with: lib_mcfgthread_a))
  65. + endforeach
  66. -# Specialized: -ladvapi32 -lntdll
  67. -test('test/memory.c', executable('test_memory_c',
  68. - 'test/memory.c',
  69. - dependencies: [ dep_advapi32, dep_ntdll ],
  70. - link_with: lib_mcfgthread_a))
  71. + # Specialized: -ladvapi32 -lntdll
  72. + test('test/memory.c', executable('test_memory_c',
  73. + 'test/memory.c',
  74. + dependencies: [ dep_advapi32, dep_ntdll ],
  75. + link_with: lib_mcfgthread_a))
  76. -# Specialized: -std=c89 -Wpedantic
  77. -test('test/gthr_c89_pedantic.c', executable('test_gthr_c89_pedantic_c',
  78. - 'test/gthr_c89_pedantic.c',
  79. - c_args: [ '-std=c89', '-Werror=declaration-after-statement',
  80. - '-Wpedantic', '-Wno-variadic-macros', '-Wno-long-long' ],
  81. - link_with: lib_mcfgthread_a))
  82. + # Specialized: -std=c89 -Wpedantic
  83. + test('test/gthr_c89_pedantic.c', executable('test_gthr_c89_pedantic_c',
  84. + 'test/gthr_c89_pedantic.c',
  85. + c_args: [ '-std=c89', '-Werror=declaration-after-statement',
  86. + '-Wpedantic', '-Wno-variadic-macros', '-Wno-long-long' ],
  87. + link_with: lib_mcfgthread_a))
  88. -# Specialized: -std=c99 -Wpedantic
  89. -test('test/c11_c99_pedantic.c', executable('test_c11_c99_pedantic_c',
  90. - 'test/c11_c99_pedantic.c',
  91. - c_args: [ '-std=c99', '-Wpedantic' ],
  92. - link_with: lib_mcfgthread_a))
  93. + # Specialized: -std=c99 -Wpedantic
  94. + test('test/c11_c99_pedantic.c', executable('test_c11_c99_pedantic_c',
  95. + 'test/c11_c99_pedantic.c',
  96. + c_args: [ '-std=c99', '-Wpedantic' ],
  97. + link_with: lib_mcfgthread_a))
  98. +endif
  99. \ No newline at end of file
  100. diff --git a/meson.options b/meson.options
  101. index d0342f8..b45d572 100644
  102. --- a/meson.options
  103. +++ b/meson.options
  104. @@ -15,3 +15,7 @@
  105. option('enable-debug-checks',
  106. type: 'boolean', value: false,
  107. description: 'enable run-time assertions')
  108. +
  109. +option('build-test',
  110. + type: 'boolean', value: false,
  111. + description: 'Build unit test')