[sanitizers] Add custom CMake build type as an option#4312
Conversation
Signed-off-by: Uilian Ries <uilianr@jfrog.com>
Signed-off-by: Uilian Ries <uilianr@jfrog.com>
memsharded
left a comment
There was a problem hiding this comment.
Looking very good, thanks!
| Similar to managing sanitizers with a custom CMake toolchain, but without ``compiler.sanitizer`` custom settings, | ||
| is to define sanitizers as part of a custom CMake build type. This way, you can select the desired sanitizer configuration | ||
| by specifying the build type during the CMake configuration step. | ||
| To achieve this, you can create a custom CMake toolchain file that maps build types to sanitizer flags. For example: |
There was a problem hiding this comment.
Please add a sentence, saying something like: "as this is a custom build type, you need to also define the flags that correspond to the desired based build type, for example that -g flag that matches the Debug build_type in gcc-like compilers"
Signed-off-by: Uilian Ries <uilianr@jfrog.com>
| .. code-block:: cmake | ||
| :caption: cmake/sanitizer_toolchain.cmake | ||
|
|
||
| if(CMAKE_BUILD_TYPE STREQUAL "DebugASan") |
There was a problem hiding this comment.
Should we add a note saying that this example assumes a single-configuration generator that uses CMAKE_BUILD_TYPE?
There was a problem hiding this comment.
I don't think is really needed because is a very custom build, I mean, who customizes should know what they are doing as a custom build.
czoido
left a comment
There was a problem hiding this comment.
Just a couple of minor comments, but looks great! 👏
Co-authored-by: Carlos Zoido <mrgalleta@gmail.com>
Co-authored-by: Carlos Zoido <mrgalleta@gmail.com>
Hello! This PR is a follow-up to #4199
As @memsharded commented to me, people are using a custom CMake build type, like
DebugASan, instead of adding a new setting likecompiler.sanitizers. As a very valid scenario, I brought the case to the documentation as well.It will require a CMake file with the flags and rules managed by the user, but can be easily integrated by using the Conan conf
user_toolchain. BTW, I made a mistake in the first PR:user_toolchainis a list, not a string.Tested this new scenario locally using a simple
conan new cmake_lib+ following the instructions:You can see the new build type
DebugASanand the compiler flags-fsanitize=address -fno-omit-frame-pointerduring the build: