add build option USE_SYSTEM_PUGIXML (#2502)
authorhelmutg <helmut@subdivi.de>
Mon, 12 Oct 2020 20:24:24 +0000 (22:24 +0200)
committerGitHub <noreply@github.com>
Mon, 12 Oct 2020 20:24:24 +0000 (23:24 +0300)
It allows skipping inference-engine/thirdparty/pugixml and using the
system copy instead.

Thanks to @Osse for helping understand cmake scoping rules.

Co-authored-by: Helmut Grohne <helmut.grohne@intenta.de>
inference-engine/cmake/features_ie.cmake
inference-engine/thirdparty/CMakeLists.txt

index 7194749..b4936f4 100644 (file)
@@ -109,3 +109,5 @@ ie_option(ENABLE_CLANG_FORMAT "Enable clang-format checks during the build" ON)
 set(IE_EXTRA_PLUGINS "" CACHE STRING "Extra paths for plugins to include into DLDT build tree")
 
 ie_dependent_option(ENABLE_TBB_RELEASE_ONLY "Only Release TBB libraries are linked to the Inference Engine binaries" ON "THREADING MATCHES TBB;LINUX" OFF)
+
+ie_option (USE_SYSTEM_PUGIXML "use the system copy of pugixml" OFF)
index a2550bf..86b0dad 100644 (file)
@@ -55,22 +55,31 @@ function(build_with_lto)
         set(BUILD_TESTS ${BUILD_TESTS_current} CACHE BOOL "Build tests" FORCE)
     endfunction()
 
-    ie_build_pugixml()
+    if (USE_SYSTEM_PUGIXML)
+        find_package(PugiXML REQUIRED)
+        set_property(TARGET pugixml PROPERTY IMPORTED_GLOBAL TRUE)
+    else()
+        ie_build_pugixml()
+        target_include_directories(pugixml INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/pugixml/src>")
+    endif()
     add_subdirectory(stb_lib)
     add_subdirectory(ade)
     add_subdirectory(fluid/modules/gapi)
 
-    target_include_directories(pugixml INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/pugixml/src>")
-
-    set_target_properties(pugixml ade fluid stb_image
+    set_target_properties(ade fluid stb_image
                           PROPERTIES FOLDER thirdparty)
 
     # developer package
 
-    ie_developer_export_targets(ade fluid pugixml)
-    if(TARGET pugixml_mt)
-        ie_developer_export_targets(pugixml_mt)
-        set_target_properties(pugixml_mt PROPERTIES FOLDER thirdparty)
+    ie_developer_export_targets(ade fluid)
+
+    if (NOT USE_SYSTEM_PUGIXML)
+        set_target_properties(pugixml PROPERTIES FOLDER thirdparty)
+        ie_developer_export_targets(pugixml)
+        if(TARGET pugixml_mt)
+            ie_developer_export_targets(pugixml_mt)
+            set_target_properties(pugixml_mt PROPERTIES FOLDER thirdparty)
+        endif()
     endif()
 
     if(ENABLE_MKL_DNN)