camke使用例程
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使用例程的更多相关文章
- (转)linux下和云端通讯的例程, ubuntu和openwrt实验成功(一)
一. HTTP请求的数据流总结#上传数据, yeelink的数据流如下POST /v1.0/device/4420/sensor/9089/datapoints HTTP/1.1Host: api. ...
- Socket编程实践(3) 多连接服务器实现与简单P2P聊天程序例程
SO_REUSEADDR选项 在上一篇文章的最后我们贴出了一个简单的C/S通信的例程.在该例程序中,使用"Ctrl+c"结束通信后,服务器是无法立即重启的,如果尝试重启服务器,将被 ...
- Socket编程实践(2) Socket API 与 简单例程
在本篇文章中,先介绍一下Socket编程的一些API,然后利用这些API实现一个客户端-服务器模型的一个简单通信例程.该例子中,服务器接收到客户端的信息后,将信息重新发送给客户端. socket()函 ...
- C#做有模和非模式化窗体 传值例程
有模窗体:指的是一定要在第二个窗体上操作之后 才能去操作前者窗体 :例如,如果一个对话框,在可以切换到其它窗体或对话框之前要求先单击"确定"或"取消",则它就是 ...
- Delphi容器类之---TList、TStringList、TObjectList,以及一个例程的代码分析
转载自:http://blog.csdn.net/jqandjq/article/details/5429137 看了这里标题,大家可能以为我会谈TListBox控件,那就错了.我要谈的是Delphi ...
- IRP完成例程返回值理解
第一,完成例程里面直接返回STATUS_SUCCESS,这时候IRP已经继续向上回卷,失去了对IRP的控制. 第二,完成例程里面返回STATUS_MORE_PROCESSING_REQUIRED,仍具 ...
- [汇编与C语言关系]2. main函数与启动例程
为什么汇编程序的入口是_start,而C程序的入口是main函数呢?以下就来解释这个问题 在<x86汇编程序基础(AT&T语法)>一文中我们汇编和链接的步骤是: $ as hell ...
- ORA-12523: TNS: 监听程序无法找到适用于客户机连接的例程
今天使用PL/SQL Developer连接到一台新的测试服务器时,遇到ORA错误:ORA-12523: TNS: 监听程序无法找到适用于客户机连接的例程.对应的监听日志文件里面错误为TNS-1252 ...
- Qt 之 入门例程 (一)
以 “Hello Qt” 为例,介绍如何建立一个 Qt 工程 . 1 QLabel 例程 QLabel 继承自 QFrame (继承自 QWidget),主要用来显示文本和图片. 1.1 Hell ...
随机推荐
- 枚举getClass、getDeclaringClass区别
枚举getClass.getDeclaringClass区别 1):“不含抽象方法”,所有枚举常量未重写方法,的class getClass与getDeclaringClass方法输出结果相同 cla ...
- JS之innerHTML,innerText,outerHTML,textContent的用法与区别
示例html代码: <div id="test"> <span style="color:red">test1</span> ...
- 洛谷P3235 [HNOI2014]江南乐(Multi-SG)
题目描述 小A是一个名副其实的狂热的回合制游戏玩家.在获得了许多回合制游戏的世界级奖项之后,小A有一天突然想起了他小时候在江南玩过的一个回合制游戏. 游戏的规则是这样的,首先给定一个数F,然后游戏系统 ...
- BZOJ4484: [Jsoi2015]最小表示(拓扑排序乱搞+bitset)
Time Limit: 20 Sec Memory Limit: 512 MBSubmit: 348 Solved: 172[Submit][Status][Discuss] Descriptio ...
- Human Motion Analysis with Wearable Inertial Sensors——阅读3
Human Motion Analysis with Wearable Inertial Sensors——阅读3 四元数方向滤波器 之前的研究开发了一种自适应增益互补滤波器,并结合高斯 - 牛顿优化 ...
- 网络基础 记一次HTTPS证书验证测试过程
记一次HTTPS证书验证测试过程 by:授客 QQ:1033553122 实践 1) 安装证书 选择主机A(假设10.202.95.88)上安装https证书 说明:采用https的服务器,必须安装数 ...
- linux下ssh通过公钥登录服务器
经常会通过ssh登录远程服务器,一种是通过密码方式登录,一种是通过公钥登录. 如何设置通过公钥登录服务器 1. 首先生成自己的公钥和私钥 ssh-keygen 命令用来生成公钥和私钥 -t 用来指定密 ...
- DBA思考系列——学会拒绝不合理的需求
DBA思考系列--学会拒绝不合理的需求 一直以来,个性都比较随意,一般很少拒绝开发人员的一些需求(有点老好人的感觉). 这点一直被老大诟病,也一直在反省!最近又有一件事情,让我觉得:应该学会拒绝不 ...
- 用户 'XXX\SERVERNAME$' 登录失败。 原因: 找不到与提供的名称匹配的登录名。 [客户端: ]
一工厂的中控服务器遇到了下面Alert提示,'XXX\SERVERNAME$' XXX表示对应的域名, SERVERNAME$(脱敏处理,SERVERNAME为具体的服务器名称+$),而且如下所示, ...
- shell 函数用法
近期在学习shell编程方面的知识,写的不怎么好,请大家多多指点,下面给大家分享一下shell函数的用法. 我们为什么要用shell函数? 简单的说,函数的作用就是把程序多次调用相同的代码部分定义成一 ...