Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow using custom mir libraries directory #198

Merged
merged 5 commits into from
Aug 9, 2024

Conversation

TibboddiT
Copy link
Contributor

@TibboddiT TibboddiT commented Aug 2, 2024

Allow invoking cmake with -DMIR_LIBRARIES_PKGCONFIG_DIRECTORY=<dir> to search Mir pc files in a custom directory.
If -DMIR_LIBRARIES_PKGCONFIG_DIRECTORY is not set, behavior remains unchanged.

Note: to successfully build locally, linking to libmirwayland.so was neeeded, so I added it to target_link_libraries.

Building on Debian with a local build of the Mir main branch works now without modifying miracle-wm sources.

Fix #196.

Copy link
Collaborator

@mattkae mattkae left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this! I have a few questions about the implementation, but it looks like the right idea

@@ -24,6 +29,7 @@ pkg_check_modules(MIRCOMMON mircommon REQUIRED)
pkg_check_modules(MIRCOMMON_INTERNAL mircommon-internal REQUIRED)
pkg_check_modules(MIRSERVER mirserver REQUIRED)
pkg_check_modules(MIRSERVER_INTERNAL mirserver-internal REQUIRED)
pkg_check_modules(MIRWAYLAND mirwayland REQUIRED)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would Mirwayland be required here? I don't remember using it in the project anywhere

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's only required at link time, otherwise building fails with

/usr/bin/ld: warning: libmirwayland.so.5, needed by <mir_install_directory>/lib/libmirplatform.so, not found (try using -rpath or -rpath-link)

and a bunch of undefined symbols.

Maybe mirplatform should require mirwayland in its pc file ? Currently it's just:

prefix=<mir_install_directory>
libdir=${prefix}/lib
includedir=${prefix}/include

Name: mirplatform
Description: Mir platform library
Version: 2.18.0
Requires: mircommon, mircore
Libs: -L${libdir} -lmirplatform
Cflags: -I${includedir}/mirplatform

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay that's probably an issue on their end, but I am happy to patch it on our end in the meantime.

Filed the bug: canonical/mir#3536

CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
Copy link
Collaborator

@mattkae mattkae left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this :) Just letting CI do its thing then I'll merge

@mattkae
Copy link
Collaborator

mattkae commented Aug 8, 2024

@TibboddiT One last thing to make this work:

We're going to need to install the libmirwayland-dev and package in CI: https://github.com/mattkae/miracle-wm/blob/ea33fb1c7212a8a3b9633e0b9fd909aab186028c/.github/workflows/cmake.yml#L33

@TibboddiT
Copy link
Contributor Author

Done. snap/snapcraft.yaml was also updated with libmirwayland-dev.

@TibboddiT TibboddiT requested a review from mattkae August 9, 2024 08:55
Copy link
Collaborator

@mattkae mattkae left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@mattkae mattkae merged commit ea8c9db into miracle-wm-org:develop Aug 9, 2024
3 checks passed
@TibboddiT TibboddiT deleted the custom-mir-libs branch August 11, 2024 11:11
option(SNAP_BUILD "Building as a snap?" OFF)

set(ENV{PKG_CONFIG_PATH} "${MIR_LIBRARIES_PKGCONFIG_DIRECTORY}:/usr/local/lib/pkgconfig/")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks any existing PKG_CONFIG_PATH setup.

$ echo $PKG_CONFIG_PATH
/nix/store/b3a0wh9v9md9kc4qdixsbwjy3799077r-boost-1.81.0-dev/lib/pkgconfig:/nix/store/sa2vr5rkh19pvy9j4hkb4lk95nlhqpix-glib-2.80.4-dev/lib/pkgconfig:/nix/store/vsygj2vzwqr9x7rzq4v3prcv2blkggmx-zlib-1.3.1-dev/lib/pkgconfig:/nix/store/niabvl1jq1hl7s3n1yx5zxa27l9mipkm-libffi-3.4.6-dev/lib/pkgconfig:[...]
$ $PKG_CONFIG --cflags miral
-I/nix/store/457888a9j750b2skjvi33h4xn66y05gi-mir-2.17.0-dev/include/miral -I/nix/store/457888a9j750b2skjvi33h4xn66y05gi-mir-2.17.0-dev/include/mircommon -I/nix/store/457888a9j750b2skjvi33h4xn66y05gi-mir-2.17.0-dev/include/mircore
/build/source/CMakeLists.txt(15):  set(MIR_LIBRARIES_PKGCONFIG_DIRECTORY  CACHE STRING Search for Mir libraries pc files in this directory )
/build/source/CMakeLists.txt(16):  option(SNAP_BUILD Building as a snap? OFF )
/build/source/CMakeLists.txt(18):  set(ENV{PKG_CONFIG_PATH} :/var/empty/local/lib/pkgconfig/ )
[...]
/nix/store/sa1yjb7xxrzcbd1bysj3r561vidfxxvb-cmake-3.29.6/share/cmake-3.29/Modules/FindPkgConfig.cmake(435):  set(ENV{PKG_CONFIG_PATH} /var/empty/local/lib/pkgconfig )
[...]
-- Checking for module 'miral'
--   No package 'miral' found

Copy link
Contributor

@OPNA2608 OPNA2608 Aug 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry. The pre-existing code already broke it, and I see this was supposed to close the issue for this: #196

Why is setting PKG_CONFIG_PATH=/usr/local/lib/pkgconfig and further messing around with it in CMake even necessary, is something wrong with some build environment somewhere? I feel like this setup should just be left to whatever build environment CMake is executed in, prepending a custom Mir path as desired.

Submitted #211 to instead use the existing ENV{PKG_CONFIG_PATH}, or set /usr/local/lib/pkgconfig as a fallback if it's empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow custom PKG_CONFIG_PATH
3 participants