Skip to content

OpenCVConfig.cmake: issue with imported target configuration remapping #10105

Closed

Description

@rokm

For development and debugging on linux, I tend to build OpenCV in RelWithDebInfo mode for use with my projects, which are also build in RelWithDebInfo mode.

Since commit 2d0611b, the above setup is broken; the projects that use OpenCV configure without errors, but the build fails with:

make[2]: *** No rule to make target 'opencv_core-NOTFOUND', needed by 'program-name'.  Stop

This is because RelWithDebInfo imported targets are now mapped to Release, which does not exist in this case (as OpenCV was also built in RelWithDebInfo mode).

The comment added to OpenCVConfig.cmake by 2d0611b states that "OpenCV supports Debug and Release only". This is not the always the case, as building OpenCV in RelWithDebInfo on linux results in build that generates OpenCVModules-relwithdebinfo.cmake.

Therefore, the remapping should be done only if the requested configuration does not actually exist, or it should be limited to platforms/toolchains where it is known that RelWithDebInfo and MinSizeRel are not supported (presumably Visual Studio?).

@bblanchon, as the author of the change, can you comment?

Activity

  1. alalek commented on Nov 17, 2017

    @alalek
    Member

    OpenCV doesn't support other build configurations than Debug/Release. So OpenCV dev team would not work on this issue, but you can propose PR for this (but it should be simple enough).
    Mentioned patch is to support building of user applications (with MSVS at first) with OpenCV binaries which are available in Debug/Release configurations only.

  2. bblanchon commented on Nov 17, 2017

    @bblanchon
    Contributor

    @rokm, I'm afraid I won't be able to help here.
    To be honest, I'm not sure how it worked before the patch, as only IMPORTED_CONFIGURATIONS only contains DEBUG and RELEASE.

  3. rokm commented on Nov 17, 2017

    @rokm
    ContributorAuthor

    @alalek, thanks for clarification. So the support is meant as in official developers' support as opposed to a technical limitation.

    Still, I would consider this change a regression for linux, because:

    a) as before, nothing really prevents one from building OpenCV with cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ... (except the knowledge that they're on their own w.r.t. support)

    The CMAKE_CONFIGURATION_TYPES line does not seem to have any effect; one still gets a RelWithDebInfo build, with OpenCVModules-relwithdebinfo.cmake and debug symbols in the libraries, as expected. And without any indication that the configuration may be problematic.

    NOTE: on linux, prior to the change, and with default CMake configuration (i.e., without additional remap rules), an application has no problems building against such a build, regardless if application itself is being built in Release, Debug, or RelWithDebInfo mode.

    b) when building an application against such a build, again no indication is given by CMake that the configuration may be problematic, until the (rather cryptic) make error

    The change seems to be addressing a MSVS-specific issue (#5564), which arises from the fact that release and debug version of libraries can exist side-by-side in the same OpenCV installation. As such, would you be opposed to making it MSVS-specific as per original suggestion?

  4. alalek commented on Nov 17, 2017

    @alalek
    Member

    Actually this problem is not Linux specific, so MSVS is affected too.

    Perhaps it is better to grab IMPORTED_CONFIGURATIONS from target and to check for missing exotic configurations (case-insensitive check).
    If it is missing then register mapping.

    ... get property from ${__cvcomponent} target ...
    if (NOT ";${CONFIGURATIONS};" MATCHES ";[Rr][Ee][Ll][Ww][iI][Tt][Hh][Dd][Ee][Bb][Ii][Nn][Ff][Oo];")
      set_target_properties(${__cvcomponent} PROPERTIES
          MAP_IMPORTED_CONFIG_RELWITHDEBINFO "Release"
      )
    endif()
    if (NOT ";${CONFIGURATIONS};" MATCHES ";...other case...;")
      set_target_properties(${__cvcomponent} PROPERTIES
          MAP_IMPORTED_CONFIG_MINSIZEREL "Release"
      )
    endif()
    
  5. tfoote commented on Dec 12, 2017

    @tfoote

    @alalek Although OpenCV does not support building with RelWithDebInfo this is breaking downstream builds which try to link against OpenCV using the OpenCVConfig.cmake generated and they are building their software with RelWithDebInfo

    We have several users having trouble here: ros-perception/vision_opencv#193

    I'd like to suggest removing the wontfix tag and pushing this up the triage priority.

    @bblanchon I have several users confirming reverting the change in #9656 fixes their builds: ros-perception/vision_opencv#193 @pjreed @tdenwiler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions