mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-04 11:55:51 +00:00
43 lines
1.4 KiB
CMake
43 lines
1.4 KiB
CMake
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
|
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14)
|
|
message (FATAL_ERROR "Clang 14+ required for building clio")
|
|
endif ()
|
|
set (is_clang TRUE)
|
|
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
|
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14)
|
|
message (FATAL_ERROR "AppleClang 14+ required for building clio")
|
|
endif ()
|
|
set (is_appleclang TRUE)
|
|
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11)
|
|
message (FATAL_ERROR "GCC 11+ required for building clio")
|
|
endif ()
|
|
set (is_gcc TRUE)
|
|
else ()
|
|
message (FATAL_ERROR "Supported compilers: AppleClang 14+, Clang 14+, GCC 11+")
|
|
endif ()
|
|
|
|
if (san)
|
|
string (TOLOWER ${san} san)
|
|
set (SAN_FLAG "-fsanitize=${san}")
|
|
set (SAN_LIB "")
|
|
if (is_gcc)
|
|
if (san STREQUAL "address")
|
|
set (SAN_LIB "asan")
|
|
elseif (san STREQUAL "thread")
|
|
set (SAN_LIB "tsan")
|
|
elseif (san STREQUAL "memory")
|
|
set (SAN_LIB "msan")
|
|
elseif (san STREQUAL "undefined")
|
|
set (SAN_LIB "ubsan")
|
|
endif ()
|
|
endif ()
|
|
set (_saved_CRL ${CMAKE_REQUIRED_LIBRARIES})
|
|
set (CMAKE_REQUIRED_LIBRARIES "${SAN_FLAG};${SAN_LIB}")
|
|
CHECK_CXX_COMPILER_FLAG (${SAN_FLAG} COMPILER_SUPPORTS_SAN)
|
|
set (CMAKE_REQUIRED_LIBRARIES ${_saved_CRL})
|
|
if (NOT COMPILER_SUPPORTS_SAN)
|
|
message (FATAL_ERROR "${san} sanitizer does not seem to be supported by your compiler")
|
|
endif ()
|
|
endif ()
|