Browse Source

Merge pull request #4 from smspillaz/issues/2

Set the HAVE_MEMORY_SANITIZER and HAVE_ADDRESS_SANITIZER cache entries.
master
Matt Arsenault 11 years ago
parent
commit
b61ffc8ceb
2 changed files with 15 additions and 1 deletions
  1. +11
    -0
      FindASan.cmake
  2. +4
    -1
      FindMSan.cmake

+ 11
- 0
FindASan.cmake View File

@@ -21,6 +21,13 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE. # THE SOFTWARE.
# #
# This module tests if address sanitizer is supported by the compiler,
# and creates a ASan build type (i.e. set CMAKE_BUILD_TYPE=ASan to use
# it). This sets the following variables:
#
# CMAKE_C_FLAGS_ASAN - Flags to use for C with asan
# CMAKE_CXX_FLAGS_ASAN - Flags to use for C++ with asan
# HAVE_ADDRESS_SANITIZER - True or false if the ASan build type is available


include(CheckCCompilerFlag) include(CheckCCompilerFlag)


@@ -43,8 +50,12 @@ endif()


if(NOT ADDRESS_SANITIZER_FLAG) if(NOT ADDRESS_SANITIZER_FLAG)
return() return()
else(NOT ADDRESS_SANITIZER_FLAG)
set(HAVE_ADDRESS_SANITIZER FALSE)
endif() endif()


set(HAVE_ADDRESS_SANITIZER TRUE)

set(CMAKE_C_FLAGS_ASAN "-O1 -g ${ADDRESS_SANITIZER_FLAG} -fno-omit-frame-pointer -fno-optimize-sibling-calls" set(CMAKE_C_FLAGS_ASAN "-O1 -g ${ADDRESS_SANITIZER_FLAG} -fno-omit-frame-pointer -fno-optimize-sibling-calls"
CACHE STRING "Flags used by the C compiler during ASan builds." CACHE STRING "Flags used by the C compiler during ASan builds."
FORCE) FORCE)


+ 4
- 1
FindMSan.cmake View File

@@ -26,7 +26,7 @@
# and creates a MSan build type (i.e. set CMAKE_BUILD_TYPE=MSan to use # and creates a MSan build type (i.e. set CMAKE_BUILD_TYPE=MSan to use
# it). This sets the following variables: # it). This sets the following variables:
# #
# CMAKE_C_FLAGS_MSAN - Flags to use for C with tsan
# CMAKE_C_FLAGS_MSAN - Flags to use for C with msan
# CMAKE_CXX_FLAGS_MSAN - Flags to use for C++ with msan # CMAKE_CXX_FLAGS_MSAN - Flags to use for C++ with msan
# HAVE_MEMORY_SANITIZER - True or false if the MSan build type is available # HAVE_MEMORY_SANITIZER - True or false if the MSan build type is available


@@ -51,8 +51,11 @@ endif()


if(NOT MEMORY_SANITIZER_FLAG) if(NOT MEMORY_SANITIZER_FLAG)
return() return()
else(NOT MEMORY_SANITIZER_FLAG)
set(HAVE_MEMORY_SANITIZER TRUE)
endif() endif()


set(HAVE_MEMORY_SANITIZER TRUE)


set(CMAKE_C_FLAGS_MSAN "-O1 -g ${MEMORY_SANITIZER_FLAG} -fno-omit-frame-pointer -fno-optimize-sibling-calls" set(CMAKE_C_FLAGS_MSAN "-O1 -g ${MEMORY_SANITIZER_FLAG} -fno-omit-frame-pointer -fno-optimize-sibling-calls"
CACHE STRING "Flags used by the C compiler during MSan builds." CACHE STRING "Flags used by the C compiler during MSan builds."


Loading…
Cancel
Save