【NCNN】第一講:NCNN在CMakeLists中的配置
阿新 • • 發佈:2019-02-17
直接上程式碼
# 設定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})