From 30e1e7af7c63db9b55f5a3cda977a6c032f0b132 Mon Sep 17 00:00:00 2001 From: Max Bruckner Date: Thu, 16 Mar 2017 01:09:26 +0100 Subject: [PATCH] CMake: Support cmake down to 2.8.5 --- CMakeLists.txt | 8 ++++++-- tests/CMakeLists.txt | 12 ++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3bfd03e..31e7928 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ set(CMAKE_LEGACY_CYGWIN_WIN32 0) -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.5) include(GNUInstallDirs) @@ -172,7 +172,11 @@ if(ENABLE_CJSON_TEST) # Disable -fsanitize=float-divide-by-zero for cJSON_test if (FLAG_SUPPORTED_fsanitizefloatdividebyzero) - target_compile_options(${TEST_CJSON} PRIVATE "-fno-sanitize=float-divide-by-zero") + if ("${CMAKE_VERSION}" VERSION_LESS "2.8.12") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-sanitize=float-divide-by-zero") + else() + target_compile_options(${TEST_CJSON} PRIVATE "-fno-sanitize=float-divide-by-zero") + endif() endif() if(ENABLE_CJSON_UTILS) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 484c676..35a27be 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -3,11 +3,19 @@ if(ENABLE_CJSON_TEST) # Disable -Werror for Unity if (FLAG_SUPPORTED_Werror) - target_compile_options(unity PRIVATE "-Wno-error") + if ("${CMAKE_VERSION}" VERSION_LESS "2.8.12") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error") + else() + target_compile_options(unity PRIVATE "-Wno-error") + endif() endif() # Disable -fvisibility=hidden for Unity if (FLAG_SUPPORTED_fvisibilityhidden) - target_compile_options(unity PRIVATE "-fvisibility=default") + if ("${CMAKE_VERSION}" VERSION_LESS "2.8.12") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=default") + else() + target_compile_options(unity PRIVATE "-fvisibility=default") + endif() endif() #copy test files -- GitLab