summaryrefslogtreecommitdiff
path: root/cmake/os
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/os')
-rw-r--r--cmake/os/Linux.cmake4
-rw-r--r--cmake/os/Windows.cmake60
-rw-r--r--cmake/os/WindowsCache.cmake7
3 files changed, 53 insertions, 18 deletions
diff --git a/cmake/os/Linux.cmake b/cmake/os/Linux.cmake
index 1575c16bb4c..6fde915165f 100644
--- a/cmake/os/Linux.cmake
+++ b/cmake/os/Linux.cmake
@@ -34,8 +34,8 @@ ENDFOREACH()
# Ensure we have clean build for shared libraries
# without unresolved symbols
-# Not supported with AddressSanitizer
-IF(NOT WITH_ASAN AND NOT WITH_UBSAN)
+# Not supported with the clang sanitizers
+IF(NOT WITH_ASAN AND NOT WITH_TSAN AND NOT WITH_UBSAN)
SET(LINK_FLAG_NO_UNDEFINED "-Wl,--no-undefined")
ENDIF()
diff --git a/cmake/os/Windows.cmake b/cmake/os/Windows.cmake
index ca6d13e1c1b..eb56f599eb4 100644
--- a/cmake/os/Windows.cmake
+++ b/cmake/os/Windows.cmake
@@ -59,7 +59,41 @@ IF(MINGW AND CMAKE_SIZEOF_VOID_P EQUAL 4)
ADD_DEFINITIONS(-march=i486)
ENDIF()
+FUNCTION(ENABLE_ASAN)
+ IF(NOT (MSVC AND CMAKE_CXX_COMPILER_ID MATCHES Clang))
+ MESSAGE(FATAL_ERROR "clang-cl is necessary to enable asan")
+ ENDIF()
+ # currently, asan is broken with static CRT.
+ IF(NOT(MSVC_CRT_TYPE STREQUAL "/MD"))
+ MESSAGE(FATAL_ERROR "-DWITH_ASAN cmake parameter also requires -DMSVC_CRT_TYPE=/MD")
+ ENDIF()
+ IF(CMAKE_SIZEOF_VOID_P EQUAL 4)
+ MESSAGE(FATAL_ERROR "-DWITH_ASAN on Windows requires 64bit build")
+ ENDIF()
+ # After installation, clang lib directory should be added to PATH
+ # (e.g C:/Program Files/LLVM/lib/clang/5.0.1/lib/windows)
+ FIND_LIBRARY(CLANG_RT_ASAN_DYNAMIC clang_rt.asan_dynamic-x86_64.lib)
+ IF(NOT CLANG_RT_ASAN_DYNAMIC)
+ MESSAGE(FATAL_ERROR "Can't enable ASAN : missing clang_rt.asan_dynamic-x86_64.lib")
+ ENDIF()
+
+ FIND_LIBRARY(CLANG_RT_ASAN_DYNAMIC_THUNK clang_rt.asan_dynamic_runtime_thunk-x86_64.lib)
+ IF(NOT CLANG_RT_ASAN_DYNAMIC_THUNK)
+ MESSAGE(FATAL_ERROR "Can't enable ASAN : missing clang_rt.asan_dynamic_runtime_thunk-x86_64.lib")
+ ENDIF()
+
+ STRING(APPEND CMAKE_C_FLAGS " -fsanitize=address")
+ STRING(APPEND CMAKE_CXX_FLAGS " -fsanitize=address")
+
+ LINK_LIBRARIES(${CLANG_RT_ASAN_DYNAMIC} ${CLANG_RT_ASAN_DYNAMIC_THUNK})
+ENDFUNCTION()
+
+
IF(MSVC)
+ IF(WITH_ASAN)
+ ENABLE_ASAN()
+ ENDIF()
+
# Disable mingw based pkg-config found in Strawberry perl
SET(PKG_CONFIG_EXECUTABLE 0 CACHE INTERNAL "")
SET(MSVC_CRT_TYPE /MT CACHE STRING
@@ -119,8 +153,16 @@ IF(MSVC)
STRING(APPEND ${flag} " /Z7")
ENDIF()
ENDFOREACH()
-
-
+
+ IF(CMAKE_CXX_COMPILER_ID MATCHES Clang)
+ SET(CLANG_CL_FLAGS
+"-Wno-unused-parameter -Wno-unused-command-line-argument -Wno-pointer-sign -Wno-deprecated-register \
+-Wno-missing-braces -Wno-unused-function -msse4.2 "
+ )
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CLANG_CL_FLAGS}")
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CLANG_CL_FLAGS}")
+ ENDIF()
+
# Fix CMake's predefined huge stack size
FOREACH(type EXE SHARED MODULE)
STRING(REGEX REPLACE "/STACK:([^ ]+)" "" CMAKE_${type}_LINKER_FLAGS "${CMAKE_${type}_LINKER_FLAGS}")
@@ -139,18 +181,18 @@ IF(MSVC)
ENDIF()
# Speed up multiprocessor build
- IF (MSVC_VERSION GREATER 1400)
+ IF (MSVC_VERSION GREATER 1400 AND (NOT CMAKE_CXX_COMPILER_ID MATCHES Clang))
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
ENDIF()
#TODO: update the code and remove the disabled warnings
- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4805 /wd4996 /we4700 /we4311 /we4477 /we4302 /we4090")
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4805 /wd4291 /wd4996 /we4099 /we4700 /we4311 /we4477 /we4302 /we4090")
- IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
- # Temporarily disable size_t warnings, due to their amount
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267")
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /we4700 /we4311 /we4477 /we4302 /we4090")
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /we4099 /we4700 /we4311 /we4477 /we4302 /we4090")
+ IF(MSVC_VERSION GREATER 1910 AND (NOT CMAKE_CXX_COMPILER_ID MATCHES Clang))
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /permissive-")
ENDIF()
+ ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_WARNINGS)
IF(MYSQL_MAINTAINER_MODE MATCHES "ERR")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
@@ -225,8 +267,6 @@ CHECK_SYMBOL_REPLACEMENT(S_IROTH _S_IREAD sys/stat.h)
CHECK_SYMBOL_REPLACEMENT(S_IFIFO _S_IFIFO sys/stat.h)
CHECK_SYMBOL_REPLACEMENT(SIGQUIT SIGTERM signal.h)
CHECK_SYMBOL_REPLACEMENT(SIGPIPE SIGINT signal.h)
-CHECK_SYMBOL_REPLACEMENT(isnan _isnan "math.h;float.h")
-CHECK_SYMBOL_REPLACEMENT(finite _finite "math;float.h")
CHECK_FUNCTION_REPLACEMENT(popen _popen)
CHECK_FUNCTION_REPLACEMENT(pclose _pclose)
CHECK_FUNCTION_REPLACEMENT(access _access)
diff --git a/cmake/os/WindowsCache.cmake b/cmake/os/WindowsCache.cmake
index 1cb6c81b627..939a52d0655 100644
--- a/cmake/os/WindowsCache.cmake
+++ b/cmake/os/WindowsCache.cmake
@@ -52,8 +52,6 @@ SET(HAVE_DECL_FDATASYNC CACHE INTERNAL "")
SET(HAVE_FEDISABLEEXCEPT CACHE INTERNAL "")
SET(HAVE_FENV_H CACHE INTERNAL "")
SET(HAVE_FESETROUND CACHE INTERNAL "")
-SET(HAVE_FINITE CACHE INTERNAL "")
-SET(HAVE_FINITE_IN_MATH_H CACHE INTERNAL "")
SET(HAVE_FLOAT_H 1 CACHE INTERNAL "")
SET(HAVE_FNMATCH_H CACHE INTERNAL "")
SET(HAVE_FPU_CONTROL_H CACHE INTERNAL "")
@@ -84,13 +82,11 @@ SET(HAVE_INTTYPES_H CACHE INTERNAL "")
SET(HAVE_IPPROTO_IPV6 CACHE INTERNAL "")
SET(HAVE_IPV6 TRUE CACHE INTERNAL "")
SET(HAVE_IPV6_V6ONLY 1 CACHE INTERNAL "")
-SET(HAVE_ISINF CACHE INTERNAL "")
SET(HAVE_LANGINFO_H CACHE INTERNAL "")
SET(HAVE_LDIV 1 CACHE INTERNAL "")
SET(HAVE_LIMITS_H 1 CACHE INTERNAL "")
SET(HAVE_LOCALE_H 1 CACHE INTERNAL "")
SET(HAVE_LOCALTIME_R 1 CACHE INTERNAL "")
-#SET(HAVE_LOG2 CACHE INTERNAL "")
SET(HAVE_LRAND48 CACHE INTERNAL "")
SET(HAVE_LSTAT CACHE INTERNAL "")
SET(HAVE_MADVISE CACHE INTERNAL "")
@@ -101,6 +97,7 @@ SET(HAVE_MEMCPY 1 CACHE INTERNAL "")
SET(HAVE_MEMMOVE 1 CACHE INTERNAL "")
SET(HAVE_MEMORY_H 1 CACHE INTERNAL "")
SET(HAVE_MKSTEMP CACHE INTERNAL "")
+SET(HAVE_MKOSTEMP CACHE INTERNAL "")
SET(HAVE_MLOCK CACHE INTERNAL "")
SET(HAVE_MLOCKALL CACHE INTERNAL "")
SET(HAVE_MMAP CACHE INTERNAL "")
@@ -141,7 +138,6 @@ SET(HAVE_READLINK CACHE INTERNAL "")
SET(HAVE_READ_REAL_TIME CACHE INTERNAL "")
SET(HAVE_REALPATH CACHE INTERNAL "")
SET(HAVE_RENAME 1 CACHE INTERNAL "")
-#SET(HAVE_RINT CACHE INTERNAL "")
SET(HAVE_RWLOCK_INIT CACHE INTERNAL "")
SET(HAVE_SCHED_H CACHE INTERNAL "")
SET(HAVE_SCHED_YIELD CACHE INTERNAL "")
@@ -240,7 +236,6 @@ SET(HAVE_SYS_VADVISE_H CACHE INTERNAL "")
SET(HAVE_SYS_WAIT_H CACHE INTERNAL "")
SET(HAVE_TCGETATTR CACHE INTERNAL "")
SET(HAVE_TELL 1 CACHE INTERNAL "")
-SET(HAVE_TEMPNAM 1 CACHE INTERNAL "")
SET(HAVE_TERMCAP_H CACHE INTERNAL "")
SET(HAVE_TERMIOS_H CACHE INTERNAL "")
SET(HAVE_TERMIO_H CACHE INTERNAL "")