open-iscsi / target-isns

Target-isns is an iSNS client for the Linux LIO iSCSI target
GNU General Public License v2.0
16 stars 19 forks source link

Set C_STANDARD target property only for CMake 3.1 or newer #31

Closed printesoi closed 8 years ago

printesoi commented 8 years ago

The C_STANDARD target property was added in CMake 3.1. The compilation using older versions of CMake, like 2.8.12 on Ubuntu 14.04 fails because the -std=c99 C flag is not added. To fix the problem, for CMake older than 3.1, add the -std=c99 to CMAKE_C_FLAGS, for newer versions set C_STANDARD target property.

Signed-off-by: Victor Dodon dodonvictor@gmail.com

cvubrugier commented 8 years ago

Hi @printesoi and thank you for your contribution!

I think your patch can be made shorter by keeping the C_STANDARD property and adding -std=c99 to CMAKE_C_FLAGS if CMake is older than version 3.1. What I suggest is basically:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index edda781..935106f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,6 +10,9 @@ set(TARGET_ISNS_VERSION "0.6.1")

 cmake_minimum_required(VERSION 2.8)
 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror")
+if (CMAKE_VERSION VERSION_LESS "3.1")
+  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
+endif ()

 option(SUPPORT_SYSTEMD "Support service control via systemd" OFF)

Do you agree with this change and if so can you send me an updated pull request? I tested that it works with CMake 2.8.12 on Ubuntu 14.04.

Thanks again!

printesoi commented 8 years ago

Yes, I will send you immediately a new pull-request! Thank you very much for the feedback!