From 6c9ea2451f23f6ebb2d63a2ba75f7a7319c53cc4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/On-Device=20Lab=28SR=29/Staff?= =?utf8?q?=20Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Fri, 8 Mar 2019 16:01:58 +0900 Subject: [PATCH] Introduce nnapi-header CMake target (#4631) This commit introduces nnapi-header target in CMake, and removes all the occurences of NNFW_INCLUDE_DIR via linking this target instead. Signed-off-by: Jonghyun Park --- CMakeLists.txt | 3 +++ libs/tflite/CMakeLists.txt | 3 ++- runtimes/logging/CMakeLists.txt | 2 +- runtimes/neurun/CMakeLists.txt | 2 +- runtimes/neurun/src/backend/acl_cl/CMakeLists.txt | 2 +- runtimes/neurun/src/backend/acl_cl/kernel/CMakeLists.txt | 2 +- runtimes/neurun/src/backend/cpu/CMakeLists.txt | 2 +- runtimes/neurun/src/backend/cpu/kernel/CMakeLists.txt | 2 +- runtimes/pure_arm_compute/CMakeLists.txt | 2 +- tests/nnapi/CMakeLists.txt | 4 ++-- 10 files changed, 14 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f0b9d03..f9a9f65 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,6 +61,9 @@ nnfw_find_package(GTest QUIET) nnfw_include(ExtendCMakeFunction) +add_library(nnapi-header INTERFACE) +target_include_directories(nnapi-header INTERFACE include) + # TODO For now Android build is being enabled incrementally so not all subdirectories are added yet. # However we are going to have the same subdirectories with other OS eventually. if("${TARGET_OS}" STREQUAL "android") diff --git a/libs/tflite/CMakeLists.txt b/libs/tflite/CMakeLists.txt index f1952a9..e816189 100644 --- a/libs/tflite/CMakeLists.txt +++ b/libs/tflite/CMakeLists.txt @@ -10,7 +10,8 @@ endif(NOT TFLITE_MAJOR_VER OR NOT TFLITE_MINOR_VER) add_library(nnfw_lib_tflite STATIC ${SOURCES}) set_target_properties(nnfw_lib_tflite PROPERTIES POSITION_INDEPENDENT_CODE ON) -target_include_directories(nnfw_lib_tflite PUBLIC ${NNFW_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include) +target_include_directories(nnfw_lib_tflite PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) +target_link_libraries(nnfw_lib_tflite nnapi-header) target_link_libraries(nnfw_lib_tflite tensorflow-lite ${LIB_PTHREAD} dl) target_link_libraries(nnfw_lib_tflite nnfw_lib_misc) target_compile_options(nnfw_lib_tflite PRIVATE -Wall -Wextra -Werror) diff --git a/runtimes/logging/CMakeLists.txt b/runtimes/logging/CMakeLists.txt index 788b943..77791a8 100644 --- a/runtimes/logging/CMakeLists.txt +++ b/runtimes/logging/CMakeLists.txt @@ -1,5 +1,5 @@ file(GLOB_RECURSE NNAPI_LOGGING_SRCS "src/*.cc") add_library(neuralnetworks SHARED ${NNAPI_LOGGING_SRCS}) -target_include_directories(neuralnetworks PUBLIC ${NNFW_INCLUDE_DIR}) target_include_directories(neuralnetworks PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) +target_link_libraries(neuralnetworks PUBLIC nnapi-header) diff --git a/runtimes/neurun/CMakeLists.txt b/runtimes/neurun/CMakeLists.txt index 5b119ee..3ca5316 100644 --- a/runtimes/neurun/CMakeLists.txt +++ b/runtimes/neurun/CMakeLists.txt @@ -29,9 +29,9 @@ file(GLOB_RECURSE SOURCES_MODEL "src/model/*.cc") set(SOURCES ${SOURCES} ${SOURCES_FRONTEND} ${SOURCES_BACKEND} ${SOURCES_GRAPH} ${SOURCES_LINEAR} ${SOURCES_DUMPER} ${SOURCES_COMPILER} ${SOURCES_EXEC} ${SOURCES_VERIFIER} ${SOURCES_UTIL} ${SOURCES_MODEL}) add_library(${LIB_NEURUN} SHARED ${SOURCES}) -target_include_directories(${LIB_NEURUN} PUBLIC ${NNFW_INCLUDE_DIR}) target_include_directories(${LIB_NEURUN} PUBLIC ${NEURUN_INCLUDE_DIR}) target_include_directories(${LIB_NEURUN} PUBLIC ${CMAKE_SOURCE_DIR}/externals/tensorflow) +target_link_libraries(${LIB_NEURUN} nnapi-header) target_link_libraries(${LIB_NEURUN} tensorflow-lite) target_link_libraries(${LIB_NEURUN} nnfw_lib_misc) target_link_libraries(${LIB_NEURUN} nnfw_lib_cpp14) diff --git a/runtimes/neurun/src/backend/acl_cl/CMakeLists.txt b/runtimes/neurun/src/backend/acl_cl/CMakeLists.txt index c7c3273..b778c4c 100644 --- a/runtimes/neurun/src/backend/acl_cl/CMakeLists.txt +++ b/runtimes/neurun/src/backend/acl_cl/CMakeLists.txt @@ -10,9 +10,9 @@ list(REMOVE_ITEM SOURCES ${REMOVE_KERNEL_SOURCES}) add_library(${LIB_NEURUN_BACKEND_ACL_CL} SHARED ${SOURCES}) -target_include_directories(${LIB_NEURUN_BACKEND_ACL_CL} PUBLIC ${NNFW_INCLUDE_DIR}) target_include_directories(${LIB_NEURUN_BACKEND_ACL_CL} PUBLIC ${NEURUN_INCLUDE_DIR}) +target_link_libraries(${LIB_NEURUN_BACKEND_ACL_CL} nnapi-header) target_link_libraries(${LIB_NEURUN_BACKEND_ACL_CL} arm_compute) target_link_libraries(${LIB_NEURUN_BACKEND_ACL_CL} arm_compute_ex) target_link_libraries(${LIB_NEURUN_BACKEND_ACL_CL} ${LIB_NEURUN_KERNEL_ACL_CL}) diff --git a/runtimes/neurun/src/backend/acl_cl/kernel/CMakeLists.txt b/runtimes/neurun/src/backend/acl_cl/kernel/CMakeLists.txt index d78ebb0..7f7709c 100644 --- a/runtimes/neurun/src/backend/acl_cl/kernel/CMakeLists.txt +++ b/runtimes/neurun/src/backend/acl_cl/kernel/CMakeLists.txt @@ -7,9 +7,9 @@ file(GLOB SOURCES "*.cc") add_library(${LIB_NEURUN_KERNEL_ACL_CL} STATIC ${SOURCES}) -target_include_directories(${LIB_NEURUN_KERNEL_ACL_CL} PUBLIC ${NNFW_INCLUDE_DIR}) target_include_directories(${LIB_NEURUN_KERNEL_ACL_CL} PUBLIC ${NEURUN_INCLUDE_DIR}) +target_link_libraries(${LIB_NEURUN_KERNEL_ACL_CL} nnapi-header) target_link_libraries(${LIB_NEURUN_KERNEL_ACL_CL} arm_compute) target_link_libraries(${LIB_NEURUN_KERNEL_ACL_CL} nnfw_lib_misc) diff --git a/runtimes/neurun/src/backend/cpu/CMakeLists.txt b/runtimes/neurun/src/backend/cpu/CMakeLists.txt index e5bbdb9..1483184 100644 --- a/runtimes/neurun/src/backend/cpu/CMakeLists.txt +++ b/runtimes/neurun/src/backend/cpu/CMakeLists.txt @@ -11,10 +11,10 @@ list(REMOVE_ITEM SOURCES ${REMOVE_KERNEL_SOURCES}) add_library(${LIB_NEURUN_BACKEND_CPU} SHARED ${SOURCES}) -target_include_directories(${LIB_NEURUN_BACKEND_CPU} PUBLIC ${NNFW_INCLUDE_DIR}) target_include_directories(${LIB_NEURUN_BACKEND_CPU} PUBLIC ${NEURUN_INCLUDE_DIR}) target_include_directories(${LIB_NEURUN_BACKEND_CPU} PUBLIC ${CMAKE_SOURCE_DIR}/externals/tensorflow) +target_link_libraries(${LIB_NEURUN_BACKEND_CPU} nnapi-header) target_link_libraries(${LIB_NEURUN_BACKEND_CPU} tensorflow-lite) target_link_libraries(${LIB_NEURUN_BACKEND_CPU} nnfw_lib_misc) target_link_libraries(${LIB_NEURUN_BACKEND_CPU} nnfw_lib_cpp14) diff --git a/runtimes/neurun/src/backend/cpu/kernel/CMakeLists.txt b/runtimes/neurun/src/backend/cpu/kernel/CMakeLists.txt index 436cb89..6617d62 100644 --- a/runtimes/neurun/src/backend/cpu/kernel/CMakeLists.txt +++ b/runtimes/neurun/src/backend/cpu/kernel/CMakeLists.txt @@ -2,10 +2,10 @@ file(GLOB SOURCES "*.cc") add_library(${LIB_NEURUN_KERNEL_CPU} STATIC ${SOURCES}) -target_include_directories(${LIB_NEURUN_KERNEL_CPU} PUBLIC ${NNFW_INCLUDE_DIR}) target_include_directories(${LIB_NEURUN_KERNEL_CPU} PUBLIC ${NEURUN_INCLUDE_DIR}) target_include_directories(${LIB_NEURUN_KERNEL_CPU} PUBLIC ${CMAKE_SOURCE_DIR}/externals/tensorflow) +target_link_libraries(${LIB_NEURUN_KERNEL_CPU} nnapi-header) target_link_libraries(${LIB_NEURUN_KERNEL_CPU} tensorflow-lite) target_link_libraries(${LIB_NEURUN_KERNEL_CPU} nnfw_lib_misc) diff --git a/runtimes/pure_arm_compute/CMakeLists.txt b/runtimes/pure_arm_compute/CMakeLists.txt index 2a26a7b..9645e09 100644 --- a/runtimes/pure_arm_compute/CMakeLists.txt +++ b/runtimes/pure_arm_compute/CMakeLists.txt @@ -9,11 +9,11 @@ file(GLOB_RECURSE SOURCES "src/*.cc") add_library(nnapi_pure_arm_compute SHARED ${SOURCES}) # To ignore compiler warnings from ARM Compute Library target_compile_options(nnapi_pure_arm_compute PRIVATE -Wno-ignored-attributes) -target_include_directories(nnapi_pure_arm_compute PUBLIC ${NNFW_INCLUDE_DIR}) target_include_directories(nnapi_pure_arm_compute PUBLIC src) if(BUILD_TFLITE_BENCHMARK_MODEL) target_compile_definitions(nnapi_pure_arm_compute PUBLIC "TFLITE_PROFILING_ENABLED") endif() +target_link_libraries(nnapi_pure_arm_compute nnapi-header) target_link_libraries(nnapi_pure_arm_compute arm_compute arm_compute_ex) target_link_libraries(nnapi_pure_arm_compute nnfw_lib_cpp14 nnfw_lib_misc nnfw_lib_profiling) diff --git a/tests/nnapi/CMakeLists.txt b/tests/nnapi/CMakeLists.txt index 434266f..4641d98 100644 --- a/tests/nnapi/CMakeLists.txt +++ b/tests/nnapi/CMakeLists.txt @@ -30,8 +30,7 @@ add_executable(${RUNTIME_NNAPI_TEST} ${RUNTIME_NNAPI_TEST_SRC}) nnfw_find_package(GTest) -set(RUNTIME_NNAPI_TEST_SRC_INC ${NNFW_INCLUDE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include +set(RUNTIME_NNAPI_TEST_SRC_INC ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/src) target_include_directories(${RUNTIME_NNAPI_TEST} PRIVATE ${RUNTIME_NNAPI_TEST_SRC_INC}) @@ -40,6 +39,7 @@ if (BUILD_NEURUN) elseif (BUILD_PURE_ARM_COMPUTE) set(SKIPLIST_FILE_NAME ${RUNTIME_NNAPI_TEST}.skip.${TARGET_PLATFORM}) endif() +target_link_libraries(${RUNTIME_NNAPI_TEST} nnapi-header) target_link_libraries(${RUNTIME_NNAPI_TEST} gtest) target_link_libraries(${RUNTIME_NNAPI_TEST} ${LIB_PTHREAD} dl) -- 2.7.4