我刚开始使用C ++,并且想使用CMake来编译一个简单的hello world程序,但是一旦生成MakeFile,我不知道该怎么办。我有一个名为tutorial的目录,其中包含我的tutorial.cpp文件,其中包含hello世界代码。我也有一个CMakeLists文件,其中包含:
cmake_minimum_required(VERSION 3.14.4)
project (tutorial)
add_executable(tutorial tutorial.cpp)
当我从终端的教程目录中运行命令cmake .
时,将生成所有正确的文件(至少我认为它们是正确的),并且得到以下输出:
-- The C compiler identification is AppleClang 10.0.1.10010046
-- The CXX compiler identification is AppleClang 10.0.1.10010046
-- Check for working C compiler:
/Library/Developer/CommandLineTools/usr/bin/cc
-- Check for working C compiler:
/Library/Developer/CommandLineTools/usr/bin/cc -- 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:
/Library/Developer/CommandLineTools/usr/bin/c++
-- Check for working CXX compiler:
/Library/Developer/CommandLineTools/usr/bin/c++ -- 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:
/Users/kshitijsachan/Documents/cs/cpp/tutorial
然后我在终端中输入make
,但没有任何输出。我实际上如何运行生成的Makefile?
答案 0 :(得分:0)
运行make <some_valid_target_name>
-像make all
或make install
(如果存在此类常用目标)或您的项目定义的任何其他目标。检查您的项目文档或CMakeLists.txt文件以获取有效的目标名称。
另请参见cmake_add_executable,它添加了一个目标。