CMAKE_MINIMUM_REQUIRED(VERSION 2.6) #cmake 最低版本要求,低于2.6 构建过程会被终止。
PROJECT(Algorithms) #定义工程名称
MESSAGE(STATUS "Project: Algorithms") #打印相关消息消息
MESSAGE(STATUS "Project Directory: ${PROJECT_SOURCE_DIR}")
SET(CMAKE_BUILD_TYPE "Debug")
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g2 -ggdb")
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")
add_definitions(-DCPU_ONLY)
add_definitions(-DUSE_OPENCV)
add_definitions(-DUSE_CAFFE)
add_compile_options(-std=c++11)
ADD_SUBDIRECTORY(src) #添加子目录
INCLUDE_DIRECTORIES( #相关头文件的目录
/usr/include
${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/include/parameter
${PROJECT_SOURCE_DIR}/include/result
${PROJECT_SOURCE_DIR}/include/features
${PROJECT_SOURCE_DIR}/include/glog
${PROJECT_SOURCE_DIR}/include/json
${PROJECT_SOURCE_DIR}/include/OpenBLAS
${PROJECT_SOURCE_DIR}/include/utils
)
FIND_LIBRARY(RUNTIME_LIB caffe /usr/lib ${PROJECT_SOURCE_DIR}/lib /usr/local/lib NO_DEFAULT_PATH)
MESSAGE(STATUS "find caffe ----reuslt --- : ${RUNTIME_LIB}")
aux_source_directory(. SOURCE_FILES)
ADD_EXECUTABLE(Algorithms ${SOURCE_FILES}) #shengchengwenjian
LINK_DIRECTORIES( #相关库文件的目录
${PROJECT_SOURCE_DIR}/lib
/usr/local/lib
)
TARGET_LINK_LIBRARIES(Algorithms
protobuf
algorithm
gflags
boost_filesystem
m
hdf5
boost_system
glog
opencv_core
opencv_highgui
opencv_imgproc
${PROJECT_SOURCE_DIR}/lib/libcaffe.so
pthread
)
SET_TARGET_PROPERTIES(Algorithms PROPERTIES #表示生成的执行文件所在路径
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)