~vanvugt/mir/log-level

« back to all changes in this revision

Viewing changes to CMakeLists.txt

  • Committer: Daniel van Vugt
  • Date: 2015-01-23 03:08:41 UTC
  • mfrom: (2201.2.50 development-branch)
  • Revision ID: daniel.van.vugt@canonical.com-20150123030841-zn39cao9um2o9x0p
Merge latest trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
include (cmake/PrePush.cmake)
49
49
include (GNUInstallDirs)
50
50
 
51
 
set(build_types "None;Debug;Release;RelWithDebInfo;MinSizeRel;Coverage;AddressSanitizer")
 
51
set(build_types "None;Debug;Release;RelWithDebInfo;MinSizeRel;Coverage;AddressSanitizer;ThreadSanitizer")
52
52
# Change informational string for CMAKE_BUILD_TYPE
53
53
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "${build_types}" FORCE)
54
54
# Enable cmake-gui to display a drop down list for CMAKE_BUILD_TYPE
92
92
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
93
93
  set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=address")
94
94
  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address")
 
95
elseif(cmake_build_type_lower MATCHES "threadsanitizer")
 
96
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread -fno-omit-frame-pointer")
 
97
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread -fno-omit-frame-pointer")
 
98
  if (CMAKE_COMPILER_IS_GNUCXX)
 
99
    # Work around GCC bug. It should automatically link to tsan when
 
100
    # -fsanitize=thread is used, but doesn't.
 
101
    #
 
102
    # Linking everything with tsan is harmless and simple, so do that.
 
103
    link_libraries(tsan)
 
104
  endif()
95
105
else()
96
106
  # AddressSanitizer builds fail if we disallow undefined symbols
97
107
  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
98
108
  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-undefined")
99
109
endif()
100
110
 
 
111
set(CMAKE_MODULE_LINKER_FLAGS_THREADSANITIZER "-fsanitize=thread")
 
112
set(CMAKE_SHARED_LINKER_FLAGS_THREADSANITZIER "-fsanitize=thread")
 
113
set(CMAKE_EXE_LINKER_FLAGS_THREADSANITIZER "-pie")
 
114
 
101
115
# Define LOG_NDEBUG=1 to ensure Android ALOGV calls are not compiled in to
102
116
# consume CPU time...
103
117
add_definitions(-DLOG_NDEBUG=1)