From 162f2e2dba069ad3df7d488136f07536d54b7795 Mon Sep 17 00:00:00 2001 From: wmin0 Date: Tue, 18 Jul 2023 06:29:05 +0800 Subject: [PATCH] scons: Use pkgconfig to get correct Protobuf dependency (#68) Latest protobuf library depends on abseil libraries. We should rely on pkgconfig to give us correct dependency. We still keep the old check as fallback. Change-Id: I529ea1f61e5bbc16b2520ab1badff3d8264f1c33 --- src/proto/SConsopts | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/proto/SConsopts b/src/proto/SConsopts index 6b5b25d0ce..fab29bc235 100644 --- a/src/proto/SConsopts +++ b/src/proto/SConsopts @@ -50,14 +50,6 @@ with gem5_scons.Configure(main) as conf: warning('protoc version', min_protoc_version, 'or newer required.\n' 'Installed version:', protoc_version[1]) else: - # Attempt to determine the appropriate include path and - # library path using pkg-config, that means we also need to - # check for pkg-config. Note that it is possible to use - # protobuf without the involvement of pkg-config. Later on we - # check go a library config check and at that point the test - # will fail if libprotobuf cannot be found. - if conf.env['HAVE_PKG_CONFIG']: - conf.CheckPkgConfig('protobuf', '--cflags', '--libs-only-L') conf.env['HAVE_PROTOC'] = True # If we have the protobuf compiler, also make sure we have the @@ -65,9 +57,11 @@ with gem5_scons.Configure(main) as conf: # automatically added to the LIBS environment variable. After # this, we can use the HAVE_PROTOBUF flag to determine if we have # got both protoc and libprotobuf available. - conf.env['CONF']['HAVE_PROTOBUF'] = conf.env['HAVE_PROTOC'] and \ + conf.env['CONF']['HAVE_PROTOBUF'] = conf.env['HAVE_PROTOC'] and ( + (conf.env['HAVE_PKG_CONFIG'] and + conf.CheckPkgConfig('protobuf', '--cflags', '--libs')) or conf.CheckLibWithHeader('protobuf', 'google/protobuf/message.h', - 'C++', 'GOOGLE_PROTOBUF_VERIFY_VERSION;') + 'C++', 'GOOGLE_PROTOBUF_VERIFY_VERSION;')) # If we have the compiler but not the library, print another warning. if main['HAVE_PROTOC'] and not main['CONF']['HAVE_PROTOBUF']: