On 5 May 2017 at 19:45, Konstantin Tokarev <annu...@yandex.ru> wrote:
> Hello,
>
> Is there any clear way to build specific target in "Debug" mode with flags 
> that it would have in "Release"?
>
> In particular, build this specific target without effect of 
> CMAKE_CXX_FLAGS_DEBUG and CMAKE_C_FLAGS_DEBUG, while preserving flags added 
> by target_compile_options


Something like this would sort of do it.

```
target_compile_options(your_target
  PRIVATE
  $<$<COMPILE_LANGUAGE:CXX>:$<$<CONFIG:Debug>:${CMAKE_CXX_FLAGS_RELEASE}>>
  $<$<COMPILE_LANGUAGE:C>:$<$<CONFIG:Debug>:${CMAKE_C_FLAGS_RELEASE}>>
```

The problem you have though is that `your_target` in debug mode will
already debug build flags (e.g. `-O0 g`). So you may get conflicting
compiler options.

Another way of doing this is to build your target as an external
project where you set the build mode of the external project to be
release.
-- 

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