Fixed c samples build (#2278)
authorMikhail Ryzhov <mikhail.ryzhov@intel.com>
Thu, 17 Sep 2020 10:51:23 +0000 (13:51 +0300)
committerGitHub <noreply@github.com>
Thu, 17 Sep 2020 10:51:23 +0000 (13:51 +0300)
* Fixed c samples build

fixed CVS-38816 - Failure to build samples in C

* Fixed issue with gflags

inference-engine/ie_bridges/c/samples/common/opencv_c_wraper/CMakeLists.txt [moved from inference-engine/ie_bridges/c/samples/common/CMakeLists.txt with 100% similarity]
inference-engine/ie_bridges/c/samples/common/opencv_c_wraper/opencv_c_wraper.cpp [moved from inference-engine/ie_bridges/c/samples/common/opencv_c_wraper.cpp with 100% similarity]
inference-engine/ie_bridges/c/samples/common/opencv_c_wraper/opencv_c_wraper.h [moved from inference-engine/ie_bridges/c/samples/common/opencv_c_wraper.h with 100% similarity]
inference-engine/samples/CMakeLists.txt

index fbfdf3c..398ce69 100644 (file)
@@ -145,6 +145,8 @@ endif()
 # exactly the same OpenCV_DIR path which was used for the InferenceEngine build
 if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/common/format_reader")
     add_subdirectory(common/format_reader)
+elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/common/opencv_c_wraper")
+    add_subdirectory(common/opencv_c_wraper)
 endif()
 
 # samples build can be switched off during whole IE build
@@ -216,6 +218,7 @@ macro(ie_add_sample)
 
     set(folder_name cpp_samples)
     if(IE_SAMPLE_NAME MATCHES ".*_c$")
+       set(c_sample ON)
         set(folder_name c_samples)
     endif()
 
@@ -228,7 +231,11 @@ macro(ie_add_sample)
     target_include_directories(${IE_SAMPLE_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../common")
 
     target_link_libraries(${IE_SAMPLE_NAME} PRIVATE ${OpenCV_LIBRARIES} ${InferenceEngine_LIBRARIES}
-                                                    ${IE_SAMPLE_DEPENDENCIES} gflags)
+                                                    ${IE_SAMPLE_DEPENDENCIES})
+
+    if(NOT c_sample)
+        target_link_libraries(${IE_SAMPLE_NAME} PRIVATE gflags)
+    endif()
 
     # create global target with all samples / demo apps
     if(NOT TARGET ie_samples)
@@ -237,7 +244,7 @@ macro(ie_add_sample)
     add_dependencies(ie_samples ${IE_SAMPLE_NAME})
 
     if(COMMAND add_cpplint_target AND NOT IE_SAMPLE_EXCLUDE_CPPLINT)
-        if(folder_name STREQUAL "c_samples")
+        if(c_sample)
             set(custom_filters "-readability/casting")
         endif()
         add_cpplint_target(${IE_SAMPLE_NAME}_cpplint FOR_TARGETS ${IE_SAMPLE_NAME}