Skip to content

Commit a330cc1

Browse files
committed
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 <[email protected]>
1 parent da6ed18 commit a330cc1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
message(STATUS "cmake verison: ${CMAKE_VERSION}")
12
cmake_minimum_required(VERSION 2.8.7)
23
project(libiio C)
34

@@ -77,6 +78,13 @@ if (CMAKE_COMPILER_IS_GNUCC)
7778
if (HAS_WPEDANTIC)
7879
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpedantic")
7980
endif()
81+
# cmake 2.8 doesn't support C_STANDARD defined in set_target_properties
82+
if (${CMAKE_VERSION} VERSION_LESS "3.2")
83+
check_c_compiler_flag(-std=c99 HAS_C99)
84+
if (HAS_C99)
85+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
86+
endif()
87+
endif()
8088
endif()
8189

8290
if(APPLE)

0 commit comments

Comments
 (0)