您好,欢迎来到尔游网。
搜索
您的当前位置:首页cmake入门1之hello world

cmake入门1之hello world

来源:尔游网


环境

ubuntu18

cmake version 3.17.3

准备文件

新建一个文件夹demo1,新建两个文件:CMakeLists.txt、helloworld.c

parallels@Lincoln:~/workspace/cmakedemo/demo1$ pwd
/home/parallels/workspace/cmakedemo/demo1
parallels@Lincoln:~/workspace/cmakedemo/demo1$ tree
.
├── CMakeLists.txt
└── helloworld.c

helloworld.c文件源码如下:

#include <stdio.h>

int main() {
    printf("hello world\n");
    return 0;
}

CMakeLists.txt:cmake的配置文件

#设置cmake的最小版本要求
cmake_minimum_required(VERSION 3.10)
#设置工程名字为 ylk_hello
project(ylk_hello)
#使用helloworld.c生成可执行程序hello
add_executable(hello helloworld.c)

使用cmake

1、生成配置

parallels@Lincoln:~/workspace/cmakedemo/demo1$ cmake .
-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /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 co

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- axer.cn 版权所有 湘ICP备2023022495号-12

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务