[CMake] NO_SYSTEM_ENVIRONMENT_PATH globally?

Ray Donnelly mingw.android at gmail.com
Sun Dec 13 20:06:15 EST 2015


Hi,

I ran into a problem on MSYS2 recently building llvm+clang for
mingw-w64 using CMake 3.4.1 (we carry a few local patches, they're
fairly minor, except the qt5-static one, and I don't think they are
likely related to this:
https://github.com/Alexpux/MINGW-packages/tree/master/mingw-w64-cmake)

MSYS2 has two shells .. actually it's 3 or 4, but for simplicity we'll
ignore the 32-bit ones and pretend there's only 2 64-bit shells, one
launched with msys2_shell.bat and one launched with mingw64_shell.bat.
Under msys2_shell.bat, the "/mingw64/bin" folder doesn't appear at all
in PATH, while under mingw64_shell.bat, it appears at the very front,
before "/usr/bin" (which contains the msys2 software).

When running CMake to configure the build for libclang, it tries to
see if if can find libdl with "find_library (DL_LIBRARY_PATH dl)".
Unfortunately it finds the msys-2.0.dll-linked libdl.a in /usr/lib
because NO_SYSTEM_ENVIRONMENT_PATH isn't set, which isn't then in
/mingw64/bin/g++.exe's linker search path (and even if it was, we
don't want to link msys-2.0.dll software into native software!).

I wondered what the recommended approach is for handling this
scenario? Clearly we need msys2 software to be in our PATH (ls, bash,
etc, etc), but it seems CMake is keen to look in a lot of places to
find libraries (AFAICT, it takes each element in PATH and appends
../lib to it then looks in there with the usual prefix/suffix rules)
..

>From our perspective, as MSYS2 is a distro employing a prefix, we'd be
happy for only that to be searched in for libraries. Is there
something that can accommodate for this already? Clearly, patching
each occurrence of find_library isn't something I can entertain, so
I'd like to make a change to how CMake itself behaves somehow. If you
can guide me on an acceptable way to achieve this I'd like to try to
come up with a patch.

--
Best regards,

Ray Donnelly.


More information about the CMake mailing list