Linux工程搭建
cmake
1
安装cmake,sudo apt install cmake,并编写Cmakel ists.txt。
2
执行命令"cmake PATH"或者"ccmake PATH"生成Makefile (PATH是 CMakelists.txt 所在的目录)。
3
使用make命令进行编译。
cmake 语法
#确定cmake最低版本
cmake_minimum_required(VERSION 2.8)
#打印
MESSAGE(STATUS "This is install dir" ${CMAKE_INSTALL_PREFIX})
#确定工程名
project(XXX)
#添加需要的库
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH) "/usr/local/share/OpenCV")find_package(OpenCV 3.2.0 REQUIRED)
#添加需要的头文件include_directories(include)include_directories(${OpenCV_INCLUDE_DIRS))include_directories(/usr/local/cuda-8.0/include/)
#确定编译语言
#add_definitions(-std=c++11)set(CMAKE_CXX_STANDARD 11)
#设定变量ADD_DEFINITIONS(-DGPU-DCUDNN)
#添加源代码aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/src src)
#编译动态库并链接库文件link_directories(${PROJECT_SOURCE_DIR))add_library(plate_recognition SHARED $(SRC))target_link_libraries(plate_recognition -Ilianghao -Ipthread-Im -Istdc++)
等等
标签:CMAKE,23,directories,PATH,OpenCV,Linux,cmake,include,搭建
From: https://www.cnblogs.com/mzx233/p/17716597.html