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 |
Mike Kelly | f74937e | 2022-05-20 17:18:59 +0100 | [diff] [blame] | 15 | OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/../../generated/ArmnnSchema_generated.h DEPENDS ArmnnSchema.fbs |
| 16 | COMMAND ${FLATC} -o ${CMAKE_CURRENT_SOURCE_DIR}/../../generated --cpp ${CMAKE_CURRENT_SOURCE_DIR}/ArmnnSchema.fbs |
Ruomei Yan | db7c391 | 2019-03-08 17:50:25 +0000 | [diff] [blame] | 17 | ) |
Mike Kelly | f74937e | 2022-05-20 17:18:59 +0100 | [diff] [blame] | 18 | set_property(SOURCE Serializer.cpp APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../../generated/ArmnnSchema_generated.h) |
| 19 | set_directory_properties(PROPERTIES ADDITIONAL_CLEAN_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../../generated/) |
Ruomei Yan | db7c391 | 2019-03-08 17:50:25 +0000 | [diff] [blame] | 20 | |
| 21 | set(armnn_serializer_sources) |
| 22 | list(APPEND armnn_serializer_sources |
| 23 | ../../include/armnnSerializer/ISerializer.hpp |
| 24 | ../../include/armnnDeserializer/IDeserializer.hpp |
Ruomei Yan | db7c391 | 2019-03-08 17:50:25 +0000 | [diff] [blame] | 25 | Serializer.hpp |
| 26 | Serializer.cpp |
| 27 | SerializerUtils.hpp |
| 28 | SerializerUtils.cpp |
| 29 | ../armnnDeserializer/Deserializer.hpp |
| 30 | ../armnnDeserializer/Deserializer.cpp |
| 31 | ) |
| 32 | |
Jim Flynn | 870b96c | 2022-03-25 21:24:56 +0000 | [diff] [blame] | 33 | if(BUILD_BARE_METAL) |
| 34 | add_library_ex(armnnSerializer STATIC ${armnn_serializer_sources}) |
| 35 | else() |
Sadik Armagan | 8f397a1 | 2022-06-17 15:38:22 +0100 | [diff] [blame^] | 36 | # We're going to export both an OBJECT library and a SHARED library here. |
| 37 | # In some instances it's easier to include the serializer directly into |
| 38 | # the target executable or library rather than have yet another .so. |
| 39 | add_library(armnnSerializerObj OBJECT ${armnn_serializer_sources}) |
Jim Flynn | 870b96c | 2022-03-25 21:24:56 +0000 | [diff] [blame] | 40 | add_library_ex(armnnSerializer SHARED ${armnn_serializer_sources}) |
| 41 | endif() |
Ruomei Yan | db7c391 | 2019-03-08 17:50:25 +0000 | [diff] [blame] | 42 | |
| 43 | include_directories(SYSTEM "${FLATBUFFERS_INCLUDE_PATH}") |
Mike Kelly | f74937e | 2022-05-20 17:18:59 +0100 | [diff] [blame] | 44 | |
Ruomei Yan | db7c391 | 2019-03-08 17:50:25 +0000 | [diff] [blame] | 45 | set_target_properties(armnnSerializer PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) |
Sadik Armagan | 8f397a1 | 2022-06-17 15:38:22 +0100 | [diff] [blame^] | 46 | target_include_directories(armnnSerializerObj PRIVATE ../armnn) |
| 47 | target_include_directories(armnnSerializerObj PRIVATE ../armnnUtils) |
Ruomei Yan | db7c391 | 2019-03-08 17:50:25 +0000 | [diff] [blame] | 48 | target_include_directories(armnnSerializer PRIVATE ../armnn) |
| 49 | target_include_directories(armnnSerializer PRIVATE ../armnnUtils) |
Mike Kelly | f74937e | 2022-05-20 17:18:59 +0100 | [diff] [blame] | 50 | target_include_directories(armnnSerializer PRIVATE ../../generated) |
Sadik Armagan | 8f397a1 | 2022-06-17 15:38:22 +0100 | [diff] [blame^] | 51 | target_include_directories(armnnSerializerObj PRIVATE ../../generated) |
Mike Kelly | f74937e | 2022-05-20 17:18:59 +0100 | [diff] [blame] | 52 | |
| 53 | list(APPEND armnn_serializer_sources |
| 54 | ArmnnSchema_generated.h |
| 55 | ) |
Ruomei Yan | db7c391 | 2019-03-08 17:50:25 +0000 | [diff] [blame] | 56 | |
| 57 | # System include to suppress warnings for flatbuffers generated files |
Sadik Armagan | 8f397a1 | 2022-06-17 15:38:22 +0100 | [diff] [blame^] | 58 | target_include_directories(armnnSerializerObj SYSTEM PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) |
Ruomei Yan | db7c391 | 2019-03-08 17:50:25 +0000 | [diff] [blame] | 59 | target_include_directories(armnnSerializer SYSTEM PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) |
| 60 | |
| 61 | target_link_libraries(armnnSerializer armnn ${FLATBUFFERS_LIBRARY}) |
Matthew Bentham | a7b7928 | 2019-06-03 13:00:50 +0100 | [diff] [blame] | 62 | |
Sadik Armagan | 8f397a1 | 2022-06-17 15:38:22 +0100 | [diff] [blame^] | 63 | install(TARGETS armnnSerializerObj |
| 64 | EXPORT armnn-targets |
| 65 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 66 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 67 | ) |
| 68 | |
Matthew Bentham | a7b7928 | 2019-06-03 13:00:50 +0100 | [diff] [blame] | 69 | install(TARGETS armnnSerializer |
Derek Lamberti | eac4adb | 2020-08-25 13:05:59 +0100 | [diff] [blame] | 70 | EXPORT armnn-targets |
| 71 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 72 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 73 | ) |
Matteo Martincigh | bccc345 | 2019-10-18 14:59:19 +0100 | [diff] [blame] | 74 | set_target_properties(armnnSerializer PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} ) |
Matthew Bentham | a7b7928 | 2019-06-03 13:00:50 +0100 | [diff] [blame] | 75 | endif() |