Skip to content

Commit

Permalink
Update Config.cmake.in and so on
Browse files Browse the repository at this point in the history
  • Loading branch information
daquexian committed May 24, 2019
1 parent 34b5fa2 commit 6ea82ea
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .daq_pm/configs/all-27
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
name DNNLibrary
type cpp
build_dir build-all-v27
cmake_options -DCMAKE_TOOLCHAIN_FILE=~/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-27 -DANDROID_ABI=arm64-v8a -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -GNinja
cmake_options -DCMAKE_TOOLCHAIN_FILE=~/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-27 -DANDROID_ABI=arm64-v8a -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -GNinja -DDNN_READ_ONNX=ON -DDNN_CUSTOM_PROTOC_EXECUTABLE=/usr/bin/protoc
2 changes: 1 addition & 1 deletion .daq_pm/configs/infer
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name DNNLibrary
type cpp
target dnn_retrieve_result
build_dir build
build_dir build_infer
cmake_options -DCMAKE_SYSTEM_NAME=Android -DCMAKE_TOOLCHAIN_FILE=~/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_CPP_FEATURES=exceptions -DANDROID_PLATFORM=android-28 -DANDROID_ABI=arm64-v8a -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
program_arguments ~/adb_push_and_run.sh binaries/dnn_retrieve_result
2 changes: 1 addition & 1 deletion .daq_pm/configs/onnx_infer
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ name DNNLibrary
type cpp
target dnn_retrieve_result
build_dir build_onnxinfer
cmake_options -DCMAKE_SYSTEM_NAME=Android -DCMAKE_TOOLCHAIN_FILE=~/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_CPP_FEATURES=exceptions -DANDROID_PLATFORM=android-28 -DANDROID_ABI=arm64-v8a -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DDNN_READ_ONNX=ON -DONNX_CUSTOM_PROTOC_EXECUTABLE=/usr/bin/protoc
cmake_options -DCMAKE_SYSTEM_NAME=Android -DCMAKE_TOOLCHAIN_FILE=~/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_CPP_FEATURES=exceptions -DANDROID_PLATFORM=android-28 -DANDROID_ABI=arm64-v8a -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DDNN_READ_ONNX=ON -DDNN_CUSTOM_PROTOC_EXECUTABLE=/usr/bin/protoc
program_arguments ~/adb_push_and_run.sh binaries/dnn_retrieve_result
18 changes: 18 additions & 0 deletions cmake/DNNLibraryConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
get_filename_component(DNNLibrary_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)

if (@DNN_READ_ONNX@)
if (NOT TARGET protobuf::libprotobuf)
find_package(Protobuf REQUIRED)
endif()
if (NOT TARGET onnx)
find_package(ONNX REQUIRED)
endif()
endif()

if (NOT TARGET glog::glog)
find_package(glog REQUIRED)
endif()

if (NOT TARGET dnnlibrary::dnnlibrary)
include("${DNNLibrary_CMAKE_DIR}/DNNLibraryTargets.cmake")
endif()
17 changes: 17 additions & 0 deletions cmake/ONNX2daqConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
get_filename_component(ONNX2daq_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)

if (NOT TARGET protobuf::libprotobuf)
find_package(Protobuf REQUIRED)
endif()

if (NOT TARGET onnx)
find_package(ONNX REQUIRED)
endif()

if (NOT TARGET glog::glog)
find_package(glog REQUIRED)
endif()

if (NOT TARGET dnnlibrary::onnx2daq)
include("${ONNX2daq_CMAKE_DIR}/ONNX2daqTargets.cmake")
endif()
2 changes: 1 addition & 1 deletion cmake/onnx.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ macro(configure_onnx)
endif()
set(ONNX_BUILD_MAIN_LIB ON)
set(ONNX_NAMESPACE ${DAQ_ONNX_NAMESPACE} CACHE STRING "onnx namespace")
if (NOT EXISTS ${DNN_CUSTOM_PROTOC_EXECUTABLE})
if (${CMAKE_SYSTEM_NAME} STREQUAL "Android" AND NOT EXISTS ${DNN_CUSTOM_PROTOC_EXECUTABLE})
message(FATAL ERROR "DNN_CUSTOM_PROTOC_EXECUTABLE is not set or wrong.")
endif()
set(ONNX_CUSTOM_PROTOC_EXECUTABLE ${DNN_CUSTOM_PROTOC_EXECUTABLE})
Expand Down
2 changes: 1 addition & 1 deletion cmake/protobuf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ macro(configure_protobuf)
option(protobuf_BUILD_PROTOC_BINARIES "" ON)
endif()
add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/protobuf/cmake)
if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Android")
if (protobuf_BUILD_PROTOC_BINARIES)
add_executable(protobuf::protoc ALIAS protoc)
endif()
add_library(protobuf::libprotobuf ALIAS libprotobuf)
Expand Down
18 changes: 17 additions & 1 deletion dnnlibrary/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ else()
treat_warnings_as_errors(dnnlibrary)
endif()


install(TARGETS dnnlibrary
EXPORT DNNLibraryTargets)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/
DESTINATION include)

if (DNN_BUILD_JNI)
add_library(
Expand All @@ -83,4 +86,17 @@ if (DNN_BUILD_JNI)
src/JavaWrapper.cpp)
target_link_libraries(daq-jni
dnnlibrary)
install(TARGETS daq-jni
EXPORT DNNLibraryTargets)
endif()

install(EXPORT DNNLibraryTargets
NAMESPACE dnnlibrary::
DESTINATION share/cmake/DNNLibrary
)

configure_file("${PROJECT_SOURCE_DIR}/cmake/DNNLibraryConfig.cmake.in"
"${PROJECT_BINARY_DIR}/cmake/DNNLibraryConfig.cmake"
@ONLY)

install(FILES "${PROJECT_BINARY_DIR}/cmake/DNNLibraryConfig.cmake" DESTINATION share/cmake/DNNLibrary)
26 changes: 26 additions & 0 deletions tools/onnx2daq/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,19 @@ if (${DNN_SYSTEM_PROTOBUF})
treat_warnings_as_errors(onnx2daq)
endif()

if (CMAKE_SYSTEM_NAME STREQUAL "Android")
# Build DNNLibrary (on Android)
install(TARGETS onnx2daq
EXPORT DNNLibraryTargets)
else()
# Build onnx2daq (on non-Android)
install(TARGETS onnx2daq
EXPORT ONNX2daqTargets)
endif()


if (NOT ONNX2DAQ_ONLY_LIB)
# Build onnx2daq-bin (on non-Android)
add_executable(onnx2daq-bin
${CMAKE_CURRENT_SOURCE_DIR}/onnx2daq.cpp)
target_link_libraries(onnx2daq-bin
Expand All @@ -39,6 +50,8 @@ if (NOT ONNX2DAQ_ONLY_LIB)
treat_warnings_as_errors(onnx2daq-bin)
endif()
set_target_properties(onnx2daq-bin PROPERTIES OUTPUT_NAME "onnx2daq")
install(TARGETS onnx2daq-bin
EXPORT ONNX2daqTargets)

if (${DNN_BUILD_PYTHON})
pybind11_add_module(_onnx2daq ${CMAKE_CURRENT_SOURCE_DIR}/pywrapper.cpp)
Expand All @@ -53,3 +66,16 @@ if (NOT ONNX2DAQ_ONLY_LIB)
)
endif()
endif()

if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Android")
install(EXPORT ONNX2daqTargets
NAMESPACE dnnlibrary::
DESTINATION share/cmake/ONNX2daq
)

configure_file("${PROJECT_SOURCE_DIR}/cmake/ONNX2daqConfig.cmake.in"
"${PROJECT_BINARY_DIR}/cmake/ONNX2daqConfig.cmake"
@ONLY)

install(FILES "${PROJECT_BINARY_DIR}/cmake/ONNX2daqConfig.cmake" DESTINATION share/cmake/ONNX2daq)
endif()

0 comments on commit 6ea82ea

Please sign in to comment.