1

In my CMake script I'm adding a custom configuration type like suggested in the CMake FAQ:

if(CMAKE_CONFIGURATION_TYPES)
  set(CMAKE_CONFIGURATION_TYPES Debug Release MyRelease)
  set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "Reset the configurations to what we need" FORCE)
endif()

I would like to have a MyRelease configuration in my generated Visual Studio 2015 project that behaves like Release but with an additional post-build step. The problem is, that it appears to use the Debug configuration as the basis by default. This, in turn, becomes a problem when using imported targets that don't explicitly specify the library location for my own configuration type. For example, when using the imported target opencv_core it will try to link against the opencv_core2413d.lib which is defined specifically for Debug configuration.

Is there a way to let custom configuration types inherit from the Release configuration type?

Note: I'm using CMake version 3.12.

bender
  • 613
  • 1
  • 8
  • 23
  • You are probably looking for [CMAKE_MAP_IMPORTED_CONFIG_](https://cmake.org/cmake/help/v3.7/variable/CMAKE_MAP_IMPORTED_CONFIG_CONFIG.html) which affects on choosing of an IMPORTED target's configuration for your configuration. – Tsyvarev Oct 10 '18 at 11:35
  • Thank you for your comment, do you have any example on how to use the CMAKE_MAP_IMPORTED_CONFIG_ variable? I tried setting it like this: `set(CMAKE_MAP_IMPORTED_CONFIG_MYRELEASE MyRelease Release)` but without luck. – bender Oct 10 '18 at 15:01
  • This sounds like two questions in one. I'd ask for a split, or vote close needs focus, but there's an existing question where the top answer should address both your questions [here](https://stackoverflow.com/q/43746829/11107541). – starball Oct 13 '22 at 01:51
  • Does this answer your question? [How to create a CMake configuration type that inherits from Release](https://stackoverflow.com/questions/43746829/how-to-create-a-cmake-configuration-type-that-inherits-from-release) – starball Oct 13 '22 at 01:51

0 Answers0