【发布时间】:2012-10-14 19:15:08
【问题描述】:
我对这个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 -G "MinGW Makefiles" 调用 cmake,失败并显示以下输出:
c:\Users\pietro.mele\projects\tests\buildSystem_test\cmake_test>cmake -G "MinGW Makefiles" .
-- The C compiler identification is GNU 4.6.1
-- The CXX compiler identification is GNU 4.6.1
-- Check for working C compiler: C:/MinGW/bin/gcc
CMake Error: your C compiler: "C:/MinGW/bin/gcc" was not found. Please set CMAKE_C_COMPILER to a valid compiler path or name.
CMake Error: Internal CMake error, TryCompile configure of cmake failed
-- Check for working C compiler: C:/MinGW/bin/gcc -- broken
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:52 (MESSAGE):
The C compiler "C:/MinGW/bin/gcc" is not able to compile a simple test
program.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:10 (project)
CMake Error: your C compiler: "C:/MinGW/bin/gcc" was not found. Please set CMAKE_C_COMPILER to a valid compiler path or name.
CMake Error: your CXX compiler: "C:/MinGW/bin/g++" was not found. Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
-- Configuring incomplete, errors occurred!
但是gcc 编译器在C:/MinGW/bin/ 中并且可以工作。
有什么想法吗?
平台:
- Windows 7
- MinGW/GCC 4.6
【问题讨论】:
-
我好久没接触Windows了,但是操作系统通常说
C:\MinGW\bin\g++而不是你指定的,这是否困扰cmake? -
不,它不会打扰 CMake。无论操作系统如何,CMake 都使用“/”作为分隔符。在 Windows 上,我们会在必要时翻译为“\”。
-
顺便说一句,因为这里的错误信息是“找不到”——也许你需要在文件名的末尾添加“.exe”?