Support different flatbuffer libs for debug and release
authorRob Hughes <robert.hughes@arm.com>
Tue, 7 Jan 2020 13:26:42 +0000 (13:26 +0000)
committerRob Hughes <robert.hughes@arm.com>
Wed, 15 Jan 2020 16:28:16 +0000 (16:28 +0000)
The existing FLATBUFFERS_LIBRARY variable is still honoured, but if
not specified then we use CMake's find_library to find the debug and release
variants, using PATH_SUFFIXES to help separate debug and release.

This is the same approach we use for the armcompute libs.

Change-Id: I21e8da3f76669dbfb8dbdf49046f9db46cba50a2
Signed-off-by: Robert Hughes <robert.hughes@arm.com>
src/armnnTfLiteParser/CMakeLists.txt

index ae60079..97c55a1 100755 (executable)
@@ -19,7 +19,21 @@ if(BUILD_TF_LITE_PARSER)
     target_include_directories(armnnTfLiteParser SYSTEM PRIVATE "${TF_LITE_SCHEMA_INCLUDE_PATH}")
 
     target_link_libraries(armnnTfLiteParser ${Boost_FILESYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY})
-    target_link_libraries(armnnTfLiteParser armnn ${FLATBUFFERS_LIBRARY})
+
+    # If user has explicitly specified flatbuffers lib then use that,
+    # otherwise search for it based on FLATBUFFERS_BUILD_DIR
+    if (FLATBUFFERS_LIBRARY)
+        target_link_libraries(armnnTfLiteParser armnn ${FLATBUFFERS_LIBRARY})
+    else()
+        # Use PATH_SUFFIXES to help find separate libs for debug/release on Windows builds
+        find_library(FLATBUFFERS_LIBRARY_DEBUG NAMES flatbuffers
+                     HINTS ${FLATBUFFERS_BUILD_DIR}
+                     PATH_SUFFIXES "Debug")
+        find_library(FLATBUFFERS_LIBRARY_RELEASE NAMES flatbuffers
+                     HINTS ${FLATBUFFERS_BUILD_DIR}
+                     PATH_SUFFIXES "Release")
+        target_link_libraries(armnnTfLiteParser armnn debug ${FLATBUFFERS_LIBRARY_DEBUG} optimized ${FLATBUFFERS_LIBRARY_RELEASE})
+    endif()
 
     set_target_properties(armnnTfLiteParser PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} )