[gjs: 2/6] meson: Ignore precompiled headers option under g++ and earlier versions of meson




commit e9cded086977c5f1863881bc6723545f24464b38
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Thu May 6 22:06:49 2021 +0200

    meson: Ignore precompiled headers option under g++ and earlier versions of meson
    
    This is not supported because g++ will only pick a pch if it's the first
    included source, but mozjs will provide us an `-include` cflag that
    meson will use it too early.
    
    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100462
    https://github.com/mesonbuild/meson/pull/8740

 meson.build | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/meson.build b/meson.build
index 92dff728..3cf75661 100644
--- a/meson.build
+++ b/meson.build
@@ -5,7 +5,7 @@
 project('gjs', 'cpp', 'c', version: '1.69.1', license: ['MIT', 'LGPL2+'],
     meson_version: '>= 0.52.0',
     default_options: ['cpp_std=c++17', 'cpp_rtti=false', 'c_std=c99',
-        'warning_level=2'])
+        'warning_level=2', 'b_pch=true' ])
 
 # cpp_rtti: SpiderMonkey can be compiled with or without runtime type
 # information, and the default is without. We must match that option because we
@@ -496,11 +496,19 @@ if host_machine.system() == 'windows'
     libgjs_cpp_args += ['-DWIN32', '-DXP_WIN']
 endif
 
+pch_headers = ['gjs/gjs_pch.hh']
+if get_option('b_pch') and not meson.version().version_compare('>= 0.58.1')
+    if cxx.get_id() == 'gcc'
+        warning('Precompiled headers not supported with g++ and meson versions earlier than 0.58.1')
+        pch_headers = []
+    endif
+endif
+
 libgjs_jsapi = static_library(meson.project_name() + '-jsapi',
     libgjs_jsapi_sources, probes_header, probes_objfile,
     cpp_args: libgjs_cpp_args,
     dependencies: libgjs_dependencies,
-    cpp_pch: 'gjs/gjs_pch.hh',
+    cpp_pch: pch_headers,
     install: false)
 
 link_args = []
@@ -520,7 +528,7 @@ libgjs = shared_library(meson.project_name(),
     link_args: link_args, link_depends: [symbol_map, symbol_list],
     link_with: libgjs_jsapi,
     dependencies: libgjs_dependencies,
-    cpp_pch: 'gjs/gjs_pch.hh',
+    cpp_pch: pch_headers,
     version: '0.0.0', soversion: '0',
     gnu_symbol_visibility: 'hidden',
     install: true)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]