diff options
author | Guy Harris <gharris@sonic.net> | 2022-07-12 01:22:14 -0700 |
---|---|---|
committer | Guy Harris <gharris@sonic.net> | 2022-07-12 01:22:14 -0700 |
commit | 0e0dceba0c29e6ef777d2f5302bab2a01d835ab8 (patch) | |
tree | 3754eeec6c4c0dcb2b79972cb8c7393a7db74ee1 /CMakeLists.txt | |
parent | 914e40f62f3382256cc27d5e171661f92f840f81 (diff) |
On Solaris, tweak PKG_CONFIG_PATH as necessary for the build bitwidth.
For 32-bit builds, make sure that, if /usr/lib/amd64/pkgconfig is in the
path, we put /usr/lib/pkgconfig before it, so that we find the .pc files
for 32-bit versions of packages.
For 64-bit builds, make sure that, if /usr/lib/pkgconfig is in the path,
we put /usr/lib/amd64/pkgconfig before it and, if it's not in the path,
we have /usr/lib/amd64/pkgconfig at the end of the path, so that we find
the .pc files for 64-bit versions of packages.
The dbus package makes this necessary.
This should fix issue #1112.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index b6babc1c..982a0d0a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,6 +100,67 @@ This prevents code in these languages from being combined.") endif() endif() +# +# Solaris pkg-config is annoying. For at least one package (D-Bus, I'm +# looking at *you*!), there are separate include files for 32-bit and +# 64-bit builds (I guess using "unsigned long long" as a 64-bit integer +# type on a 64-bit build is like crossing the beams or soething), and +# there are two separate .pc files, so if we're doing a 32-bit build we +# should make sure we look in /usr/lib/pkgconfig for .pc files and if +# we're doing a 64-bit build we should make sure we look in +# /usr/lib/amd64/pkgconfig for .pc files. +# +if(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_VERSION MATCHES "5[.][0-9.]*") + # + # Note: string(REPLACE) does not appear to support using ENV{...} + # as an argument, so we set a variable and then use set() to set + # the environment variable. + # + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + # + # 64-bit build. If /usr/lib/pkgconfig appears in the path, + # prepend /usr/lib/amd64/pkgconfig to it; otherwise, + # put /usr/lib/amd64 at the end. + # + if((NOT DEFINED ENV{PKG_CONFIG_PATH}) OR "$ENV{PKG_CONFIG_PATH}" EQUAL "") + # + # Not set, or empty. Set it to /usr/lib/amd64/pkgconfig. + # + set(fixed_path "/usr/lib/amd64/pkgconfig") + elseif("$ENV{PKG_CONFIG_PATH}" MATCHES "/usr/lib/pkgconfig") + # + # It contains /usr/lib/pkgconfig. Prepend + # /usr/lib/amd64/pkgconfig to /usr/lib/pkgconfig. + # + string(REPLACE "/usr/lib/pkgconfig" + "/usr/lib/amd64/pkgconfig:/usr/lib/pkgconfig" + fixed_path "$ENV{PKG_CONFIG_PATH}") + else() + # + # Not empty, but doesn't contain /usr/lib/pkgconfig. + # Append /usr/lib/amd64/pkgconfig to it. + # + set(fixed_path "$ENV{PKG_CONFIG_PATH}:/usr/lib/amd64/pkgconfig") + endif() + set(ENV{PKG_CONFIG_PATH} "${fixed_path}") + elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) + # + # 32-bit build. If /usr/amd64/lib/pkgconfig appears in the path, + # prepend /usr/lib/pkgconfig to it. + # + if("$ENV{PKG_CONFIG_PATH}" MATCHES "/usr/lib/amd64/pkgconfig") + # + # It contains /usr/lib/amd64/pkgconfig. Prepend + # /usr/lib/pkgconfig to /usr/lib/amd64/pkgconfig. + # + string(REPLACE "/usr/lib/amd64/pkgconfig" + "/usr/lib/pkgconfig:/usr/lib/amd64/pkgconfig" + fixed_path "$ENV{PKG_CONFIG_PATH}") + set(ENV{PKG_CONFIG_PATH} "${fixed_path}") + endif() + endif() +endif() + include(CheckCCompilerFlag) # |