windows CMakeLists.txt
在windows下写好CMakeLists.txt,然后配合cmake-gui使用。
CMakeLists.txt写的不够好,后期优化,以下仅供参考:
# set(OpenCV_DIR D:/Program Files/opencv3.4.6/opencv/build/include/)
find_package(OpenCV 3.4. 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}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
set(LINK_DIR D:/windows/x64/Release/)
# Add OpenCV headers location to your include paths
include_directories(${OpenCV_INCLUDE_DIRS}) # Declare the executable target built from your sources aux_source_directory(. DIR_SRCS)
add_executable(main ${DIR_SRCS}) # Link your application with OpenCV libraries
# link_libraries("D:/windows/x64/Release")
LINK_DIRECTORIES(${LINK_DIR}) #链接静态库目录
target_link_libraries(main ${OpenCV_LIBS} ${LINK_DIR}/idcard.lib)
由于依赖opencv静态库,opencv又没有设置为环境变量,cmake直接找依赖opencv时总是会找到Anaconda里面的opencv,此时需要把opencv路径指定到你编译opencv静态库的路径:
也可以将CMakeLists.txt写成下面的形式,这样就可以自己在cmake-gui里面自己配置需要链接的静态库路径:
# cmake needs this line
cmake_minimum_required(VERSION 2.8) # Define project name
project(DLCropTest) # 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
# set(OpenCV_DIR D:/Program Files/opencv3.4.6/opencv/build/include/)
find_package(OpenCV REQUIRED)
find_library(LINK_DIR 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}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
# set(LINK_DIR D:/windows/x64/Release/)
# Add OpenCV headers location to your include paths
include_directories(${OpenCV_INCLUDE_DIRS}) # Declare the executable target built from your sources aux_source_directory(. DIR_SRCS)
add_executable(main ${DIR_SRCS}) # Link your application with OpenCV libraries
# link_libraries("D:/windows/x64/Release")
LINK_DIRECTORIES(${LINK_DIR}) #链接静态库目录
target_link_libraries(main ${OpenCV_LIBS} ${LINK_DIR}/*.lib)
cmake-gui对应位置如下图:
windows CMakeLists.txt的更多相关文章
- [Windows篇] 在windows 10上源码编译gtest 并编写CMakeLists.txt
本文首发于个人博客https://kezunlin.me/post/aca50ff8/,欢迎阅读! compile gtest on windows 10 Guide compile gtest on ...
- opencv3在CMakeLists.txt中的调用问题
在cmake工程中使用opencv需要在CMakeLists.txt文件中加以调用,在opencv2.xx版本,可以用以下语句 # 寻找OpenCV库 find_package( OpenCV REQ ...
- linux CMakeLists.txt 语法
CMake入门教程 参考文献:http://www.ibm.com/developerworks/cn/linux/l-cn-cmake/index.html 官方网址:http://www.cmak ...
- CMake之CMakeLists.txt编写入门
自定义变量 主要有隐式定义和显式定义两种. 隐式定义的一个例子是PROJECT指令,它会隐式的定义< projectname >_BINARY_DIR和< projectname & ...
- CMakeLists.txt编写常用命令
目录 1. 设置cmake最小版本 2. 设置项目名称 3. 设置编译目标类型 4. 指定编译包含的源文件 1. 明确指明包含的源文件 2. 搜索指定目录的所有的cpp文件 3. 自定义搜索规则 4. ...
- CMakeLists.txt install
本部分是关于ros CMakeLists.txt install :可参考http://wiki.ros.org/catkin/CMakeLists.txt 1.CMakeLists.txt中的in ...
- 简单CMakeLists.txt文件
#CMakeLists.txt cmake_minimum_required(VERSION 2.8) project(server) #添加包含目录 include_directories(./in ...
- CMAKE 生成VS2008静态库工程 与 CMAKE使用,CMakeLists.txt编写总结
cmake -G"Visual Studio 9 2008 Win64" 以上命令得用cd命令切换到顶层CMakeLists.txt的当前目录,才能生效 以下是CMakeLists ...
- Android Studio Linking an external C++ project 时候 报Invalid file name. Expected: CMakeLists.txt
Android Studio 右键Linking an external C++ project 时候 报Invalid file name. Expected: CMakeLists.txt错误 查 ...
随机推荐
- Python之路Day09
函数 将某个功能封装到一个空间中就是一个函数 减少重复代码 函数体中存放的时代码 定义函数 def len(): def 关键字 len 函数名 -- 变量名 ()格式规定 :语句结束 调用函数 函数 ...
- PHP中关于foreach使用引用变量的坑
PHP版本为 5.6.12 代码如下: 1 2 3 4 5 6 7 8 9 10 11 12 <?php $arr = ['a', 'b', 'c', 'd', 'e']; foreach ...
- TD - 输入框
模板1:TD - 普通输入框 <input dojoType="bootstrap.form.ValidationTextBox" dojoAttachPoint=" ...
- 占位 SC
占位 SC include: SC404 SC405
- Intellij IDEA史上最全快捷键大全
古人有云:工欲善其事,必先利其器,要是只是手握利器,而不能发挥其最大的效益,那无异于赤手空拳,对敌对垒. 那古人所云,未得其精髓,只能为碎语闲言尔. 自动代码 常用的有fori/sout/psvm+T ...
- .NET知识梳理——4.特性Attribute
1. 特性 1.1 特性Attribute 特性就是一个类,继承自Attribute抽象类(该类无抽象方法.避免实例化),约定俗成用Attribute类结尾,标记时可省略掉Attribu ...
- 163.扩展User模型-一对一方式扩展
一对一外键 如果你对用户验证方法authenticate没有更多的要求,就是使用username和password就可以完成用户的登录验证工作,但是想要在原来的模型的基础上添加新的字段,那么就可以使用 ...
- linux切换普通用户遇bash-4.1解决
1,修改vim /etc/passwd 把对应用户的登陆环境改成,/bin/bash 2,复制配置 cp -a /etc/skel/. /home/www/ 3再次尝试su www有效
- python | 网络编程(socket、udp、tcp)
一.套接字 socket 1.1 作用:实现不同主机间的进程间通信(不同电脑.手机等设备之间收发数据) 1.2 分类:udp.tcp 1.3 创建 socket import socket socke ...
- Codeforces Round #621 (Div. 1 + Div. 2)D(最短路,图)
#define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ]; vector<]; ]; ] ...