微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

cmake:指定编译器的问题

我有这个CMakeLists.txt文件的问题:

cmake_minimum_required(VERSION 2.6) SET(CMAKE_C_COMPILER C:\MinGW\bin\gcc) SET(CMAKE_CXX_COMPILER C:\MinGW\bin\g++) project(cmake_test) add_executable(a.exe test.cpp)

调用cmake: cmake -G "MinGW Makefiles"

我得到:

c:cmake_test>cmake -G "MinGW Makefiles" . -- The C compiler identification is GNU 4.6.1 CMake Warning (dev) at CMakeFiles/CMakeCCompiler.cmake:1 (SET): Syntax error in cmake code at C:/cmake_test/CMakeFiles/CMakeCCompiler.cmake:1 when parsing string C:MinGWbingcc Invalid escape sequence M Policy CMP0010 is not set: Bad variable reference Syntax is an error. Run "cmake --help-policy CMP0010" for policy details. Use the cmake_policy command to set the policy and suppress this warning. Call Stack (most recent call first): CMakeLists.txt:12 (project) This warning is for project developers. Use -Wno-dev to suppress it. -- The CXX compiler identification is GNU 4.6.1 CMake Warning (dev) at CMakeFiles/CMakeCXXCompiler.cmake:1 (SET): Syntax error in cmake code at C:/cmake_test/CMakeFiles/CMakeCXXCompiler.cmake:1 when parsing string C:MinGWbing++ Invalid escape sequence M Policy CMP0010 is not set: Bad variable reference Syntax is an error. Run "cmake --help-policy CMP0010" for policy details. Use the cmake_policy command to set the policy and suppress this warning. Call Stack (most recent call first): CMakeLists.txt:12 (project) This warning is for project developers. Use -Wno-dev to suppress it. -- Check for working C compiler: C:MinGWbingcc CMake Error at C:/cmake_test/CMakeFiles/CMakeCCompiler.cmake:1 (SET): Syntax error in cmake code at C:/cmake_test/CMakeFiles/CMakeCCompiler.cmake:1 when parsing string C:MinGWbingcc Invalid escape sequence M Call Stack (most recent call first): CMakeLists.txt:2 (PROJECT) CMake Error: CMAKE_C_COMPILER not set,after EnableLanguage CMake Error: Internal CMake error,TryCompile configure of cmake Failed CMake Error: your C compiler: "C:MinGWbingcc" was not found. Please set CMAKE_C_COMPILER to a valid compiler path or name. CMake Error: your CXX compiler: "C:MinGWbing++" was not found. Please set CMAKE_CXX_COMPILER to a valid compiler path or name. -- Configuring incomplete,errors occurred!

我也试过:

编译Windows的静态TagLib 1.6.3库

如何让CMake在生成visual studio解决scheme后执行一些脚本

CMake:无论如何强制链接库?

如何在Windows上使用MinGW构buildOpenCV 3.2.0

CMake内部错误(TEST_BIG_ENDIAN)

C:MinGWbing++ /C/MinGW/bin/g++

结果相同。 双引号也没有帮助,要么。

当然,编译器存在于指定的目录中。

谢谢你的提示

CMake:如何禁用单个* .cpp文件的优化?

使用Cmake运行CppuTests

使用cmakebuild立错误:找不到-lpthreads

cmake找不到java,但是已经安装了

如何使用CMake为多重configuration生成器和基于生成文件的目标文件获取path?

您必须使用四个反斜杠才能在SET获得文字反斜杠:

SET(CMAKE_C_COMPILER C:\\MinGW\\bin\\gcc) SET(CMAKE_CXX_COMPILER C:\\MinGW\\bin\\g++)

无论您是否在引用中使用引号,这都适用。

由于这很丑陋,所以最好使用正斜杠:

SET(CMAKE_C_COMPILER C:/MinGW/bin/gcc) SET(CMAKE_CXX_COMPILER C:/MinGW/bin/g++)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐