CMake 实例学习(一) 开始
来源:互联网 发布:c语言学生综合测评系统 编辑:程序博客网 时间:2024/06/16 22:52
转载 http://blog.chinaunix.net/uid-25696269-id-603825.html
如有版权问题,请联系QQ: 858668791
1:CMake概述
说简单点,CMake 就是为我们生成 makefile 文件的,你是否在为撰写makefile而头疼呢,那就试试CMake吧,我也是一边学习,一边做一些笔记,难免会有一些理解错误的地方,还望各位看客及时指出,Thanks.
2:从“Hello world”开始
- [onezeroone@ ex-1]$ pwd
- /home/onezeroone/work/backup/cmake/ex-1
- [onezeroone@ ex-1]$ ls
- hello.c
- #include <stdio.h>
- int
- main(void)
- {
- printf("Hello world\n");
- return 0;
- }
- [onezeroone@ ex-1]$ ls
- CMakeLists.txt hello.c
- [onezeroone@ ex-1]$ cat CMakeLists.txt
- PROJECT(HELLO)
- ADD_EXECUTABLE(hello hello.c)
PROJECT语法:
PROJECT(projectname [CXX] [C] [JAVA])
用于指定工程名字,[]为可选内容,默认表示支持所有语言。
ADD_EXECUTABLE(hello hello.c)
定义工程生产的可执行文件名为hello, 源文件为hello.c
4:执行cmake .
- [onezeroone@ ex-1]$ cmake.
- -- The C compiler identificationis GNU
- -- The CXX compiler identificationis GNU
- -- Checkfor working C compiler:/usr/bin/gcc
- -- Checkfor working C compiler:/usr/bin/gcc-- works
- -- Detecting C compiler ABI info
- -- Detecting C compiler ABI info- done
- -- Checkfor working CXX compiler:/usr/bin/c++
- -- Checkfor working CXX compiler:/usr/bin/c++-- works
- -- Detecting CXX compiler ABI info
- -- Detecting CXX compiler ABI info- done
- -- Configuring done
- -- Generating done
- -- Build files have been writtento:/home/onezeroone/work/backup/cmake/ex-1
- [onezeroone@ ex-1]$ ls
- CMakeCache.txt CMakeFiles cmake_install.cmake CMakeLists.txt hello.c Makefile
5.make
- [onezeroone@ ex-1]$ make
- Scanning dependencies of target hello
- [100%] Building C object CMakeFiles/hello.dir/hello.c.o
- Linking C executable hello
- [100%] Built target hello
- [onezeroone@ ex-1]$ ls
- CMakeCache.txt CMakeFiles cmake_install.cmake CMakeLists.txt hello hello.c Makefile
- [onezeroone@ ex-1]$./hello
- Hello world
0 0
- CMake 实例学习(一) 开始
- cmake学习实例
- cmake 学习笔记(一)
- cmake 学习笔记(一)
- cmake 学习笔记(一)
- cmake 学习笔记(一)
- cmake 学习笔记(一)
- cmake 学习笔记(一)
- cmake 学习笔记(一)
- cmake 学习笔记(一)
- cmake 学习笔记(一)
- cmake 学习笔记(一)
- cmake 学习笔记(一)
- Cmake学习(一)
- cmake 学习笔记(一)
- cmake 学习笔记(一)
- cmake 学习笔记(一)
- cmake 学习笔记(一)
- 43arew352asr436346
- Android优化——UI优化(二)
- 5sr43rsd43
- 43aewf4gs54
- 5sg4sdf32
- CMake 实例学习(一) 开始
- 弹幕小demo
- 462dsaf345454
- 2343
- Eclipse: install new software could not find jar file
- 基于HOOK的Anti-debug调用点trace和Anti-anti
- 不同服务器之间配置NFS
- 正则匹配中文以及一些常用正则表达式
- ip 穿透