From 92bc875e0a129bbe34bc4c2c99f9c98c0c381298 Mon Sep 17 00:00:00 2001 From: Paul Bakker Date: Mon, 30 Dec 2013 17:56:23 +0100 Subject: [PATCH] Support for CLANG compiler in CMakeLists.txt --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6cfa4e435..1cad26928 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,8 @@ project(POLARSSL C) enable_testing() +string(REGEX MATCH "clang" CMAKE_COMPILER_IS_CLANG "${CMAKE_C_COMPILER}") + if(CMAKE_COMPILER_IS_GNUCC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -Wall -Wextra -W -Wdeclaration-after-statement") set(CMAKE_C_FLAGS_DEBUG "-g3 -O0") @@ -11,6 +13,12 @@ if(CMAKE_COMPILER_IS_GNUCC) set(CMAKE_C_FLAGS_CHECKFULL "${CMAKE_C_FLAGS_CHECK} -Wcast-qual") endif(CMAKE_COMPILER_IS_GNUCC) +if(CMAKE_COMPILER_IS_CLANG) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -Wall -Wextra -W -Wdeclaration-after-statement") + set(CMAKE_C_FLAGS_DEBUG "-g3 -O0") + set(CMAKE_C_FLAGS_CHECK "${CMAKE_C_FLAGS} -Wpointer-arith -Wwrite-strings -Wdocumentation -Werror") +endif(CMAKE_COMPILER_IS_CLANG) + set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose the type of build: None Debug Release Coverage Check CheckFull" FORCE)