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

**URL:** https://discourse.cmake.org/t/force-specific-library-to-be-release-in-a-config-debug-build/5387
**Category:** Usage
**Tags:** os:windows
**Created:** [April 6, 2022, 3:08pm UTC](https://discourse.cmake.org/t/force-specific-library-to-be-release-in-a-config-debug-build/5387 "2022-04-06T15:08:34Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Boooke](https://discourse.cmake.org/user_avatar/discourse.cmake.org/boooke/32/2322_2.png) [@Boooke](https://discourse.cmake.org/u/Boooke)
#### Post date: [April 6, 2022, 3:08pm UTC](https://discourse.cmake.org/t/force-specific-library-to-be-release-in-a-config-debug-build/5387/1 "2022-04-06T15:08:34Z")

</div>

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:

```auto
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

```auto
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?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [April 9, 2022, 12:45pm UTC](https://discourse.cmake.org/t/force-specific-library-to-be-release-in-a-config-debug-build/5387/2 "2022-04-09T12:45:16Z")

</div>

You can try using the [`MAP_IMPORTED_CONFIG_<CONFIG>`](https://cmake.org/cmake/help/latest/prop_tgt/MAP_IMPORTED_CONFIG_CONFIG.html) 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.

---

<div class="post-metadata">

### Author: ![Boooke](https://discourse.cmake.org/user_avatar/discourse.cmake.org/boooke/32/2322_2.png) [@Boooke](https://discourse.cmake.org/u/Boooke)
#### Post date: [April 18, 2022, 9:26am UTC](https://discourse.cmake.org/t/force-specific-library-to-be-release-in-a-config-debug-build/5387/3 "2022-04-18T09:26:57Z")

</div>

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.
