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. form表单基础知识

    form 元素是块级元素 ------------------- ------------------- ----------------------------------------------- ...

  2. POJ3683 Priest John's Busiest Day(2-SAT)

    Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 11049   Accepted: 3767   Special Judge ...

  3. Ubuntu快捷键、Ubuntu终端常用命令

    Ubuntu快捷键 0.Ctrl + Alt + t 打开终端,在终端命令行操作 1. Ctrl + W: 关闭当前 Nautilus 窗口 2. Ctrl+T: 在 Nautilus 打开新的 Ta ...

  4. leetcode-977. 有序数组的平方

    leetcode-977. 有序数组的平方 (来自 120周赛) 题意 给定一个按非递减顺序排序的整数数组 A,返回每个数字的平方组成的新数组,要求也按非递减顺序排序. 示例 1: 输入:[-4,-1 ...

  5. 转载:python生成以及打开json、csv和txt文件

    原文地址:https://blog.csdn.net/weixin_42555131/article/details/82012642 生成txt文件: mesg = "hello worl ...

  6. VirtualBox网络连接方式

    VirtualBox图形界面下有四种网络接入方式,它们分别是: 1.NAT 网络地址转换模式(NAT,Network Address Translation) 2.Bridged Adapter 桥接 ...

  7. Spark Standalone 提交模式

    一.Client提交模式 提交命令: ./spark-submit --master spark://node1:7077 --class org.apache.spark.examples.Spar ...

  8. 使用Visual Studio Team Services敏捷规划和项目组合管理(一)——使用团队、区域和迭代

    使用Visual Studio Team Services敏捷规划和项目组合管理(一)--使用团队.区域和迭代 概述 在本实验,你将会了解Visual Studio Team Services提供的敏 ...

  9. A problem has been detected and windows has been shut down to prevent damage to your computer.他么啥意思?看这里!【蓝屏】

    A problem has been detected and windows has been shut down to prevent damage to your computer.  检测到问 ...

  10. aspectj 简单的模拟权限检查、事务、日志记录

    package com.ij34.service; public class Hello { public void he() { System.out.println("执行Hello的h ...