瑞芯微CmakeLists 转makefile

官网的CmakeLists.txt

cmake_minimum_required(VERSION 3.4.1)

project(rknn_zero_copy_demo_linux)

set(CMAKE_SYSTEM_NAME Linux)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

if (CMAKE_C_COMPILER MATCHES "aarch64")
  set(LIB_ARCH lib64)
else()
  set(LIB_ARCH lib)
endif()

# rga
set(RGA_DIR ${CMAKE_SOURCE_DIR}/../3rdparty/rga)
include_directories(${RGA_DIR}/include)

# drm
set(DRM_DIR ${CMAKE_SOURCE_DIR}/../3rdparty/drm)
include_directories(${DRM_DIR}/include)
include_directories(${DRM_DIR}/include/libdrm)

include_directories(${CMAKE_SOURCE_DIR}/include)

# rknn api
set(RKNN_API_PATH ${CMAKE_SOURCE_DIR}/../librknn_api)
include_directories(${RKNN_API_PATH}/include)
set(RKNN_API_LIB ${RKNN_API_PATH}/${LIB_ARCH}/librknn_api.so)

# opencv
if(LIB_ARCH STREQUAL "lib")
	set(OpenCV_DIR ${CMAKE_SOURCE_DIR}/../3rdparty/opencv/opencv-linux-armhf/share/OpenCV)
else()
	set(OpenCV_DIR ${CMAKE_SOURCE_DIR}/../3rdparty/opencv/opencv-linux-aarch64/share/OpenCV)
endif()
find_package(OpenCV REQUIRED)

set(CMAKE_INSTALL_RPATH "lib")

add_executable(rknn_zero_copy_demo
        src/drm_func.c
        src/rga_func.c
        src/postprocess.cc
        src/main.cc
        )

target_link_libraries(rknn_zero_copy_demo
	${RKNN_API_LIB}
  ${OpenCV_LIBS}
  dl
)

# install target and libraries
set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/install/rknn_zero_copy_demo)
install(TARGETS rknn_zero_copy_demo DESTINATION ./)
install(DIRECTORY model DESTINATION ./)
install(PROGRAMS ${RKNN_API_LIB} DESTINATION lib)

我改写的makefile

EXE=main_demo
CC = arm-linux-gnueabihf-g++
AR = arm-linux-gnueabihf-ar
LDFLAGS :=
CXXFLAGS := -pthread -Wall -c  -o -ldl #ldl 解决 ldopen no define 
THR_DPARTY := ../3rdparty
#  opencv include ----
OPENCV_PATH:= $(THR_DPARTY)/opencv/opencv-linux-armhf
INCS = -I$(OPENCV_PATH)/include/  #INCLUDES 指定了头文件的路径
# CXXFLAGS+=$(INCS)
#  opencv lib ----
OPENCV_SHAER_LIBS_PATH:= $(OPENCV_PATH)/share/OpenCV/3rdparty/lib
OPENCV_SHAER_LIBS := $(foreach opencvlib, $(OPENCV_SHAER_LIBS_PATH), $(wildcard $(opencvlib)/*.a))# 2 找.cc 文件
LIBS += ${OPENCV_PATH}/lib/libopencv_imgcodecs.a
LIBS += ${OPENCV_PATH}/lib/libopencv_imgproc.a
LIBS += ${OPENCV_PATH}/lib/libopencv_core.a
LIBS += $(OPENCV_SHAER_LIBS) # 这几个不知道为神马 就算 加不上


#--rga--
INCS += -I$(THR_DPARTY)/rga/include/  #INCLUDES 指定了头文件的路径
LIBS +=  $(THR_DPARTY)/rga/lib/librga.so
#--drm-
INCS +=  -I$(THR_DPARTY)/drm/include/  #INCLUDES 指定了头文件的路径
INCS +=  -I$(THR_DPARTY)/drm/include/libdrm/  #INCLUDES 指定了头文件的路径
LIBS +=  $(THR_DPARTY)/drm/lib/libdrm.so
#--rknn--librknn_api/include/rknn_api.h
INCS += -I../librknn_api/include/
LIBS += ../librknn_api/lib/librknn_api.so

#---
INCS += -I./include/  #INCLUDES 指定了头文件的路径
LDFLAGS += $(LIBS) -lpthread -ldl
CXX_OBJECTS_CPP := $(shell find ./src/ -name "*.cc")
# CXX_OBJECTS_CPP := ./src/main.cc ./src/drm_func.cc ./src/postprocess.cc  ./src/rga_func.cc
# $(info( $(CXX_OBJECTS)))
CXX_OBJECTS += $(patsubst %.cc,%.o,$(CXX_OBJECTS_CPP))
$(EXE): $(CXX_OBJECTS)
	$(CC)  $(INCS) $(CXX_OBJECTS)  -o $(EXE)  $(LDFLAGS)

%.o: %.cc
	$(CC)  $(INCS) -c  $(CXXFLAGS)  $<  -o  $@
# %.o: %.c
# 	$(CC)  $(INCS) -c  $(CXXFLAGS)  $<  -o  $@
clean:
	rm -f ./src/*.o
	rm -f ./src*.d
	rm -f $(EXE)

你可能感兴趣的:(so,封库,opencv,人工智能,计算机视觉)