【发布时间】:2015-07-30 11:49:34
【问题描述】:
我正在尝试使用 cmake。假设我的源目录中有一个 HelloWorld.c 文件和一个 CMakeList.txt,其中包含以下内容:
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT( HelloWorld )
ADD_EXECUTABLE( helloworld HelloWorld.c )
当我在此目录中调用 cmake(使用 minGW 生成器)时,一切正常,生成的构建树还包含一个 "Makefile" 。我现在的问题是:这个生成的 makefile 也可以用作通常的手动创建的 makefile。例如,当我在命令 promtp 中键入“make”时,项目应该构建。但我什么也没看到,只有:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
这个输出。这里有什么不明白的地方?
我正在使用 cmake GUI 生成构建树并获得以下输出:
The C compiler identification is GNU 4.8.1
The CXX compiler identification is GNU 4.8.1
Check for working C compiler: C:/MinGW/bin/gcc.exe
Check for working C compiler: C:/MinGW/bin/gcc.exe -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Detecting C compile features
Detecting C compile features - done
Check for working CXX compiler: C:/MinGW/bin/g++.exe
Check for working CXX compiler: C:/MinGW/bin/g++.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
那么,这意味着,在我的构建目录中,所有与 gcc 编译器相关的东西都是正确的吗? 但是,我也无法理解,当我从 HelloWorld.c 和 CMakeList.Txt 所在的源目录运行 cmake 时,我得到了这个输出:
C:\testworkspace\cmake>cmake C:\testworkspace\cmake
-- Building for: Visual Studio 10 2010
-- The C compiler identification is MSVC 16.0.40219.1
-- The CXX compiler identification is MSVC 16.0.40219.1
-- Check for working C compiler using: Visual Studio 10 2010
-- Check for working C compiler using: Visual Studio 10 2010 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working CXX compiler using: Visual Studio 10 2010
-- Check for working CXX compiler using: Visual Studio 10 2010 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Detecting CXX compile features
-- Detecting CXX compile features - failed
-- Configuring done
-- Generating done
-- Build files have been written to: C:/testworkspace/cmake
C:\testworkspace\cmake>
为什么 cmake 采用 Visual Studio 编译器?在 GUI 中配置了 MinGW 编译器!?
【问题讨论】:
-
你在
Makefile所在的同一个文件夹中吗? -
是的,我正在从它的文件夹中运行 make :S
-
你用的是什么编译器?您谈到了 minGW,但您的品牌似乎链接了 microsoft
nmake -
make helloworld怎么样?或者make并按下制表键? -
我正在使用 gcc 编译器。此外,当我查看 CMakeCach.Txt 文件时,gcc 被指定为编译器。但奇怪的是,当我查看生成的 makefile 时,没有任何关于 gcc 编译器的内容.. hmm