include(CheckCXXCompilerFlag)
-if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
- AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0")
- # Old GCC versions don't have the required header support.
+# Old GCC versions don't have the required header support.
+# Old Apple Clang versions seem to support -mavx2 but not the target
+# attribute that's used to enable AVX2 for a certain function.
+if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
+ OR (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0))
message(STATUS "Detected unsupported compiler for HAVE_AVX2 - disabled")
set(HAVE_AVX2 FALSE)
else()
check_cxx_compiler_flag(-mavx2 HAVE_AVX2)
endif()
-
list(APPEND CMAKE_REQUIRED_LIBRARIES ws2_32)
list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES ws2_32)
# Not supported in CMake 3.4: target_compile_features(project_options INTERFACE
# c_std_11 cxx_std_11)
-if(CMAKE_CXX_COMPILER_ID MATCHES "^GNU|Clang$")
+if(CMAKE_CXX_COMPILER_ID MATCHES "^GNU|(Apple)?Clang$")
option(ENABLE_COVERAGE "Enable coverage reporting for GCC/Clang" FALSE)
if(ENABLE_COVERAGE)
target_compile_options(standard_settings INTERFACE --coverage -O0 -g)
function(add_source_if_enabled feature compile_flags)
string(TOUPPER "have_${blake_source_type}_${feature}" have_feature)
- if(${blake_source_type} STREQUAL "asm")
+
+ # AVX512 support fails to compile with old Apple Clang versions even though
+ # the compiler accepts the -m flags.
+ if(${feature} STREQUAL "avx512"
+ AND CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"
+ AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)
+ message(STATUS "Detected unsupported compiler for ${have_feature} - disabled")
+ set(${have_feature} FALSE)
+ elseif(${blake_source_type} STREQUAL "asm")
check_asm_compiler_flag(${compile_flags} ${have_feature})
else()
check_c_compiler_flag(${compile_flags} ${have_feature})