Skip to content

Commit

Permalink
fix(build): add required definitions and include directory for buildi…
Browse files Browse the repository at this point in the history
…ng external dd api
  • Loading branch information
Bycob authored and mergify[bot] committed May 27, 2021
1 parent 447dd53 commit a059428
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 13 deletions.
55 changes: 43 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ if (NOT EXISTS ${CMAKE_BINARY_DIR}/src)
COMMAND bash -c "mkdir ${CMAKE_BINARY_DIR}/src")
endif()

set(CMAKE_CXX_FLAGS "-g -O2 -Wall -Wextra -fopenmp -fPIC -std=c++14 -DUSE_OPENCV -DUSE_LMDB -Wl,--no-as-needed -ltcmalloc_minimal")
set(CMAKE_CXX_FLAGS "-g -O2 -Wall -Wextra -fopenmp -fPIC -std=c++14 -Wl,--no-as-needed -ltcmalloc_minimal")
add_definitions("-DUSE_OPENCV" "-DUSE_LMDB")

if(WARNING)
string(APPEND CMAKE_CXX_FLAGS " -Werror")
Expand Down Expand Up @@ -692,7 +693,6 @@ endif()
if (USE_NCNN)
message(STATUS "Configuring NCNN")
add_definitions(-DUSE_NCNN)
include_directories(${CMAKE_CURRENT_BINARY_DIR})

set(NCNN_PATCHES_PATH ${CMAKE_BINARY_DIR}/patches/ncnn)
set(NCNN_PATCHES
Expand Down Expand Up @@ -732,7 +732,6 @@ if (USE_NCNN)
set(NCNN_LIB_DEPS ${CMAKE_BINARY_DIR}/ncnn/src/ncnn-build/src/libncnn.a)
set(NCNN_INC_DIR ${CMAKE_BINARY_DIR}/ncnn/src/ncnn/src ${CMAKE_BINARY_DIR}/ncnn/src/ncnn-build/src)
set(NCNN_LIB_DIR ${CMAKE_BINARY_DIR}/ncnn/src/ncnn-build/src)
include_directories(${NCNN_INC_DIR})
endif()

# Torch
Expand Down Expand Up @@ -898,12 +897,6 @@ if (USE_TSNE)
set(TSNE_LIB_DIR ${CMAKE_BINARY_DIR}/Multicore-TSNE/src/Multicore-TSNE-build)
endif()

# add the binary tree to the search path for include files
# so that we will find dd_config.h
include_directories("${PROJECT_BINARY_DIR}")
include_directories(${CAFFE_INC_DIR} ${XGBOOST_INC_DIR} ${TSNE_INC_DIR} ${TORCH_INC_DIR})
include_directories(${CMAKE_SOURCE_DIR}/src/backends/caffe ${CMAKE_SOURCE_DIR}/backends/xgb ${CMAKE_SOURCE_DIR}/backends/tf ${CMAKE_SOURCE_DIR}/backends/dlib ${CMAKE_SOURCE_DIR}/backends/tsne)

if (USE_TENSORRT)
add_definitions(-DUSE_TENSORRT)
if (EXISTS ${TENSORRT_DIR}/libprotobuf.a)
Expand Down Expand Up @@ -933,7 +926,6 @@ if (USE_TENSORRT)
endif()

set(TENSORRT_LIB_DIR ${CMAKE_BINARY_DIR}/tensorrt-oss/bin/ ${TENSORRT_LIB_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
set(TENSORRT_LIBS /usr/lib/x86_64-linux-gnu/libnvinfer.so.7 nvcaffeparser nvinfer_plugin nvonnxparser )

if (NOT TENSORRT_VERSION)
Expand Down Expand Up @@ -987,7 +979,6 @@ if (USE_TENSORRT)

# Use our tensorrt-oss header versions first
include_directories(SYSTEM ${CMAKE_BINARY_DIR}/tensorrt-oss/src/tensorrt-oss/include)
include_directories(${TENSORRT_INC_DIR})
endif()

if (USE_HTTP_SERVER_OATPP)
Expand Down Expand Up @@ -1074,10 +1065,48 @@ endif()

# main library, main & tests
include_directories("${PROJECT_SOURCE_DIR}/src")
# add the binary tree to the search path for include files
# so that we will find dd_config.h
include_directories("${PROJECT_BINARY_DIR}")
# caffe.pb.h, ...
include_directories(${CMAKE_BINARY_DIR}/src)

include_directories(
${CAFFE_INC_DIR}
${XGBOOST_INC_DIR}
${TSNE_INC_DIR}
${TORCH_INC_DIR}
${TENSORRT_INC_DIR}
${NCNN_INC_DIR}
)
include_directories(
${CMAKE_SOURCE_DIR}/src/backends/caffe
${CMAKE_SOURCE_DIR}/backends/xgb
${CMAKE_SOURCE_DIR}/backends/tf
${CMAKE_SOURCE_DIR}/backends/dlib
${CMAKE_SOURCE_DIR}/backends/tsne
)

add_subdirectory(src)

set(COMMON_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${HTTP_INCLUDE_DIR} ${PROTOBUF_INCLUDE_DIR} ${SPDLOG_INCLUDE_DIR})
set(COMMON_INCLUDE_DIRS
${Boost_INCLUDE_DIRS}
${HTTP_INCLUDE_DIR}
${PROTOBUF_INCLUDE_DIR}
${SPDLOG_INCLUDE_DIR}
${CAFFE_INC_DIR}
${XGBOOST_INC_DIR}
${TSNE_INC_DIR}
${TORCH_INC_DIR}
${TENSORRT_INC_DIR}
${NCNN_INC_DIR}

${CMAKE_SOURCE_DIR}/src/backends/caffe
${CMAKE_SOURCE_DIR}/backends/xgb
${CMAKE_SOURCE_DIR}/backends/tf
${CMAKE_SOURCE_DIR}/backends/dlib
${CMAKE_SOURCE_DIR}/backends/tsne
)

if (CUDA_FOUND)
list(APPEND COMMON_INCLUDE_DIRS ${CUDA_INCLUDE_DIRS})
Expand Down Expand Up @@ -1116,6 +1145,8 @@ if (USE_HDF5)
endif()

# configure config.cmake for external application
get_directory_property(COMMON_DEFINITIONS COMPILE_DEFINITIONS)

configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/DeepDetectConfig.cmake.in
${CMAKE_BINARY_DIR}/DeepDetectConfig.cmake
Expand Down
3 changes: 2 additions & 1 deletion cmake/DeepDetectConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ if (NOT USE_CPU_ONLY)
endif()

set(DeepDetect_CXX_FLAGS "-fopenmp -pthread")
set(DeepDetect_INCLUDE_DIRS @COMMON_INCLUDE_DIRS@)
set(DeepDetect_DEFINITIONS @COMMON_DEFINITIONS@)
set(DeepDetect_INCLUDE_DIRS @PROJECT_SOURCE_DIR@/src @CMAKE_BINARY_DIR@/src @CMAKE_BINARY_DIR@ @COMMON_INCLUDE_DIRS@ @EIGEN3_INCLUDE_DIR@)
set(DeepDetect_LIBRARY_DIRS @COMMON_LINK_DIRS@ @CMAKE_BINARY_DIR@/src)
set(DeepDetect_LIBRARIES @COMMON_LINK_LIBS@ @HTTP_LIB_DEPS@ @OATPP_LIB_DEPS@)

0 comments on commit a059428

Please sign in to comment.