You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
OpenCVConfig.cmake: issue with imported target configuration remapping #10105
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?
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.
@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.
@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?
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()
@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
Reacted by P. J. Reed, Robert Hafner, Thomas Denewiler, Paul Dinh, randoms, Patrick Beeson, Andrew Price, Parker Lusk, Ted Steiner and Aleksei Petrenko
Activity
alalek commentedon Nov 17, 2017
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.
bblanchon commentedon Nov 17, 2017
@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_CONFIGURATIONSonly containsDEBUGandRELEASE.rokm commentedon Nov 17, 2017
@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.cmakeand 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?
alalek commentedon Nov 17, 2017
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.
tfoote commentedon Dec 12, 2017
@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
wontfixtag 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