Ruomei Yan | db7c391 | 2019-03-08 17:50:25 +0000 | [diff] [blame] | 1 | # |
| 2 | # Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | # SPDX-License-Identifier: MIT |
| 4 | # |
| 5 | if(BUILD_ARMNN_SERIALIZER) |
Matthew Bentham | 6894718 | 2019-06-10 17:11:31 +0100 | [diff] [blame] | 6 | find_program(FLATC flatc |
| 7 | HINTS ${FLATC_DIR} |
| 8 | DOC "Path to 'flatc', the flatbuffers compiler") |
| 9 | if (NOT FLATC) |
| 10 | message(SEND_ERROR "flatc not found. Specify the full path of the flatc executable with -DFLATC=<flatc path>") |
| 11 | endif() |
| 12 | |
Matteo Martincigh | 286080f | 2019-05-31 13:02:11 +0100 | [diff] [blame] | 13 | add_custom_command( |
| 14 | # Generate an ArmnnSchema_generated.h file if it doesn't exist, or update it when necessary otherwise |
| 15 | OUTPUT ArmnnSchema_generated.h DEPENDS ArmnnSchema.fbs |
Matthew Bentham | 6894718 | 2019-06-10 17:11:31 +0100 | [diff] [blame] | 16 | COMMAND ${FLATC} -o ${CMAKE_CURRENT_BINARY_DIR} --cpp ${CMAKE_CURRENT_SOURCE_DIR}/ArmnnSchema.fbs |
Ruomei Yan | db7c391 | 2019-03-08 17:50:25 +0000 | [diff] [blame] | 17 | ) |
| 18 | |
| 19 | set(armnn_serializer_sources) |
| 20 | list(APPEND armnn_serializer_sources |
| 21 | ../../include/armnnSerializer/ISerializer.hpp |
| 22 | ../../include/armnnDeserializer/IDeserializer.hpp |
| 23 | ArmnnSchema_generated.h |
| 24 | Serializer.hpp |
| 25 | Serializer.cpp |
| 26 | SerializerUtils.hpp |
| 27 | SerializerUtils.cpp |
| 28 | ../armnnDeserializer/Deserializer.hpp |
| 29 | ../armnnDeserializer/Deserializer.cpp |
| 30 | ) |
| 31 | |
| 32 | add_library_ex(armnnSerializer SHARED ${armnn_serializer_sources}) |
| 33 | |
| 34 | include_directories(SYSTEM "${FLATBUFFERS_INCLUDE_PATH}") |
| 35 | set_target_properties(armnnSerializer PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) |
| 36 | target_include_directories(armnnSerializer PRIVATE ../armnn) |
| 37 | target_include_directories(armnnSerializer PRIVATE ../armnnUtils) |
| 38 | |
| 39 | # System include to suppress warnings for flatbuffers generated files |
| 40 | target_include_directories(armnnSerializer SYSTEM PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) |
| 41 | |
| 42 | target_link_libraries(armnnSerializer armnn ${FLATBUFFERS_LIBRARY}) |
Matthew Bentham | a7b7928 | 2019-06-03 13:00:50 +0100 | [diff] [blame] | 43 | |
| 44 | install(TARGETS armnnSerializer |
| 45 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) |
| 46 | endif() |