1 同文件夹直接编译

1 同文件夹直接编译

# cmake needs this line
cmake_minimum_required(VERSION 2.8) # Define project name
project(pixel_Giga) # Find OpenCV, you may need to set OpenCV_DIR variable
# to the absolute path to the directory containing OpenCVConfig.cmake file
# via the command line or GUI
find_package(OpenCV REQUIRED) # If the package has been found, several variables will
# be set, you can find the full list with descriptions
# in the OpenCVConfig.cmake file.
# Print some message showing some of them
message(STATUS "OpenCV library status:")
message(STATUS " version: ${OpenCV_VERSION}")
message(STATUS " libraries: ${OpenCV_LIBS}")
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}") if(CMAKE_VERSION VERSION_LESS "2.8.11")
# Add OpenCV headers location to your include paths
include_directories(${OpenCV_INCLUDE_DIRS})
endif() # Declare the executable target built from your sources
add_executable(camera1 camera1.cpp openShare.cpp openShare.hpp)
# Link your application with OpenCV libraries
target_link_libraries(camera1 ${OpenCV_LIBS}) # Declare the executable target built from your sources
add_executable(camera2 camera2.cpp openShare.cpp openShare.hpp)
# Link your application with OpenCV libraries
target_link_libraries(camera2 ${OpenCV_LIBS}) # Declare the executable target built from your sources
add_executable(camera3 camera3.cpp openShare.cpp openShare.hpp)
# Link your application with OpenCV libraries
target_link_libraries(camera3 ${OpenCV_LIBS}) # Declare the executable target built from your sources
add_executable(camera4 camera4.cpp openShare.cpp openShare.hpp)
# Link your application with OpenCV libraries
target_link_libraries(camera4 ${OpenCV_LIBS}) # Declare the executable target built from your sources
add_executable(camera5 camera5.cpp openShare.cpp openShare.hpp)
# Link your application with OpenCV libraries
target_link_libraries(camera5 ${OpenCV_LIBS}) # Declare the executable target built from your sources
add_executable(camera6 camera6.cpp openShare.cpp openShare.hpp)
# Link your application with OpenCV libraries
target_link_libraries(camera6 ${OpenCV_LIBS}) # Declare the executable target built from your sources
add_executable(camera7 camera7.cpp openShare.cpp openShare.hpp)
# Link your application with OpenCV libraries
target_link_libraries(camera7 ${OpenCV_LIBS}) # Declare the executable target built from your sources
add_executable(camera8 camera8.cpp openShare.cpp openShare.hpp)
# Link your application with OpenCV libraries
target_link_libraries(camera8 ${OpenCV_LIBS}) # Declare the executable target built from your sources
add_executable(camera9 camera9.cpp openShare.cpp openShare.hpp)
# Link your application with OpenCV libraries
target_link_libraries(camera9 ${OpenCV_LIBS}) # Declare the executable target built from your sources
add_executable(camera10 camera10.cpp openShare.cpp openShare.hpp)
# Link your application with OpenCV libraries
target_link_libraries(camera10 ${OpenCV_LIBS}) # Declare the executable target built from your sources
add_executable(camera11 camera11.cpp openShare.cpp openShare.hpp)
# Link your application with OpenCV libraries
target_link_libraries(camera11 ${OpenCV_LIBS}) # Declare the executable target built from your sources
add_executable(camera12 camera12.cpp openShare.cpp openShare.hpp)
# Link your application with OpenCV libraries
target_link_libraries(camera12 ${OpenCV_LIBS}) # Declare the executable target built from your sources
add_executable(dispose1 dispose1.cpp openShare.cpp openShare.hpp)
# Link your application with OpenCV libraries
target_link_libraries(dispose1 ${OpenCV_LIBS})

2 同文件夹多个编译

CMakeLists.txt

cmake_minimum_required(VERSION 2.6)
project(tcp) #自动连接模式 #1将文件夹下全部文件链接到 src
#aux_source_directory(. src)
#将src里面的所有文件链接用于生成可执行文件
#add_executable(project1 ${src}) #手动添加模式
#1测试-生成可执行文件main
add_executable(main src/main.cpp) add_executable(client src/client.cpp) add_executable(Server src/Server.cpp) add_executable(http_client src/http_client.cpp) #设置可执行文件的输出目录
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)

src源码地址

可执行文件夹

3 分文件夹间接编译

CMakeLists.txt

#1工程名字
PROJECT(main)
#2版本要求
CMAKE_MINIMUM_REQUIRED(VERSION 2.6) #3-1该命令会把参数 <.当前文件夹> 中所有的源文件名称赋值给参数 <DIR_SRCS>
AUX_SOURCE_DIRECTORY(. DIR_SRCS)
#3-2包含src文件夹下的内容,会自动到该文件夹下寻找新的cmake
ADD_SUBDIRECTORY( src ) #0 指示变量 DIR_SRCS 中的源文件需要编译 成一个名称为 main 的可执行文件。
ADD_EXECUTABLE(main ${DIR_SRCS}) #-1 链接库
TARGET_LINK_LIBRARIES( main Test )

main.cpp

#include <iostream>
using namespace std;
#include "src/print_drc.cpp"
#include "src/print_src.cpp" int main()
{ print_drc();
print_src(); cout<<"hello world"<<endl;
return 1;
}

CMakeLists.txt

#3-1该命令会把参数 <.当前文件夹> 中所有的源文件名称赋值给参数 <DIR_TEST1_SRCS>
AUX_SOURCE_DIRECTORY(. DIR_TEST1_SRCS) #0 指示变量 DIR_SRCS 中的源文件需要编译 成一个名称为 main 的可执行文件。
#ADD_EXECUTABLE(main ${DIR_SRCS})
#0 指示变量 DIR_TEST1_SRCS 中的源文件需要编译 成一个名称为 main 的库。
ADD_LIBRARY ( Test ${DIR_TEST1_SRCS})

print_drc.cpp

#include <iostream>

using namespace std;

int print_drc()
{
cout<<"1 这是来自直接目录下的测试!"<<endl;
return 1;
}

print_src.cpp

#include <iostream>

using namespace std;

int print_src()
{
cout<<" 2 这是来自src下的测试!"<<endl;
return 1;
}

编译

cmake ..

make

运行

camke使用例程的更多相关文章

  1. (转)linux下和云端通讯的例程, ubuntu和openwrt实验成功(一)

    一.  HTTP请求的数据流总结#上传数据, yeelink的数据流如下POST /v1.0/device/4420/sensor/9089/datapoints HTTP/1.1Host: api. ...

  2. Socket编程实践(3) 多连接服务器实现与简单P2P聊天程序例程

    SO_REUSEADDR选项 在上一篇文章的最后我们贴出了一个简单的C/S通信的例程.在该例程序中,使用"Ctrl+c"结束通信后,服务器是无法立即重启的,如果尝试重启服务器,将被 ...

  3. Socket编程实践(2) Socket API 与 简单例程

    在本篇文章中,先介绍一下Socket编程的一些API,然后利用这些API实现一个客户端-服务器模型的一个简单通信例程.该例子中,服务器接收到客户端的信息后,将信息重新发送给客户端. socket()函 ...

  4. C#做有模和非模式化窗体 传值例程

    有模窗体:指的是一定要在第二个窗体上操作之后 才能去操作前者窗体 :例如,如果一个对话框,在可以切换到其它窗体或对话框之前要求先单击"确定"或"取消",则它就是 ...

  5. Delphi容器类之---TList、TStringList、TObjectList,以及一个例程的代码分析

    转载自:http://blog.csdn.net/jqandjq/article/details/5429137 看了这里标题,大家可能以为我会谈TListBox控件,那就错了.我要谈的是Delphi ...

  6. IRP完成例程返回值理解

    第一,完成例程里面直接返回STATUS_SUCCESS,这时候IRP已经继续向上回卷,失去了对IRP的控制. 第二,完成例程里面返回STATUS_MORE_PROCESSING_REQUIRED,仍具 ...

  7. [汇编与C语言关系]2. main函数与启动例程

    为什么汇编程序的入口是_start,而C程序的入口是main函数呢?以下就来解释这个问题 在<x86汇编程序基础(AT&T语法)>一文中我们汇编和链接的步骤是: $ as hell ...

  8. ORA-12523: TNS: 监听程序无法找到适用于客户机连接的例程

    今天使用PL/SQL Developer连接到一台新的测试服务器时,遇到ORA错误:ORA-12523: TNS: 监听程序无法找到适用于客户机连接的例程.对应的监听日志文件里面错误为TNS-1252 ...

  9. Qt 之 入门例程 (一)

    以 “Hello Qt” 为例,介绍如何建立一个 Qt 工程 . 1  QLabel 例程 QLabel 继承自 QFrame (继承自 QWidget),主要用来显示文本和图片. 1.1  Hell ...

随机推荐

  1. Laravel 系列入门教程(二)【最适合中国人的 Laravel 教程】

    本篇文章中,我将跟大家一起体验 Laravel 框架最重要的部分——路由系统. 如果你读过 2015 版的教程,你会发现那篇文章里大书特书的 Auth 系统构建已经被 Laravel 捎带手给解决了. ...

  2. thinkphp简洁、美观、靠谱的分页类

    我们要实现如下图分页效果 这个分页类是在thinkphp框架内置的分页类的基础上修改而来:原分页类的一些设计,在实际运用中感觉不是很方便: 1.只有一页内容时不显示分页: 2.原分页类在当前页是第一页 ...

  3. 3;XHTML排列清单控制标记

    1.无序号条例式清单<ul> 2.有序号条例式清单<ol> 3.无序列表和有序列表的结合应用 4.叙述式清单<dl> 排列清单控制标记可以创建一般的列表.编号列表或 ...

  4. SDN的初步实践--通过netconf协议控制交换机

    1.近期在做一个云服务项目,需要与物理交换机配合实现,通过python编程实现了对物理交换机的控制,完全不需要命令行手工配置交换机, 一定程度上实现了SDN的集中控制的思想. 2.架构图如下: 3.利 ...

  5. chrome正确的打开方式

    1:修改默认的搜索引擎 原因是中国不能使用Google浏览器,所以需要对其默认的搜索引擎进行改造:   三个点/设置/修改默认搜索引擎     2:使用插件;   右上角的省略号小点/更多工具/扩展应 ...

  6. 上了IPD和CMMI,为什么还要搞敏捷?

    文/资深顾问 杨学明 现在国内许多产品创新型企业一旦研发团队上了规模,就会进行IPD体系的变革或CMMI的认证,但现在还有一种更加流程的开发模式,就是敏捷,华为公司早在2009年正式发文在全公司现在流 ...

  7. codeforces 632C The Smallest String Concatenation

    The Smallest String Concatenation 题目链接:http://codeforces.com/problemset/problem/632/C ——每天在线,欢迎留言谈论. ...

  8. Snapshot origin volumes can be resized only while inactive: try lvchange -an

    事件现象:   最近同事在扩展VG时遇到了"Snapshot origin volumes can be resized only while inactive: try lvchange ...

  9. [20190214]11g Query Result Cache RC Latches.txt

    [20190214]11g Query Result Cache RC Latches.txt --//昨天我重复链接http://www.pythian.com/blog/oracle-11g-qu ...

  10. MongoDB Sharding分片配置

    Ps:mongod是mongodb实例,mongos被默认为为mongodb sharding的路由实例. 本文使用的mongodb版本为3.2.9,因此参考网址为:https://docs.mong ...