From a330cc1877f9eb7fc978fa7708af9fca8c392dd0 Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Fri, 24 Apr 2020 18:22:26 -0400 Subject: [PATCH] cmake: support old Cmake for -std=c99 on old verisons of Cmake, they don't support the way we are setting the "C_STANDARD 99" (in set_target_properties), so check for old verison and then set the CMAKE_C_FLAGS by hand. This eliminates all the warnings that happen on the Zynq images we use (2019R1) and some of the older CI images we support, and make it alot easier to see where the real errors/warnings are. Signed-off-by: Robin Getz --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 590fd8d49..b4f3c43f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,4 @@ +message(STATUS "cmake verison: ${CMAKE_VERSION}") cmake_minimum_required(VERSION 2.8.7) project(libiio C) @@ -77,6 +78,13 @@ if (CMAKE_COMPILER_IS_GNUCC) if (HAS_WPEDANTIC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpedantic") endif() + # cmake 2.8 doesn't support C_STANDARD defined in set_target_properties + if (${CMAKE_VERSION} VERSION_LESS "3.2") + check_c_compiler_flag(-std=c99 HAS_C99) + if (HAS_C99) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") + endif() + endif() endif() if(APPLE)