简体   繁体   English

如何使CMake find_file在MSYS2上接受UNIX样式的路径?

[英]How to get CMake find_file to accept UNIX-style paths on MSYS2?

I'm using CMake 3.4.1, on Windows 10, with MSYS2 (everything up-to-date as of Dec. 25 2015). 我在Windows 10和MSYS2上使用CMake 3.4.1(截至2015年12月25日的所有最新信息)。

When I use CMake's find_file command, it won't work unless the path is in Windows-style. 当我使用CMake的find_file命令时,除非路径为Windows风格,否则它将无法工作。 This is a problem for me, because I'm trying to use findwxWidgets.cmake , which fails because of this. 这对我来说是个问题,因为我正在尝试使用findwxWidgets.cmake ,因此失败了。

For example: 例如:

CMakeLists.txt: CMakeLists.txt:

cmake_minimum_required(VERSION 3.0)
find_file(version_h version.h PATHS /mingw64/include/wx-3.0/wx)
message(STATUS "version_h: ${version_h}")

Running cmake spits out: 运行cmake吐出:

-- version_h: version_h-NOTFOUND

But it's clearly in there: 但这显然在那里:

>>> file /mingw64/include/wx-3.0/wx/version.h
/mingw64/include/wx-3.0/wx/version.h: C source, ASCII text

I'm wondering if this is a bug, or if there's some obscure flag I have to set to get this to work. 我想知道这是否是错误,或者是否必须设置一些晦涩的标记才能使其正常工作。 How do I get CMake's find_file to find files with UNIX-style paths? 如何获取CMake的find_file来查找具有UNIX样式路径的文件?

MinGW-w64 cmake can't understand MSYS2 paths. MinGW-w64 cmake无法理解MSYS2路径。 You might propose a path transformation test program to the CMake developers, but that's fairly gross and I'd hope the would reject that. 您可能会向CMake开发人员提出一个路径转换测试程序,但这相当繁琐,我希望它会拒绝。 Instead these things must be solved case-by-case. 相反,必须逐案解决这些问题。 wx-config, being a shell script, is providing an MSYS2 path. wx-config是一个shell脚本,它提供了MSYS2路径。

This is a bug in the currently release MSYS2 wxWidgets packages that will be fixed in the next release. 这是当前发行的MSYS2 wxWidgets软件包中的错误,它将在下一版本中修复。 To work around it, find the line in /mingw64/bin/wx-config or /mingw32/bin/wx-config: 要解决此问题,请在/ mingw64 / bin / wx-config或/ mingw32 / bin / wx-config中找到以下行:

prefix=${input_option_prefix-${this_prefix:-/mingw64}}

(or /mingw32 of course) and add after it: (或/ mingw32),然后添加:

if [ "x${MSYSTEM}" = "xMINGW32" ] || [ "x${MSYSTEM}" = "xMINGW64" ]; then
    prefix=$(cygpath -m ${prefix})
fi

Be careful to remove it at upgrade time though. 但是请注意在升级时将其删除。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM