Github #277 Add option to use shared boost libraries
authorMatthew Bentham <Matthew.Bentham@arm.com>
Thu, 31 Oct 2019 09:55:01 +0000 (09:55 +0000)
committerMatteo Martincigh <matteo.martincigh@arm.com>
Thu, 31 Oct 2019 14:03:23 +0000 (14:03 +0000)
Pass -DSHARED_BOOST=ON to cmake to link dynamically to boost.
This makes it possible to use standard package-installed boost
libraries in a native build.

Change-Id: I6cbd72fae8b0cf8ae07f4382ab0510854c1623fd
Signed-off-by: Matthew Bentham <Matthew.Bentham@arm.com>
cmake/GlobalConfig.cmake

index 2c1989e..af57948 100644 (file)
@@ -22,6 +22,7 @@ option(TF_LITE_GENERATED_PATH "Tensorflow lite generated C++ schema location" OF
 option(FLATBUFFERS_ROOT "Location where the flatbuffers 'include' and 'lib' folders to be found" Off)
 option(DYNAMIC_BACKEND_PATHS "Colon seperated list of paths where to load the dynamic backends from" "")
 option(BUILD_GATORD_MOCK "Build the Gatord simulator for external profiling testing." ON)
+option(SHARED_BOOST "Use dynamic linking for boost libraries" OFF)
 
 include(SelectLibraryConfigurations)
 
@@ -108,8 +109,13 @@ endif()
 set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
 
 # Boost
+if(SHARED_BOOST)
+    add_definitions(-DBOOST_ALL_DYN_LINK)
+    set(Boost_USE_STATIC_LIBS OFF)
+else()
+    set(Boost_USE_STATIC_LIBS ON)
+endif()
 add_definitions("-DBOOST_ALL_NO_LIB") # Turn off auto-linking as we specify the libs manually
-set(Boost_USE_STATIC_LIBS ON)
 find_package(Boost 1.59 REQUIRED COMPONENTS unit_test_framework system filesystem log program_options)
 include_directories(SYSTEM "${Boost_INCLUDE_DIRS}")
 link_directories(${Boost_LIBRARY_DIRS})