Cmake学习总结(三)
最后架构如下:
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
图片新闻
最新活动更多
-
直播回顾进入直播>> 智能医疗设备测试的挑战
-
4月26日立即报名 >> 【线上研讨会】TDK模块化电容器、电能质量解决方案
-
4月30日免费下载 >> SPM31智能功率模块助力降低供暖和制冷能耗,打造可持续未来!
-
4月30日限时免费下载>> 高动态范围(eHDR)成像设计指南
-
5月10日立即下载>> 【是德科技】精选《汽车 SerDes 发射机测试》白皮书
-
5月22日立即报名>>> OFweek 2024新周期显示技术趋势研讨会
-
8 芯片封装介绍
发表评论
请输入评论内容...
请输入评论/评论长度6~500个字
暂无评论
暂无评论