wangg | 5f960d9 | 2020-08-26 01:44:32 +0000 | [diff] [blame] | 1 | # |
| 2 | # Copyright © 2020 Arm Ltd and Contributors. All rights reserved. |
| 3 | # SPDX-License-Identifier: MIT |
| 4 | # |
| 5 | if(BUILD_ARMNN_DESERIALIZER) |
Colm Donelan | 718966f | 2022-10-10 10:06:12 +0100 | [diff] [blame] | 6 | # We're using NO_SYSTEM_ENVIRONMENT_PATH to prevent a system installed |
| 7 | # flatc being found and used. |
wangg | 5f960d9 | 2020-08-26 01:44:32 +0000 | [diff] [blame] | 8 | find_program(FLATC flatc |
| 9 | HINTS ${FLATC_DIR} |
Colm Donelan | 718966f | 2022-10-10 10:06:12 +0100 | [diff] [blame] | 10 | NO_SYSTEM_ENVIRONMENT_PATH |
wangg | 5f960d9 | 2020-08-26 01:44:32 +0000 | [diff] [blame] | 11 | DOC "Path to 'flatc', the flatbuffers compiler") |
Colm Donelan | 718966f | 2022-10-10 10:06:12 +0100 | [diff] [blame] | 12 | |
wangg | 5f960d9 | 2020-08-26 01:44:32 +0000 | [diff] [blame] | 13 | if (NOT FLATC) |
| 14 | message(SEND_ERROR "flatc not found. Specify the full path of the flatc executable with -DFLATC=<flatc path>") |
Colm Donelan | 718966f | 2022-10-10 10:06:12 +0100 | [diff] [blame] | 15 | else() |
| 16 | message("Using flatc was from: ${FLATC}") |
wangg | 5f960d9 | 2020-08-26 01:44:32 +0000 | [diff] [blame] | 17 | endif() |
| 18 | |
| 19 | add_custom_command( |
| 20 | # Generate an ArmnnSchema_generated.h file if it doesn't exist, or update it when necessary otherwise |
Mike Kelly | f74937e | 2022-05-20 17:18:59 +0100 | [diff] [blame] | 21 | OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/../../generated/ArmnnSchema_generated.h DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../armnnSerializer/ArmnnSchema.fbs |
| 22 | COMMAND ${FLATC} -o ${CMAKE_CURRENT_SOURCE_DIR}/../../generated --cpp ${CMAKE_CURRENT_SOURCE_DIR}/../armnnSerializer/ArmnnSchema.fbs |
wangg | 5f960d9 | 2020-08-26 01:44:32 +0000 | [diff] [blame] | 23 | ) |
Mike Kelly | f74937e | 2022-05-20 17:18:59 +0100 | [diff] [blame] | 24 | set_property(SOURCE Deserializer.cpp APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../../generated/ArmnnSchema_generated.h) |
| 25 | set_directory_properties(PROPERTIES ADDITIONAL_CLEAN_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../../generated/) |
wangg | 5f960d9 | 2020-08-26 01:44:32 +0000 | [diff] [blame] | 26 | |
| 27 | set(armnn_deserializer_sources) |
| 28 | list(APPEND armnn_deserializer_sources |
Finn Williams | 85d3671 | 2021-01-26 22:30:06 +0000 | [diff] [blame] | 29 | Deserializer.hpp |
| 30 | Deserializer.cpp |
wangg | 5f960d9 | 2020-08-26 01:44:32 +0000 | [diff] [blame] | 31 | ) |
| 32 | |
| 33 | add_library_ex(armnnDeserializer SHARED ${armnn_deserializer_sources}) |
| 34 | |
| 35 | include_directories(SYSTEM "${FLATBUFFERS_INCLUDE_PATH}") |
Mike Kelly | f74937e | 2022-05-20 17:18:59 +0100 | [diff] [blame] | 36 | |
wangg | 5f960d9 | 2020-08-26 01:44:32 +0000 | [diff] [blame] | 37 | set_target_properties(armnnDeserializer PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) |
| 38 | target_include_directories(armnnDeserializer PRIVATE ../armnn) |
| 39 | target_include_directories(armnnDeserializer PRIVATE ../armnnUtils) |
Mike Kelly | f74937e | 2022-05-20 17:18:59 +0100 | [diff] [blame] | 40 | target_include_directories(armnnDeserializer PRIVATE ../../generated) |
| 41 | |
| 42 | list(APPEND armnn_deserializer_sources |
| 43 | ArmnnSchema_generated.h |
| 44 | ) |
wangg | 5f960d9 | 2020-08-26 01:44:32 +0000 | [diff] [blame] | 45 | |
| 46 | # System include to suppress warnings for flatbuffers generated files |
| 47 | target_include_directories(armnnDeserializer SYSTEM PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) |
| 48 | |
| 49 | target_link_libraries(armnnDeserializer armnn ${FLATBUFFERS_LIBRARY}) |
| 50 | |
| 51 | install(TARGETS armnnDeserializer |
| 52 | EXPORT armnn-targets |
| 53 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 54 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 55 | ) |
| 56 | set_target_properties(armnnDeserializer PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} ) |
| 57 | endif() |