实现类似于vs中工程的CMakeLists.txt的编写。功能为main.cpp调用hello.cpp 的hello()函数,world.cpp的world()函数。使用自动添加多目录下的文件。

1.工程目录如下

2.主函数main.cpp

#include

#include "hello.h"

#include "world.h"

int main()

{

hello();

world();

return 0;

}

3.顶层CMakeLists.txt

cmake_minimum_required(VERSION 2.8)

project(helloworld)

# Add the source in project root directory

aux_source_directory(. DIRSRCS)

# Add header file include directories

include_directories(./ ./hello ./world)

# Add block directories

add_subdirectory(hello)

add_subdirectory(world)

# Target

add_executable(helloworld ${DIRSRCS})

target_link_libraries(helloworld hello world)

4.hello文件夹

CMakeLists.txt

aux_source_directory(. DIR_HELLO_SRCS)

add_library(hello ${DIR_HELLO_SRCS})12

hello.cpp

#include "hello.h"

void hello()

{

printf("hello\n");

}

hello.h

#ifndef HELLO_H

#define HELLO_H

#include

void hello();

#endif12345

5.world文件夹

CMakeLists.txt

aux_source_directory(. DIR_WORLD_SRCS)

add_library(world ${DIR_WORLD_SRCS})12

world.cpp

#include "world.h"

void world()

{

printf("world\n");

}

world.h

#ifndef WORLD_H

#define WORLD_H

#include

void world();

#endif

cmake linux模板 多目录_多目录工程的CmakeLists.txt编写(自动添加多目录下的文件)...相关推荐

  1. 多目录cmake工程 CmakeLists.txt编写

    实现类似于vs中工程的CMakeLists.txt的编写.功能为main.cpp调用hello.cpp 的hello()函数,world.cpp的world()函数.使用自动添加多目录下的文件 1.工 ...

  2. 网页打开共享目录_“馆员说事儿”之三大中文数据库期刊封面、目录、封底下载方法步骤(三)中国知网...

    三大中文数据库期刊封面.目录.封底下载方法步骤 -中国知网 三.中国知网 中国知网提供了各期刊封面.目录.封底的浏览及打印. 中国知网(CNKI)提供的封面.目录和封底信息,最早可到2008年,同样也 ...

  3. 解决CMake Error: The source directory “*“ does not appear to contain CMakeLists.txt.

    一.问题: 安装opencv 遇到这样的问题,本人安装参考的文献为: https://blog.csdn.net/u013066730/article/details/79411767 安装到下图的该 ...

  4. java 加载class文件路径_动手实现MVC: 1. Java 扫描并加载包路径下class文件

    背景 用过spring框架之后,有个指定扫描包路径,然后自动实例化一些bean,这个过程还是比较有意思的,抽象一下,即下面三个点 如何扫描包路径下所有的class文件 如何扫描jar包中对应包路径下所 ...

  5. cmake The source directory xxxx does not appear to contain CMakeLists.txt

    执行 cmake . 的时候报错: The source directory "xxxx" does not appear to contain CMakeLists.txt 简单 ...

  6. 解决CMake Error: The source directory … does not appear to contain CMakeLists.txt.

    声明: 在ubuntu20下安装openpose时需要安装Opnecv 问题:从http://opencv.org/releases.html中下载了opencv-3.4.12的Sources版本. ...

  7. java jar 目录_将Java类路径中的所有jar包括在一个目录中

    有没有一种方法可以将所有的jar文件包含在类路径的目录中? 我正在尝试java -classpath lib / *.jar :. my.package.Program,它无法找到当然在这些罐子里的类 ...

  8. java前端目录_[Java教程]前端那点事儿——Tocify自动生成文档目录

    [Java教程]前端那点事儿--Tocify自动生成文档目录 0 2016-06-29 22:00:07 今天偶然间看到文档服务器有一个动态目录功能,点击目录能跳转到指定的位置:窗口滑动也能自动更新目 ...

  9. bat脚本中获取上级目录_使用Python写一个可以监控Tomcat 运行的脚本,并且把.py文件转换成.exe文件...

    使用Python写一个可以监控Tomcat 运行的脚本,并且把.py文件转换成.exe文件 文章来源与博主本人的CSDN博客,博客地址:https://blog.csdn.net/weixin_435 ...

最新文章

  1. 办公室自动化系统_大队举办办公自动化系统培训班
  2. 在Windows下使用gcc
  3. CF708E-Student‘s Camp【数学期望,dp】
  4. 第三章 正态性检验、自相关检验与异方差性检验
  5. 【vue.config.js配置configureWebpack的optimization splitChunks页面空白 - DCloud】
  6. Spring容器扩展机制
  7. I00013 鸡兔同笼
  8. 支持HTML5 SqlLite的AndroidApp
  9. Hadoop yarn配置参数
  10. aix服务器端口配置文件,aix系统查看端口号
  11. LintCode #4. 丑数 II
  12. 公民住宅权不可侵犯!为阻强拆致人重伤,属正当防卫
  13. springCloud微服务生态圈囊括—— 服务注册,服务调用,服务降级,熔断。(1)
  14. 在verilog中将 .txt文件读入reg/将reg的数据写入.txt
  15. 使用win32com来实现outlook的自动发送
  16. 【毕业设计系列】033:基于MATLAB语言的实时变声器系统【含Matlab源码】
  17. 天猫双11背后的阿里技术
  18. 进入空气稀薄地带,《朗读者》再现阿里云10年技术自主研发
  19. SQuirrel连接hive配置
  20. mysql 短整型_C++ int,short,long(详解版)

热门文章

  1. Ubuntu20.04安装eBPF BCC
  2. Linux 如何隔离CPU核心 isolcpus=0-2
  3. CUDA(*.cu)程序与C(*.c)源程序混合编译
  4. 关于PF_INET和AF_INET的区别
  5. php如何从mongo获取视频文件,使用mongodb对文件(图片、音频、视频)的存储、读取操作...
  6. python编写自动化脚本工具_python自动化工具之pywinauto实例详解
  7. Linux中shell运行方式,linux脚本中父shell与子shell 执行的几种方式
  8. 食物在人体内消化主要经过哪些步骤
  9. python re模块详解_python与正则表达式:re模块详解
  10. php网站https怎么做301,php网站如何增加https安全访问