Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide XRoc Sample #6

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
134 changes: 134 additions & 0 deletions src/sample/x2/xroc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
cmake_minimum_required(VERSION 2.8)
option(PARENT_BUILD "is build from parent" OFF)
if(NOT ${PARENT_BUILD})
include(cmake/hobot_util.cmake)
endif()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不需要包含gradle这一套参数了, 用最简单的cmake来改造吧, 参考FasterrcnnMethod

project(xroc-framework-example)

option(RELEASE_LIB "build version of release" ON)

if (${RELEASE_LIB})
set(CMAKE_BUILD_TYPE Release)
else ()
set(CMAKE_BUILD_TYPE Debug)
endif ()

if (${PLATFORM_MAC})
add_definitions(-DHR_POSIX)
add_definitions(-DHR_MAC)
elseif (${PLATFORM_LINUX})
add_definitions(-DHR_POSIX)
add_definitions(-DHR_LINUX)
if(NOT(${arch} STREQUAL "default") AND NOT(${arch} STREQUAL "x86"))
if(${arch} STREQUAL "arm_hi3519")
list(APPEND CMAKE_C_FLAGS " -mcpu=cortex-a17.cortex-a7 -mfloat-abi=softfp -mfpu=neon-vfpv4 ")
add_definitions(-DHR_HI3519)
elseif(${arch} STREQUAL "armhf")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

把这些没用的编译选项去掉,只写aarch64的参数就行,可以参考在Fasterrcnnmethod和smartplugin精简的cmake

list(APPEND CMAKE_C_FLAGS " -marm -mfloat-abi=hard -mfpu=neon ")
elseif(${arch} STREQUAL "aarch64")
list(APPEND CMAKE_C_FLAGS "-march=armv8-a -mcpu=cortex-a53 ")
elseif (${arch} STREQUAL "armv8l")
# x2 32 soc
add_definitions(-DX2)
else()
list(APPEND CMAKE_C_FLAGS " -marm -mfloat-abi=softfp -mfpu=neon ")
endif()
else() # linux on x86?
list(APPEND CMAKE_C_FLAGS " -msse4.2 ")
endif()
elseif (${PLATFORM_ANDROID})
set(ENABLE_NEON "true")
add_definitions(-DENABLE_OMP)
add_definitions(-DHR_POSIX)
add_definitions(-DHR_ANDROID)
elseif (${PLATFORM_WIN})
set(CMAKE_CXX_FLAGS_RELEASE "/MD")
set(CMAKE_CXX_FLAGS_DEBUG "/MDd")
add_definitions(-DHR_WIN)
add_definitions(-D_MBCS)
add_definitions(-DHOBOT_EXPORTS)
else ()
message(FATAL_ERROR "invoke cmake with -DPLATFORM_MAC=TRUE|-DPLATFORM_LINUX=TRUE|-DPLATFORM_ANDROID=TRUE|-DPLATFORM_WIN=TRUE")
return()
endif()
message("CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}" )

option(USE_ENCRYPT "whether to use hobot aes encrypt" OFF)
if (NOT ${USE_ENCRYPT})
add_definitions(-DNO_ENCRYPT)
message("not use hobot aes encrypt")
else ()
message("use hobot aes encrypt")
endif()

option(USE_OMP "whether to use omp" OFF)
if (NOT ${USE_OMP})
add_definitions(-DNO_OMP)
message("not use omp..")
else ()
message("use omp..")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp" )
endif ()

option(IPC_VER "whether to use omp" OFF)
if (NOT ${IPC_VER})
add_definitions(-DNOIPC_VER)
message("not ipc ver..")
else ()
message("ipc ver..")
add_definitions(-DUSE_ZLOG)
message("use zlog....")
add_definitions(-DNO_OMP)
message("not use omp....")
endif ()

set(CMAKE_CXX_STANDARD 11)

if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
message("building release")
list(APPEND CMAKE_C_FLAGS " -O3")
else ()
list(APPEND CMAKE_C_FLAGS " -Og -g ")
endif()

list(APPEND CMAKE_C_FLAGS " -Wall -fPIC")
list(APPEND CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11")
string(REGEX REPLACE ";" " " CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
string(REGEX REPLACE ";" " " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})


include_directories(
include
include/common
include/log
include/timer
)

include_directories(SYSTEM /usr/include/python2.7)


message("add src files ...")

#add_library(xroc-framework STATIC ${SOURCE_FILES})

add_subdirectory(example/bbox_filter)


if(NOT ${PARENT_BUILD})
set(OUTPUT_ROOT ${CMAKE_SOURCE_DIR}/output/)
endif()

set(MY_OUTPUT_ROOT ${OUTPUT_ROOT}/${PROJECT_NAME})

install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/hobotxsdk
DESTINATION ${MY_OUTPUT_ROOT}/include/
FILES_MATCHING PATTERN "*.h")
install(FILES
${PROJECT_SOURCE_DIR}/include/hobotxroc/method.h
${PROJECT_SOURCE_DIR}/include/hobotxroc/method_factory.h
${PROJECT_SOURCE_DIR}/include/hobotxroc/profiler.h
DESTINATION ${MY_OUTPUT_ROOT}/include/hobotxroc)

#install(TARGETS ${PROJECT_NAME}
# DESTINATION ${MY_OUTPUT_ROOT}/lib)

Loading