侵权投诉
订阅
纠错
加入自媒体

Cmake学习总结(三)

2020-07-13 09:13
TXP嵌入式
关注

最后架构如下:

root@txp-virtual-machine:/home/txp/testmy# tree

├── bin

├── build

├── CMakeLists.txt

├── include

│   ├── test1.h

│   └── test2.h

└── src

├── CMakeLists.txt

├── main.c

├── test1.c

└── test2.c

2、编译运行:

root@txp-virtual-machine:/home/txp/testmy# cd build

root@txp-virtual-machine:/home/txp/testmy/build# ls

root@txp-virtual-machine:/home/txp/testmy/build# cmake ..

-- The C compiler identification is GNU 4.8.4

-- The CXX compiler identification is GNU 4.8.4

-- 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

-- Check for working CXX compiler: /usr/bin/c++

-- Check for 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 written to: /home/txp/testmy/build

root@txp-virtual-machine:/home/txp/testmy/build# make

Scanning dependencies of target main

[ 33%] Building C object src/CMakeFiles/main.dir/test2.c.o

[ 66%] Building C object src/CMakeFiles/main.dir/test1.c.o

[100%] Building C object src/CMakeFiles/main.dir/main.c.o

Linking C executable ../../bin/main

[100%] Built target main

root@txp-virtual-machine:/home/txp/testmy/build# cd ../bin

root@txp-virtual-machine:/home/txp/testmy/bin# ls

main

注意这里是切换到build目录下去执行cmake哈。 这里为啥这样做呢,我们课可以看到在build目录下执行cmake .. 和make命令后,生成的一些配置文件都会在这个目录下,不会在别的目录下,就这样看起来就舒服整洁多了:

root@txp-virtual-machine:/home/txp/testmy/build# ls

CMakeCache.txt  CMakeFiles  cmake_install.cmake  Makefile  src

现在整个架构如下:

root@txp-virtual-machine:/home/txp/testmy# tree

├── bin

│   └── main

├── build

│   ├── CMakeCache.txt

│   ├── CMakeFiles

│   │   ├── 2.8.12.2

│   │   │   ├── CMakeCCompiler.cmake

│   │   │   ├── CMakeCXXCompiler.cmake

│   │   │   ├── CMakeDetermineCompilerABI_C.bin

│   │   │   ├── CMakeDetermineCompilerABI_CXX.bin

│   │   │   ├── CMakeSystem.cmake

│   │   │   ├── CompilerIdC

│   │   │   │   ├── a.out

│   │   │   │   └── CMakeCCompilerId.c

│   │   │   └── CompilerIdCXX

│   │   │       ├── a.out

│   │   │       └── CMakeCXXCompilerId.cpp

│   │   ├── cmake.check_cache

│   │   ├── CMakeDirectoryInformation.cmake

│   │   ├── CMakeOutput.log

│   │   ├── CMakeTmp

│   │   ├── Makefile2

│   │   ├── Makefile.cmake

│   │   ├── progress.marks

│   │   └── TargetDirectories.txt

│   ├── cmake_install.cmake

│   ├── Makefile

│   └── src

│       ├── CMakeFiles

│       │   ├── CMakeDirectoryInformation.cmake

│       │   ├── main.dir

│       │   │   ├── build.make

│       │   │   ├── C.includecache

│       │   │   ├── cmake_clean.cmake

│       │   │   ├── DependInfo.cmake

│       │   │   ├── depend.internal

│       │   │   ├── depend.make

│       │   │   ├── flags.make

│       │   │   ├── link.txt

│       │   │   ├── main.c.o

│       │   │   ├── progress.make

│       │   │   ├── test1.c.o

│       │   │   └── test2.c.o

│       │   └── progress.marks

│       ├── cmake_install.cmake

│       └── Makefile

├── CMakeLists.txt

├── include

│   ├── test1.h

│   └── test2.h

└── src

├── CMakeLists.txt

├── main.c

├── test1.c

└── test2.c

<上一页  1  2  3  4  下一页>  
声明: 本文由入驻维科号的作者撰写,观点仅代表作者本人,不代表OFweek立场。如有侵权或其他问题,请联系举报。

发表评论

0条评论,0人参与

请输入评论内容...

请输入评论/评论长度6~500个字

您提交的评论过于频繁,请输入验证码继续

暂无评论

暂无评论

电子工程 猎头职位 更多
扫码关注公众号
OFweek电子工程网
获取更多精彩内容
文章纠错
x
*文字标题:
*纠错内容:
联系邮箱:
*验 证 码:

粤公网安备 44030502002758号