[CMake] MSYS2 broken CMAKE_PREFIX_PATH

Mario Emmenlauer mario at emmenlauer.de
Tue Feb 13 09:22:02 EST 2018


On 13.02.2018 01:08, Alan W. Irwin wrote:
> On 2018-02-12 23:06+0100 Mario Emmenlauer wrote:
> 
>> On 12.02.2018 22:09, Alan W. Irwin wrote:
> [...]
>>> I am virtually positive from reading
>>> <https://github.com/msys2/msys2/wiki/MSYS2-introduction> and other
>>> MinGW-w64/MSYS2 documentation that the conversion from POSIX to native
>>> PATHs is done by the MSYS2 dll.  Also, MinGW-w64/MSYS2 applications
>>> from the msys2 repository are linked against that dll while the
>>> applications from the mingw64 repository are pure native, i.e., not
>>> linked against that dll.  Thus, if that mental model is correct, here
>>> are some predictions that flow from it.
>>>
>>> * The cmake version from the msys2 repository will understand cache
>>> variables expressed as POSIX PATHs, but the cmake version from the
>>> mingw64 repository wont have that capability.
>>
>> I am not sure if I follow until here, but very likely I just misunderstand
>> what you are saying. Please help shed some light!
> 
> I will try.  :-)
> 
>> In my observation, I
>> have cmake installed from mingw64 repository, and I can successfully use
>> this cmake with a CMAKE_PREFIX_PATH in POSIX PATH notation
>> find all my dependencies with find_xxx() commands (i.e. find_library() or
>> find_file() or the like). I also use this same cmake with a path to the
>> source directory specified as POSIX PATH.
>>
>> So to be 150% sure we mean the same, the following works for me, where
>> /d/ corresponds to the D: drive of Windows:
>>    /mingw64/bin/cmake /d/tmp/sources \
>>        -DCMAKE_PREFIX_PATH="/d/dest/thirdparty;/d/dest/binaries" && \
>>    make && make install
>>
>> Is that contradictory to your point above?
> 
> It certainly contradicts one of my predictions.
> 
> Just to clarify, the environment variable form of the above command
> would have been (assuming your command-line environment is bash.exe
> from the msys2 repository of MinGW-w64/MSYS2)
> 
> export CMAKE_PREFIX_PATH="/d/dest/thirdparty;/d/dest/binaries"
> /mingw64/bin/cmake /d/tmp/sources && make && make install
> 
> But instead, of using that environment variable form of the
> command you used the
> -DCMAKE_PREFIX_PATH="/d/dest/thirdparty;/d/dest/binaries"
> cmake option which sets CMAKE_PREFIX_PATH as a cache variable.
> 
> And for that cache variable approach, my prediction was the mingw64
> version of cmake would not work with the above POSIX form of
> CMAKE_PREFIX_PATH, but your experience is it does work!  So that
> contradiction to the prediction is indeed an interesting result.
> 
> Just to cover off one possibility, could you try the bash printenv
> command to print out all your bash environment variables to make sure
> you have not inadvertently set the environment variable form of
> CMAKE_PREFIX_PATH?  Of course, if you confirm this way that
> CMAKE_PREFIX_PATH is not set as an environment variable, then it is
> pretty clear something is incorrect/incomplete about the above mental
> model.
I'm 99% certain that this variable is not defined, because I build
from a standard Cygwin shell started from a gitlab runner. But there
might be another piece of evidence that can help us further. When I
build as outlined above (here for reference):

    /mingw64/bin/cmake /d/tmp/sources \
        -DCMAKE_PREFIX_PATH="/d/dest/thirdparty;/d/dest/binaries" && \
    make && make install

then the find_xxx() commands will work, but the cmake package
configurations fail. To get them also to work, I can switch to
Windows path styles:

    /mingw64/bin/cmake /d/tmp/sources \
        -DCMAKE_PREFIX_PATH="D:\\dest\\thirdparty;D:\\dest\\binaries" && \
    make && make install

then *everything* will work. So this should clarify that my POSIX path
was not automatically translated before, otherwise both invocations
would be identical, and the cmake package configurations should still
fail.

PS: Note that the source directory is *still* in POSIX path notation :-)

So its my understanding that cmake does have quite ok support for
POSIX paths on Windows, except for the cmake package configurations.

    Mario Emmenlauer


--
BioDataAnalysis GmbH, Mario Emmenlauer      Tel. Buero: +49-89-74677203
Balanstr. 43                   mailto: memmenlauer * biodataanalysis.de
D-81669 München                          http://www.biodataanalysis.de/


More information about the CMake mailing list