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错误 查 ...
随机推荐
- deepin开机自动启动服务备忘
systemctl enable mysql.service(设置开机自启) sudo systemctl start nginx.service sudo systemctl restart ngi ...
- Python基础笔记2
@time 2019/12/17 12:04 一.列表 1.增加数据:append.insert方法 names = ["兰陵王", "孙悟空", " ...
- RYU安装教程
一.使用pip的形式安装RYU 1.首先检查ubuntu中是否存在pip,命令为 sudo pip3 --version 2.如果存在则使用默认版本8.1.1就行不必跟新,否则自己下载一个pip 3. ...
- centos7添加多个网段
# service network restart是重启所有网卡.例如下面的例子:>ifconfig eth0 up|down>service network restart|start| ...
- requests-验证码登录
ModuleNotFoundError: No module named 'bs4': 解决方法:pip install beautifulsoup4 https://blog.csdn.net/wi ...
- LEF 格式
LEF 文件是布局布线根据使用的cell 几何信息库的文件格式,下面是一个LEF文件的部分,右边是对他的解释.布局布线工具将根据LEF文件的信息决定怎样布局,怎么走线,怎样生成通孔. VERSION ...
- TI DaVinci(达芬奇)入门
(转载来自 德州仪器半导体技术(上海)有限公司 通用DSP 技术应用工程师 崔晶 德州仪器(TI)的第一颗达芬奇(DaVinci)芯片(处理器)DM6446已经问世快三年了.继DM644x之后,TI又 ...
- FactoryBean的作用
Spring 中有两种类型的Bean,一种是普通Bean,另一种是工厂Bean 即 FactoryBean.FactoryBean跟普通Bean不同,其返回的对象不是指定类的一个实例,而是该Facto ...
- LED Holiday Light -Picking LED Christmas Lights, 4 Things
LED Christmas lights are not very cheap, but you should know that LED lights can be used for more th ...
- Itext相关知识
最近需求用到office和pdf相关知识,office使用poi操作的,pdf则使用Itext操作 Itext官网: http://itextpdf.com/ Itext7相关使用示例:https:/ ...