----- On Nov 7, 2016, at 1:37 AM, Stephan Menzel <stephan.men...@gmail.com> 
wrote: 

> Hello everyone,
> I'm looking for a way to force Debug configurations in generated MSVC 
> solutions
> to use the Release runtime instead of the default "Debug". e.g. /MD rather 
> than
> /MDd.

> My use case is an ever recurring problem of creating libraries that are linked
> in plug-in fashion against Release only applications. I want for my Debug
> configuration to have debug info and no optimization but still use the release
> runtime so I can link them.

> I tried replacing /MDd with /MD in CMAKE_CXX_FLAGS_DEBUG. This yielded objects
> built with /MD alright but failed to link into an executable with stuff like
> that:

> error LNK2038: mismatch detected for 'RuntimeLibrary': value 
> 'MD_DynamicRelease'
> doesn't match value 'MDd_DynamicDebug' in Test.obj

> From what I gather all the obj are actually compiled for Release runtime 
> without
> optimization and Debug info just like I need it. But then the main obj is 
> built
> and linked in Debug mode, causing the executable to not be created.

> Is there a way to solve this? Like a generic CMake executable flag or 
> something
> that I can use to force the other runtime?

> Please note that using RelWithDebInfo and turning off optimization is not
> exactly what I need as I still want that mode much the way it is.

If you are going to use /MD instead of /MDd, then you probably also need to 
remove the _DEBUG preprocessor flag. 
IIRC, I've seen cases where defining _DEBUG includes symbols only defined by 
the debug runtimes. 

Clint 
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to