-
Notifications
You must be signed in to change notification settings - Fork 513
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
cmake: incorrect PKG_CONFIG_EXECUTABLE setting is used #1023
Comments
From cmake docs:
Is there somehow an existing cache entry for |
Ah, yes. I've looked a bit further and in this case the root cause is this snippet in our CMakeLists.txt file:
This leads to cmake checking for the pkg-config executable twice. Right now this results in:
With one of the fixes below the correct thing happens:
Or we don't do the PkgConfig init twice in our software, then it works either way:
So here's the possible fixes: Fix1:
Fix2:
Fix3: Either way, I think the intended behaviour in MXE should be defined and documented. Fix3 is something we should probably fix in our software either way, but OTOH it would also be nice if this worked regardless, i.e. Fix2 might be a nicer solution possibly. Assuming the FORCE there doesn't cause other problems, that is. |
Thanks for the investigation! I'm thinking
happens if |
No, cmake is always run with the same toolchain file. Here's how to reproduce:
The first "include(FindPkgConfig)" seems to do a pkg-config check (as does the second), but for some reason it finds another pkg-config and/or doesn't honor the toolchain file settings. I haven't really looked into that any further. (Put any random *.pc file into ~/sr_mingw/lib/pkgconfig for testing and replace libsigrokcxx accordingly above) |
@ChristianFrisson, do you have any insights on this? Adding |
Please remove
For more info check https://cmake.org/cmake/help/latest/command/find_package.html I actually issued #896 otherwise multiple/first calls to Hoping this will help! |
This causes the check for the pkg-config tool to be performed twice since it is followed by another "find_package(PkgConfig)". This can cause issues in some situation, see e.g. mxe/mxe#1023 (comment) This fixes bug #663.
Oddly, the behaviour seems to change if you put it after the |
* use templates instead of `echo` for readability * ensure `pkg-config` executable is set correctly - closes mxe#1023 - avoids future cases of mxe#1108 (comment) * moves `cmake_policy` to toolchain (closes mxe#971) * use `CACHE ... FORCE` for other variables (BUILD_SHARED_LIBS etc.)
* use templates instead of `echo` for readability * ensure `pkg-config` executable is set correctly - closes mxe#1023 - avoids future cases of mxe#1108 (comment) * moves `cmake_policy` to toolchain (closes mxe#971) * use `CACHE ... FORCE` for other variables (BUILD_SHARED_LIBS etc.)
Now I think that's wrong - #2097 simply errors if |
I was under the impression that an issue we're seeing was the same as #904, but I don't think that is the case anymore. Here's what seems to have been changed and goes wrong.
The setup:
A CMakeLists.txt file for a project is using something like this to find pkg-config-using libraries:
Old (working) mxe.conf had this:
set(PKG_CONFIG_EXECUTABLE /home/uwe/mxe-git/usr/bin/i686-w64-mingw32.static-pkg-config)
New (not working) mxe.conf has this:
And
/home/uwe/mxe-git/usr/i686-w64-mingw32.static/share/cmake/mxe-conf.d/pkgconf.cmake
contains:set(PKG_CONFIG_EXECUTABLE /home/uwe/mxe-git/usr/bin/i686-w64-mingw32.static-pkg-config CACHE PATH "pkg-config executable")
The problem/difference is the "CACHE" here, I think. With the above
PKG_CONFIG_EXECUTABLE
is/usr/bin/pkg-config
before and after theset
line. When dropping theCACHE PATH "pkg-config executable"
part, thePKG_CONFIG_EXECUTABLE
after theset
line is now correct again:Using the correct
PKG_CONFIG_EXECUTABLE
the host cmake now finds the packages correctly again.Please double-check if performing this change makes sense for MXE and all its requirements, I only checked one very specific use-case here.
The text was updated successfully, but these errors were encountered: