Repository: conan-io/conan-center-index

Issue:
[package] OpenCV/4.5.5: LNK1104 opencv_xobjdetect455
<!-- 
  Please don't forget to update the issue title.
  Include all applicable information to help us reproduce your problem.
-->

### Package and Environment Details (include every applicable attribute)
  * Package Name/Version: **opencv/4.5.5**
  * Operating System+version: **Microsoft Windows Server 2019 Standard Evaluation 10.0.17763 N/A Build 17763**
  * Compiler+version: **Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30143 for x64**
  * Conan version: **conan 1.47.0**
  * Python version: **Python 3.10.4**


### Conan profile (output of `conan profile show default` or `conan profile show <profile>` if custom profile is in use)
```
arch=x86_64
arch_build=x86_64
build_type=Debug
compiler=Visual Studio
compiler.runtime=MDd
compiler.version=16
os=Windows
os_build=Windows
```


### Steps to reproduce (Include if Applicable)
conanfile:
```
[requires]
opencv/4.5.5

[options]
opencv:contrib=True
opencv:with_ffmpeg=False
opencv:dnn=False
opencv:with_ade=False

[generators]
cmake_find_package
```
cmake:
```
find_package(OpenCV REQUIRED)
add_executable(plot plot_demo.cpp)

# Use the global target
target_link_libraries(plot opencv::opencv)
```
plot_demo.cpp: https://raw.githubusercontent.com/opencv/opencv_contrib/master/modules/plot/samples/plot_demo.cpp

### Logs (Include/Attach if Applicable)
<details><summary>Click to expand log</summary>

```
Linking CXX executable C:\Users\user\source\project\bin\plot.exe
FAILED: C:/Users/user/source/project/bin/plot.exe 
cmd.exe /C "cd . && C:\Qt\Tools\CMake_64\bin\cmake.exe -E vs_link_exe --intdir=services\lobe_binary_accessor\CMakeFiles\plot.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100190~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100190~1.0\x64\mt.exe --manifests  -- C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\plot.rsp  /out:C:\Users\user\source\project\bin\plot.exe /implib:services\lobe_binary_accessor\plot.lib /pdb:C:\Users\user\source\project\bin\plot.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console  && cd ."
LINK Pass 1: command "C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\plot.rsp /out:C:\Users\user\source\project\bin\plot.exe /implib:services\lobe_binary_accessor\plot.lib /pdb:C:\Users\user\source\project\bin\plot.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console /MANIFEST /MANIFESTFILE:services\lobe_binary_accessor\CMakeFiles\plot.dir/intermediate.manifest services\lobe_binary_accessor\CMakeFiles\plot.dir/manifest.res" failed (exit code 1104) with the following output:
LINK : fatal error LNK1104: cannot open file 'opencv_xobjdetect455d.lib'
ninja: build stopped: subcommand failed.
```

</details>



Discussion:
```cmake
get_target_property(OUT opencv::opencv_xobjdetect INTERFACE_LINK_LIBRARIES)
message(STATUS ${OUT})

message(STATUS ${opencv_LIBRARY_LIST})
message(STATUS ${opencv_LIB_DIRS})

file(GLOB CVPLOT_LIB_FILES ${opencv_LIB_DIRS}/*.lib)
message(STATUS ${CVPLOT_LIB_FILES})
```
OUT:
```
opencv_xobjdetect455dopencv::opencv_coreopencv::opencv_flannopencv::opencv_imgprocopencv::opencv_features2dopencv::opencv_imgcodecsopencv::opencv_calib3dopencv::opencv_objdetectEigen3::Eigen3$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:>$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,MODULE_LIBRARY>:>$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:>
```
opencv_LIBRARY_LIST:
```
opencv_stitching455dopencv_quality455dopencv_reg455dopencv_surface_matching455dopencv_xphoto455dopencv_fuzzy455dopencv_hfs455dopencv_img_hash455dopencv_line_descriptor455dopencv_saliency455dopencv_rgbd455dopencv_structured_light455dopencv_phase_unwrapping455dopencv_videostab455dopencv_xfeatures2d455dopencv_shape455dopencv_xobjdetect455dopencv_aruco455dopencv_bgsegm455dopencv_bioinspired455dopencv_ccalib455dopencv_dpm455dopencv_highgui455dopencv_face455dopencv_photo455dopencv_objdetect455dopencv_superres455dopencv_videoio455dopencv_optflow455dopencv_ximgproc455dopencv_stereo455dopencv_tracking455dopencv_video455dopencv_plot455dopencv_datasets455dopencv_ml455dopencv_imgcodecs455dopencv_intensity_transform455dopencv_alphamat455dopencv_rapid455dopencv_calib3d455dopencv_features2d455dopencv_flann455dopencv_imgproc455dopencv_core455d
```
opencv_LIB_DIRS:
```
-- C:/.conan/99cb87/1/lib
```
CVPLOT_LIB_FILES:
```
-- C:/.conan/99cb87/1/lib/opencv_alphamat455d.libC:/.conan/99cb87/1/lib/opencv_aruco455d.libC:/.conan/99cb87/1/lib/opencv_bgsegm455d.libC:/.conan/99cb87/1/lib/opencv_bioinspired455d.libC:/.conan/99cb87/1/lib/opencv_calib3d455d.libC:/.conan/99cb87/1/lib/opencv_ccalib455d.libC:/.conan/99cb87/1/lib/opencv_core455d.libC:/.conan/99cb87/1/lib/opencv_datasets455d.libC:/.conan/99cb87/1/lib/opencv_features2d455d.libC:/.conan/99cb87/1/lib/opencv_flann455d.libC:/.conan/99cb87/1/lib/opencv_fuzzy455d.libC:/.conan/99cb87/1/lib/opencv_hfs455d.libC:/.conan/99cb87/1/lib/opencv_highgui455d.libC:/.conan/99cb87/1/lib/opencv_img_hash455d.libC:/.conan/99cb87/1/lib/opencv_imgcodecs455d.libC:/.conan/99cb87/1/lib/opencv_imgproc455d.libC:/.conan/99cb87/1/lib/opencv_intensity_transform455d.libC:/.conan/99cb87/1/lib/opencv_line_descriptor455d.libC:/.conan/99cb87/1/lib/opencv_ml455d.libC:/.conan/99cb87/1/lib/opencv_optflow455d.libC:/.conan/99cb87/1/lib/opencv_phase_unwrapping455d.libC:/.conan/99cb87/1/lib/opencv_photo455d.libC:/.conan/99cb87/1/lib/opencv_plot455d.libC:/.conan/99cb87/1/lib/opencv_quality455d.libC:/.conan/99cb87/1/lib/opencv_rapid455d.libC:/.conan/99cb87/1/lib/opencv_reg455d.libC:/.conan/99cb87/1/lib/opencv_rgbd455d.libC:/.conan/99cb87/1/lib/opencv_saliency455d.libC:/.conan/99cb87/1/lib/opencv_shape455d.libC:/.conan/99cb87/1/lib/opencv_stereo455d.libC:/.conan/99cb87/1/lib/opencv_stitching455d.libC:/.conan/99cb87/1/lib/opencv_structured_light455d.libC:/.conan/99cb87/1/lib/opencv_superres455d.libC:/.conan/99cb87/1/lib/opencv_surface_matching455d.libC:/.conan/99cb87/1/lib/opencv_tracking455d.libC:/.conan/99cb87/1/lib/opencv_video455d.libC:/.conan/99cb87/1/lib/opencv_videoio455d.libC:/.conan/99cb87/1/lib/opencv_videostab455d.libC:/.conan/99cb87/1/lib/opencv_xfeatures2d455d.libC:/.conan/99cb87/1/lib/opencv_ximgproc455d.libC:/.conan/99cb87/1/lib/opencv_xphoto455d.lib
```
opencv_xobjdetect contains interface linked library opencv_xobjdetect455 but opencv_LIB_DIR doesn't contain related .lib file. Looks like imported non-built target.

Try to rebuild opencv: https://pastebin.com/XXjvDmSB
```
--   OpenCV modules:
--     To be built:                 alphamat aruco bgsegm bioinspired calib3d ccalib core datasets features2d flann fuzzy hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor ml optflow phase_unwrapping photo plot quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching tracking video videoio videostab xfeatures2d ximgproc xphoto
--     Disabled:                    python_tests world
--     Disabled by dependency:      barcode dnn_objdetect dnn_superres dpm face mcc objdetect text wechat_qrcode xobjdetect
```
xobjdetect was disabled but imported target was created (same for objdetect)

Problem is here https://github.com/opencv/opencv/blob/ed6ca0d7fab5381c6aa6062c49c3c99ee828fadb/modules/objdetect/CMakeLists.txt#L7 but dnn is optional. I don't understand why objdetect cannot be build without dnn.

Resolving patch:
diff --git a/recipes/opencv/4.x/conanfile.py b/recipes/opencv/4.x/conanfile.py
--- a/recipes/opencv/4.x/conanfile.py
+++ b/recipes/opencv/4.x/conanfile.py
@@ -637,7 +637,6 @@ def ipp():
                 + eigen() + ffmpeg() + ipp())},
             {"target": "opencv_calib3d",    "lib": "calib3d",    "requires": ["opencv_core", "opencv_flann", "opencv_imgproc", "opencv_features2d"]+ eigen() + ipp()},
             {"target": "opencv_highgui",    "lib": "highgui",    "requires": ["opencv_core", "opencv_imgproc", "opencv_imgcodecs", "opencv_videoio"] + freetype() + eigen() + gtk() + ipp()},
-            {"target": "opencv_objdetect",  "lib": "objdetect",  "requires": ["opencv_core", "opencv_flann", "opencv_imgproc", "opencv_features2d", "opencv_calib3d"] + eigen() + quirc() + ipp()},
             {"target": "opencv_stitching",  "lib": "stitching",  "requires": ["opencv_core", "opencv_flann", "opencv_imgproc", "opencv_features2d", "opencv_calib3d"] + xfeatures2d() + eigen() + ipp()},
             {"target": "opencv_video",      "lib": "video",      "requires": ["opencv_core", "opencv_flann", "opencv_imgproc", "opencv_features2d", "opencv_calib3d"] + eigen() + ipp()},
         ]
@@ -648,7 +647,9 @@ def ipp():
 
         if self.options.dnn:
             opencv_components.extend([
-                {"target": "opencv_dnn", "lib": "dnn", "requires": ["opencv_core", "opencv_imgproc"] + protobuf() + ipp()}
+                {"target": "opencv_dnn", "lib": "dnn", "requires": ["opencv_core", "opencv_imgproc"] + protobuf() + ipp()},
+                {"target": "opencv_objdetect",  "lib": "objdetect",  "requires": ["opencv_core", "opencv_flann", "opencv_imgproc", "opencv_features2d", "opencv_calib3d"] + eigen() + quirc() + ipp()},
+
             ])
         if self.options.contrib:
             opencv_components.extend([
@@ -670,18 +671,21 @@ def ipp():
                 {"target": "opencv_videostab",           "lib": "videostab",           "requires": ["opencv_core", "opencv_flann", "opencv_imgproc", "opencv_photo", "opencv_features2d", "opencv_imgcodecs", "opencv_videoio", "opencv_calib3d", "opencv_video"] + eigen() + ipp()},
                 {"target": "opencv_xfeatures2d",         "lib": "xfeatures2d",         "requires": ["opencv_core", "opencv_flann", "opencv_imgproc", "opencv_ml", "opencv_features2d", "opencv_calib3d", "opencv_shape", ] + eigen() + ipp()},
                 {"target": "opencv_ximgproc",            "lib": "ximgproc",            "requires": ["opencv_core", "opencv_flann", "opencv_imgproc", "opencv_features2d", "opencv_imgcodecs", "opencv_calib3d", "opencv_video"] + eigen() + ipp()},
-                {"target": "opencv_xobjdetect",          "lib": "xobjdetect",          "requires": ["opencv_core", "opencv_flann", "opencv_imgproc", "opencv_features2d", "opencv_imgcodecs", "opencv_calib3d", "opencv_objdetect"] + eigen() + ipp()},
                 {"target": "opencv_aruco",               "lib": "aruco",               "requires": ["opencv_core", "opencv_flann", "opencv_imgproc", "opencv_features2d", "opencv_imgcodecs", "opencv_calib3d"] + eigen() + ipp()},
                 {"target": "opencv_bgsegm",              "lib": "bgsegm",              "requires": ["opencv_core", "opencv_flann", "opencv_imgproc", "opencv_features2d", "opencv_calib3d", "opencv_video"] + eigen() + ipp()},
                 {"target": "opencv_bioinspired",         "lib": "bioinspired",         "requires": ["opencv_core", "opencv_imgproc", "opencv_imgcodecs", "opencv_videoio", "opencv_highgui"] + eigen() + ipp()},
                 {"target": "opencv_ccalib",              "lib": "ccalib",              "requires": ["opencv_core", "opencv_flann", "opencv_imgproc", "opencv_features2d", "opencv_imgcodecs", "opencv_videoio", "opencv_calib3d", "opencv_highgui"] + eigen() + ipp()},
-                {"target": "opencv_dpm",                 "lib": "dpm",                 "requires": ["opencv_core", "opencv_flann", "opencv_imgproc", "opencv_features2d", "opencv_imgcodecs", "opencv_videoio", "opencv_calib3d", "opencv_highgui", "opencv_objdetect"] + eigen() + ipp()},
-                {"target": "opencv_face",                "lib": "face",                "requires": ["opencv_core", "opencv_flann", "opencv_imgproc", "opencv_photo", "opencv_features2d", "opencv_calib3d", "opencv_objdetect"] + eigen() + ipp()},
                 {"target": "opencv_optflow",             "lib": "optflow",             "requires": ["opencv_core", "opencv_flann", "opencv_imgproc", "opencv_video", "opencv_features2d", "opencv_imgcodecs", "opencv_calib3d", "opencv_video", "opencv_ximgproc"] + eigen() + ipp()},
                 {"target": "opencv_superres",            "lib": "superres",            "requires": ["opencv_core", "opencv_flann", "opencv_imgproc", "opencv_features2d", "opencv_imgcodecs", "opencv_videoio", "opencv_calib3d", "opencv_video", "opencv_ximgproc", "opencv_optflow"] + eigen() + ipp()},
                 {"target": "opencv_tracking",            "lib": "tracking",            "requires": ["opencv_core", "opencv_flann", "opencv_imgproc", "opencv_ml", "opencv_plot", "opencv_features2d", "opencv_imgcodecs", "opencv_calib3d", "opencv_datasets", "opencv_video"] + eigen() + ipp()},
                 {"target": "opencv_stereo",              "lib": "stereo",              "requires": ["opencv_core", "opencv_flann", "opencv_imgproc", "opencv_ml", "opencv_plot", "opencv_features2d", "opencv_imgcodecs", "opencv_calib3d", "opencv_datasets", "opencv_video", "opencv_tracking"] + eigen() + ipp()},
             ])
+            if self.options.dnn:
+                opencv_components.extend([
+                    {"target": "opencv_xobjdetect",          "lib": "xobjdetect",          "requires": ["opencv_core", "opencv_flann", "opencv_imgproc", "opencv_features2d", "opencv_imgcodecs", "opencv_calib3d", "opencv_objdetect"] + eigen() + ipp()},
+                    {"target": "opencv_dpm",                 "lib": "dpm",                 "requires": ["opencv_core", "opencv_flann", "opencv_imgproc", "opencv_features2d", "opencv_imgcodecs", "opencv_videoio", "opencv_calib3d", "opencv_highgui", "opencv_objdetect"] + eigen() + ipp()},
+                    {"target": "opencv_face",                "lib": "face",                "requires": ["opencv_core", "opencv_flann", "opencv_imgproc", "opencv_photo", "opencv_features2d", "opencv_calib3d", "opencv_objdetect"] + eigen() + ipp()}
+                ])
             if self.version >= "4.3.0":
                 opencv_components.extend([
                     {"target": "opencv_intensity_transform", "lib": "intensity_transform", "requires": ["opencv_core", "opencv_imgproc"] + eigen() + ipp()},


Test patch: