-
Notifications
You must be signed in to change notification settings - Fork 3.5k
pkgconfig variables support in CMake toolchain file #17101
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
Conversation
sbc100
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm.
I think maybe we should add a test though, there are a few .pc files that get installed in the sysroot by default:
./cache/sysroot/lib/pkgconfig
├── egl.pc
├── glesv2.pc
└── sdl.pc
See tests/cmake for the current cmake tests.. maybe one of these can be modified/updated.
| cmake_path(CONVERT "${_em_pkgconfig_libdir}" TO_NATIVE_PATH_LIST _em_pkgconfig_libdir) | ||
| endif() | ||
| set(ENV{PKG_CONFIG_LIBDIR} "${_em_pkgconfig_libdir}") | ||
| set(ENV{PKG_CONFIG_PATH} "$ENV{EM_PKG_CONFIG_PATH}") # Stops caller's PKG_CONFIG_PATH from propagating. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should forget about EM_PKG_CONFIG_PATH. I'm not sure why use it ever had.
If somebody explicitly sets PKG_CONFIG_PATH when building an emscripten project I don't see why should ignore it. That seems like a deliberate act.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This behaviour was based on tools.building.get_building_env().
I agree that it seems a bit out of place, but that would introduce inconsistency in how caller's variables are used across tools. If it's acceptable for you then I'm happy to do it.
Or should I update get_building_env? For example: create a backwards-compatible behaviour that prioritises EM_PKG_CONFIG_PATH but also allows for PKG_CONFIG_PATH, and then implement it consistently inget_building_env and here in toolchain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should ignore EM_PKG_CONFIG_PATH in this patch and we should try to remove it from get_building_env as separate change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, removed the line in question.
|
@sbc100, Newly added test seems to work fine after adding pkg-config to Windows and Mac CI environments (as of d439aa8). It checks whether the LIBDIR variable is propagated and set to expected value and if expected packages are visible from CMake's FindPkgConfig (without verifying version to minimise the impact of any upgrades and reduce duplication - I want to add a modversion check for test in #17100). That being said, I see that |
|
|
||
| message(STATUS "PKG_CONFIG_LIBDIR: $ENV{PKG_CONFIG_LIBDIR}") | ||
|
|
||
| find_package(PkgConfig REQUIRED) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this file on machines that don't have pkg-config.
If might be nice to tell the person running the test exactly what is wrong (imagine a windows developer running this test for example).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fails and drops following into stderr:
CMake Error at C:/ProgramData/chocolatey/lib/cmake.portable/tools/cmake-3.23.2-windows-x86_64/share/cmake-3.23/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
Which could be confusing. Let me add a skip branch that checks whether pkg-config is available in the PATH.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer and explict fail.. so that folks know to install it. Something like if not_in_path: self.fail('pkg-config required to run this test'.
If there are folks who are not able to don't want to install it we can consider adding an EMTEST_SKIP_PKK_CONFIG setting that will allow them to skip over it.. but hopefully it won't be needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(otherwise the test silently skips on new installations).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, made it to fail in bfc2f5a. Since I also increased verbosity in the CMake when looking for pkg-config, we could alternatively go with the same approach as test_cmake_with_embind_cpp11_mode has: if WINDOWS and not utils.which('pkg-config'): self.skipTest and on other platforms it would go through this stage and if it wouldn't find pkg-config it would fail due to CMake's non-zero code along with a "Could not find pkg-config executable!" message in stderr.
|
|
||
| find_package(PkgConfig REQUIRED) | ||
|
|
||
| pkg_check_modules(EGL REQUIRED egl) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a comment here: Emscripten ships .pc files for egl/glesv2/sdl. Check that they can all be located correctly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a message explaining what the script is trying to do. I reworded it a bit to not contain the list of packages, so that adding a new package won't require modifying the message on top of everything else. I guess we could just go with a full-pledged list and then iterate, create some nice message and so on, but I feel like that'd be an overkill for a test and I'd rather have it dumb simple.
sbc100
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! (with a couple comments). Thanks for working on this.
|
The code size test failures are unrelated.. its something that needs adjusting periodically if there are change to llvm. I'll submit a fix for that and you will need to rebase/merge. |
Also rename the existing `require_node` and `require_v8` decorators. See #17101
| else() | ||
| cmake_path(CONVERT "${_em_pkgconfig_libdir}" TO_NATIVE_PATH_LIST _em_pkgconfig_libdir) | ||
| endif() | ||
| set(ENV{PKG_CONFIG_LIBDIR} "${_em_pkgconfig_libdir}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should also set PKG_CONFIG_SYSROOT_DIR here? (doesn't have to be part of this change).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest to leave it out for now. We'd want to get consistent behaviour for CMake and building.py and PKG_CONFIG_SYSROOT_DIR can easily become a journey on its own (LIBDIR is good enough for most use cases, and SYSROOT affects only the PATH, not LIBDIR).
Also rename the existing `require_node` and `require_v8` decorators. See #17101
Also rename the existing `require_node` and `require_v8` decorators. See #17101
Also rename the existing `require_node` and `require_v8` decorators. See #17101
Drafted as per discussion in #17096.
I don't have Windows build environment to see how it works there and I'm unsure to what extent this is covered by the tests. Any input is appreciated.