blob: 7e268c4393cfbeee752f26aac0b6058cbb0273c8 [file] [log] [blame]
From f5f137b7b2fddf3e3232e4859b62da42654d0f87 Mon Sep 17 00:00:00 2001
From: Todd Lipcon <todd@cloudera.com>
Date: Thu, 25 Jun 2015 14:45:27 -0700
Subject: [PATCH] Fix cmake build to use gnu flags on clang
Previously, the cmake build was only adding -fPIC and -std=c99 on
gcc. However, these flags are also appropriate when building with
clang.
---
cmake_unofficial/CMakeLists.txt | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/cmake_unofficial/CMakeLists.txt b/cmake_unofficial/CMakeLists.txt
index 4c3eb65..a986f43 100644
--- a/cmake_unofficial/CMakeLists.txt
+++ b/cmake_unofficial/CMakeLists.txt
@@ -17,7 +17,12 @@ ENDIF()
option(BUILD_TOOLS "Build the command line tools" ON)
option(BUILD_LIBS "Build the libraries in addition to the tools" ON)
-if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
+IF("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR
+ "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
+ SET(GNU_COMPATIBLE_COMPILER 1)
+ENDIF()
+
+if(GNU_COMPATIBLE_COMPILER)
if(UNIX AND BUILD_LIBS)
add_definitions(-fPIC)
endif()
@@ -68,7 +73,7 @@ endif()
if(MSVC)
ADD_DEFINITIONS("-W4")
endif()
-if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
+if(GNU_COMPATIBLE_COMPILER)
ADD_DEFINITIONS("-Wall")
endif()
if(CMAKE_COMPILER_IS_GNUCXX)
@@ -78,7 +83,7 @@ ADD_DEFINITIONS("-Wshadow")
ADD_DEFINITIONS("-Wcast-align")
ADD_DEFINITIONS("-Wstrict-prototypes")
endif(CMAKE_COMPILER_IS_GNUCXX)
-if((CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) AND
+if(GNU_COMPATIBLE_COMPILER AND
(NOT CMAKE_SYSTEM_NAME MATCHES "SunOS"))
ADD_DEFINITIONS("-std=c99")
endif()
--
1.8.3.2