<>自定义项目的CMake配置
# 最低CMake版本要求 cmake_minimum_required(VERSION 3.14.5) # 项目名称 project(NCNN_TEST)
# 查找OpenCV find_package(OpenCV REQUIRED) # OpenCV4编译需要使用C++11 set(
CMAKE_CXX_STANDARD 11) # ncnn项目所在路径,需要替换 set(NCNN_DIR /path/to/ncnn) #
引入OpenCV和NNCN的头文件 include_directories(${OpenCV_INCLUDE_DIRS})
include_directories(${NCNN_DIR}/build/install/include/) # 设置OpenCV和NNCN的链接库 set(
NCNN_LINK_LIBRARIES${OpenCV_LIBS} ${NCNN_DIR}/build/install/lib/libncnn.a) # 源文件
set(SOURCE_FILES example.cpp) # 使用给定的源文件,为工程引入一个可执行文件,创建目标文件 add_executable(
NCNN_TEST${SOURCE_FILES}) # 将目标文件与库文件进行链接 target_link_libraries( NCNN_TEST
${NCNN_LINK_LIBRARIES} ) # 设置cmake版本,如果cmake版本过高,可能会出现错误 cmake_minimum_required(
VERSION 3.5.1) project(NCNN_test) # 设置C++编译版本 set(CMAKE_CXX_STANDARD 11) #
设置程序编译出的可执行文件 set(MAIN_FILE main.cpp) set(EXECUTABLE_OUTPUT_PATH ../) #
分别设置ncnn的链接库和头文件 set(NCNN_LIBS /ncnn/build/install/lib/libncnn.a) set(
NCNN_INCLUDE_DIRS /ncnn/build/install/include) # 配置OpenMP find_package(OpenMP
REQUIRED) if(OPENMP_FOUND) message("OPENMP FOUND") set(CMAKE_C_FLAGS "
${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}
${OpenMP_CXX_FLAGS}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}
${OpenMP_EXE_LINKER_FLAGS}") endif() # 配置OpenCV find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS}) include_directories(
${NCNN_INCLUDE_DIRS}) # 建立链接依赖 add_executable(NCNN main.cpp)
target_link_libraries(NCNN ${NCNN_LIBS}) target_link_libraries(NCNN
${OpenCV_LIBS})

技术
©2019-2020 Toolsou All rights reserved,
Java开发2020年最新常见面试题整理【Spring源码分析】42-@Conditional详解element-ui踩坑记录神仙面试宝典你有了吗?半月看完25大专题,居然斩获阿里P8offer使用css样式设计一个简单的html登陆界面XCTF攻防世界web新手练习_ 9_command_executionJS中的解构赋值的详解与具体用途Python Web 框架elementui 穿梭框 el-transfer 展示列表内容文字过长ConcurrentHashMap实现原理及源码解析