Force Specific Library to be Release in a "--config debug" Build

Hey, I want to use OpenCV that does not out of the box allow for a debug build, and I was hoping if there was somehow a way of forcing a --config debug build to use the Release version of this library?

If CMake is set to --debug it is seemingly looking for not only the lib/Debug folder, and I thought I had perhaps found a way to make it look into the right folder:

cmake_minimum_required(VERSION 3.1.0)
project(VehicleComputerVision VERSION 0.1.0)
set(LIB_OpenCV_LIBRARIES
        "$<$<NOT:$<CONFIG:DEBUG>>:${LIB_OpenCV_RELEASE}>"
        "$<$<CONFIG:DEBUG>:${LIB_OpenCV_RELEASE}>"
)
add_executable(VehicleComputerVision 
    VehicleComputerVision.cpp
)
target_link_libraries(VehicleComputerVision 
PRIVATE 
    opencv_core
    opencv_highgui
    opencv_imgproc
)

But I still get a

fatal error LNK1104: cannot open file ...\build\opencv-4.5.5\lib\Debug\opencv_highgui455d.lib'

I assume the d suffix to denote the debug version of the library, though I don’t know where it is specified to look for this

Is there a way to tell CMake to essentially treat this package as a release version despite the --config debug flag?

You can try using the MAP_IMPORTED_CONFIG_<CONFIG> property. However, OpenCV is a C++ library, so if you plan on doing this cross-configuration setup, you cannot talk to OpenCV using any C++ standard library types (std::vector, std::string, etc.) because the layout for these things are different in release and debug builds. If you need a release build of OpenCV, I recommend using RelWithDebInfo for your project.

Thanks for the help, Ben (And sorry for a late one myself). I’m not really sure what the problem was when I built it standalone, but I’ve managed to build OpenCV as a submodule inside my project using ExternalProject_Add. I have no real explanation as to why this works over the standalone build, but it manages to find my python debug libraries this way, despite using the same Python env variable.

But I’ll keep the RelWithDebInfo in mind, because this method of including OpenCV inside my project feels a little clunky.