带特殊符号的CMake路径
CMake path with special symbols
我正在使用 CLion,每当我在处理一个项目时,它不能在带有特殊符号的路径中(例如 º、 ç、ã...),失败并显示以下消息:
The C compiler
"C:/Program Files (x86)/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/bin/gcc.exe"
is not able to compile a simple test program.
MinGW 的 make
程序不能顺利处理非 ASCII 字符。我能够使用包含 ñ
:
的路径在我的机器上重现此内容
The C compiler
"C:/apps/MinGW/bin/gcc.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/workspace/peña/build2/CMakeFiles/CMakeTmp
Run Build Command(s):C:/apps/MinGW/bin/mingw32-make.exe cmTC_fe654/fast && C:/apps/MinGW/bin/mingw32-make.exe -f CMakeFiles\cmTC_fe654.dir\build.make CMakeFiles/cmTC_fe654.dir/build
mingw32-make.exe[1]: Entering directory 'C:/workspace/pe±a/build2/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_fe654.dir/testCCompiler.c.obj
C:\apps\MinGW\bin\gcc.exe -o CMakeFiles\cmTC_fe654.dir\testCCompiler.c.obj -c C:\workspace\pe├▒a\build2\CMakeFiles\CMakeTmp\testCCompiler.c
gcc.exe: error: C:\workspace\pe├▒a\build2\CMakeFiles\CMakeTmp\testCCompiler.c: No such file or directory
gcc.exe: fatal error: no input files
compilation terminated.
CMakeFiles\cmTC_fe654.dir\build.make:81: recipe for target 'CMakeFiles/cmTC_fe654.dir/testCCompiler.c.obj' failed
mingw32-make.exe[1]: *** [CMakeFiles/cmTC_fe654.dir/testCCompiler.c.obj] Error 1
mingw32-make.exe[1]: Leaving directory 'C:/workspace/pe±a/build2/CMakeFiles/CMakeTmp'
Makefile:137: recipe for target 'cmTC_fe654/fast' failed
mingw32-make.exe: *** [cmTC_fe654/fast] Error 2
注意,CMake切换到路径正确的临时构建目录,但是在执行mingw32-make.exe
时,路径现在是乱码:
C:/workspace/pe±a/build2/CMakeFiles/CMakeTmp
避免此问题的最简单方法是简单地将您的项目路径更改为不包含非 ASCII 字符的路径。
另一种选择是使用不同的生成器(MinGW Makefiles
以外的生成器)。例如,Visual Studio 可以正确配置和构建,即使非 ASCII 字符位于项目路径中:
> cmake -G"Visual Studio 16 2019" ..
Re-run cmake no build system arguments
C:/workspace/peña
-- The CXX compiler identification is MSVC 19.23.28106.4
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/workspace/peña/build
我正在使用 CLion,每当我在处理一个项目时,它不能在带有特殊符号的路径中(例如 º、 ç、ã...),失败并显示以下消息:
The C compiler
"C:/Program Files (x86)/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/bin/gcc.exe"
is not able to compile a simple test program.
MinGW 的 make
程序不能顺利处理非 ASCII 字符。我能够使用包含 ñ
:
The C compiler
"C:/apps/MinGW/bin/gcc.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/workspace/peña/build2/CMakeFiles/CMakeTmp
Run Build Command(s):C:/apps/MinGW/bin/mingw32-make.exe cmTC_fe654/fast && C:/apps/MinGW/bin/mingw32-make.exe -f CMakeFiles\cmTC_fe654.dir\build.make CMakeFiles/cmTC_fe654.dir/build
mingw32-make.exe[1]: Entering directory 'C:/workspace/pe±a/build2/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_fe654.dir/testCCompiler.c.obj
C:\apps\MinGW\bin\gcc.exe -o CMakeFiles\cmTC_fe654.dir\testCCompiler.c.obj -c C:\workspace\pe├▒a\build2\CMakeFiles\CMakeTmp\testCCompiler.c
gcc.exe: error: C:\workspace\pe├▒a\build2\CMakeFiles\CMakeTmp\testCCompiler.c: No such file or directory
gcc.exe: fatal error: no input files
compilation terminated.
CMakeFiles\cmTC_fe654.dir\build.make:81: recipe for target 'CMakeFiles/cmTC_fe654.dir/testCCompiler.c.obj' failed
mingw32-make.exe[1]: *** [CMakeFiles/cmTC_fe654.dir/testCCompiler.c.obj] Error 1
mingw32-make.exe[1]: Leaving directory 'C:/workspace/pe±a/build2/CMakeFiles/CMakeTmp'
Makefile:137: recipe for target 'cmTC_fe654/fast' failed
mingw32-make.exe: *** [cmTC_fe654/fast] Error 2
注意,CMake切换到路径正确的临时构建目录,但是在执行mingw32-make.exe
时,路径现在是乱码:
C:/workspace/pe±a/build2/CMakeFiles/CMakeTmp
避免此问题的最简单方法是简单地将您的项目路径更改为不包含非 ASCII 字符的路径。
另一种选择是使用不同的生成器(MinGW Makefiles
以外的生成器)。例如,Visual Studio 可以正确配置和构建,即使非 ASCII 字符位于项目路径中:
> cmake -G"Visual Studio 16 2019" ..
Re-run cmake no build system arguments
C:/workspace/peña
-- The CXX compiler identification is MSVC 19.23.28106.4
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/workspace/peña/build