The attentive reader will have noticed that we did not search for the AddressSanitizer on our system prior to linking our target against it. A real-world, complete use case would have done that, to avoid unpleasant surprises during the linking stage. We will remind the reader that we showed a method to probe for the availability of sanitizers in Recipe 7, Probing compiler flags, in Chapter 5, Configure-time and Build-time Operations.
For more AddressSanitizer documentation and examples, see https://github.com/google/sanitizers/wiki/AddressSanitizer. AddressSanitizer is not limited to C and C++. For a Fortran example, we refer the reader to the code repository at https://github.com/dev-cafe/cmake-cookbook/tree/v1.0/chapter-14/recipe-03/fortran-example ...