首页 > 其他 > 详细

cmake语法学习 - 02 Sub-projects

时间:2020-04-26 12:07:18      阅读:54      评论:0      收藏:0      [点我收藏+]

Before diving into the code, here is the folders structure.

├── CMakeLists.txt [ Top most ]
├── subbinary
│   ├── CMakeLists.txt [ subbinary ]
│   └── main.cpp
├── sublibrary1
│   ├── CMakeLists.txtsublibrary1 ]
│   ├── include
│   │   └── sublib1
│   │   └── sublib1.h
│   └── src
│   └── sublib1.cpp
└── sublibrary2
├── CMakeLists.txtsublibrary2 ]
└── include
└── sublib2
└── sublib2.h

 

*

CMakeLists.txt [ subbinary ]

To generate an execuatable. we have discussed before.

 

*

CMakeLists.txtsublibrary1 ]

To generate an library. we have discussed before.

 

*

CMakeLists.txtsublibrary2 ]

To generate an library. we have discussed before.

 

├── CMakeLists.txt [ Top most ]

cmake_minimum_required (VERSION 3.5)

project(subprojects)

# Add sub directories
add_subdirectory(sublibrary1)
add_subdirectory(sublibrary2)
add_subdirectory(subbinary)

 

*

add_subdirectory(sublibrary1)

- sublibrary1 is the folder name. Even though we have a folder named "sublibrary1" here, there are totally 2 different things.

- Question 1 :  Where to create the folder?

Answer 1 : Most of us will "mkdir build", "cd build" and "cmake ..", so the absolute folder path will be "......./build/sublibrary1" .

- Question 2 :What will the function do?

Answer 2 : As far as I know,

------------- 1 Create a sub-folder in building folder;

------------- 2 Link the CMakelist.txt in "sublibrary1"; So you can not pass a arbitrary folder name here.

 

 

That is all.

 

cmake语法学习 - 02 Sub-projects

原文:https://www.cnblogs.com/alexYuin/p/12778536.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!