Quantcast

Release flags on one target in debug build type

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Release flags on one target in debug build type

Konstantin Tokarev
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

--
Regards,
Konstantin
--

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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Release flags on one target in debug build type

Michael Ellery

> On May 5, 2017, at 11:45 AM, Konstantin Tokarev <[hidden email]> 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
>
> --
> Regards,
> Konstantin
> --
>
> 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


Does RelWithDebInfo do what you want? I have in the past taken one of the “alternative targets” (RelWithDebInfo or MinSIzeRel) and adjusted the flags for that target until it suited my specific needs, but I don’t necessarily claim that is the right way to go in all cases. Also be aware that the default optimization level can differ slightly with each of these build types. In the end, it’s probably best to survey the current settings for each build type and see if one is close to what you want.

-Mike

--

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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Release flags on one target in debug build type

Konstantin Tokarev


05.05.2017, 23:22, "Michael Ellery" <[hidden email]>:

>>  On May 5, 2017, at 11:45 AM, Konstantin Tokarev <[hidden email]> 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
>>
>>  --
>>  Regards,
>>  Konstantin
>>  --
>>
>>  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
>
> Does RelWithDebInfo do what you want? I have in the past taken one of the “alternative targets” (RelWithDebInfo or MinSIzeRel) and adjusted the flags for that target until it suited my specific needs, but I don’t necessarily claim that is the right way to go in all cases. Also be aware that the default optimization level can differ slightly with each of these build types. In the end, it’s probably best to survey the current settings for each build type and see if one is close to what you want.

I need to modify build of one target, not to change global build type of the project

>
> -Mike

--
Regards,
Konstantin
--

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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Release flags on one target in debug build type

Dan Liew
In reply to this post by Konstantin Tokarev
On 5 May 2017 at 19:45, Konstantin Tokarev <[hidden email]> 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
Loading...