cmake基础教程(11)add_subdirectory如何添加非子目录的CMakeLists.txt
生活随笔
收集整理的這篇文章主要介紹了
cmake基础教程(11)add_subdirectory如何添加非子目录的CMakeLists.txt
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
發現問題
有這樣一種情況。自己寫了一個庫,需要寫測試程序。類似如下結構:
hello-world/ ├── CMakeLists.txt ├── main.c ├── test │ ├── CMakeLists.txt │ └── main.c ├── hello │ ├── CMakeLists.txt │ ├── hello.c │ └── hello.h └── world├── CMakeLists.txt├── world.c└── world.hhello/` 目錄生成 `libhello.so world/` 目錄生成 `libworld.sotest/ 目錄存儲測試程序,測試上述兩個庫功能是否正常。請注意 test/ 與 hello/ 和 world/ 的目錄層級關系。
我們只關注 test/CMakeLists.txt 文件。第一反應,是這么寫:
cmake_minimum_required(VERSION 3.5)pr總結
以上是生活随笔為你收集整理的cmake基础教程(11)add_subdirectory如何添加非子目录的CMakeLists.txt的全部內容,希望文章能夠幫你解決所遇到的問題。