Skip to content

Commit

Permalink
cmake: support old Cmake for -std=c99
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
rgetz committed Apr 26, 2020
1 parent da6ed18 commit a330cc1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
message(STATUS "cmake verison: ${CMAKE_VERSION}")
cmake_minimum_required(VERSION 2.8.7)
project(libiio C)

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit a330cc1

Please sign in to comment.