From 4ccc2f48f535021918d038566b306b388416b63b Mon Sep 17 00:00:00 2001
From: Pavel Cherenkov <pcherenkov@gmail.com>
Date: Tue, 10 Apr 2012 17:18:50 +0400
Subject: [PATCH] bug977231: gcc version check (>=4.4) moved to cmake, cpuid.h
 -msse4 also checked

---
 core/CMakeLists.txt | 18 ++++++++++++++++++
 core/cpu_feature.m  |  7 -------
 2 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
index fb753cf491..4bf5ca728c 100644
--- a/core/CMakeLists.txt
+++ b/core/CMakeLists.txt
@@ -4,6 +4,24 @@
 add_library(ev tarantool_ev.c)
 
 check_c_compiler_flag ("-Wno-unused-result" gcc_has_wno_unused_result)
+check_c_compiler_flag ("-msse4" gcc_has_sse4)
+check_include_file("cpuid.h" gcc_has_cpuid)
+
+execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
+                OUTPUT_VARIABLE GCC_VERSION)
+if (GCC_VERSION VERSION_GREATER 4.4 OR GCC_VERSION VERSION_EQUAL 4.4)
+        message(STATUS "GCC Version >= 4.4")
+else()
+    message (FATAL_ERROR "GCC version should be >= 4.4")
+endif()
+
+if (NOT gcc_has_sse4)
+    message (FATAL_ERROR "GCC must support SSE4 instructions (-msse4).")
+endif()
+
+if (NOT gcc_has_cpuid)
+    message (FATAL_ERROR "GCC is missing cpuid.h")
+endif()
 
 if (gcc_has_wno_unused_result)
     set_source_files_properties(tarantool_ev.c
diff --git a/core/cpu_feature.m b/core/cpu_feature.m
index 559b8d6cf8..83816ec944 100644
--- a/core/cpu_feature.m
+++ b/core/cpu_feature.m
@@ -31,13 +31,6 @@
 	#error "Only x86 and x86_64 architectures supported"
 #endif
 
-#ifndef __GNUC__
-	#error This module uses GCC intrinsic header(s) and should be compiled using gcc.
-#elif ((__GNUC__ * 10000) + (__GNUC_MINOR__ * 100)) < 40400
-	#error This module should be compiled with GCC 4.4 and higher
-#endif
-
-
 /* GCC intrinsic headers */
 #include <cpuid.h>
 #include <smmintrin.h>
-- 
GitLab