From: Nathan Moinvaziri Date: Mon, 24 Jan 2022 03:53:22 +0000 (-0800) Subject: Added fallback macros for add_compile_options and add_link_options. X-Git-Tag: 2.1.0-beta1~412 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8927b8553d2e3fd89582d1a9f91f0d24f4ce736d;p=thirdparty%2Fzlib-ng.git Added fallback macros for add_compile_options and add_link_options. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index b9de19a75..dfdc98bbb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,6 +51,7 @@ include(cmake/detect-install-dirs.cmake) include(cmake/detect-coverage.cmake) include(cmake/detect-intrinsics.cmake) include(cmake/detect-sanitizer.cmake) +include(cmake/fallback-macros.cmake) if(CMAKE_TOOLCHAIN_FILE) message(STATUS "Using CMake toolchain: ${CMAKE_TOOLCHAIN_FILE}") diff --git a/cmake/fallback-macros.cmake b/cmake/fallback-macros.cmake new file mode 100644 index 000000000..8bc6cf25b --- /dev/null +++ b/cmake/fallback-macros.cmake @@ -0,0 +1,19 @@ +# fallback-macros.cmake -- CMake fallback macros +# Copyright (C) 2022 Nathan Moinvaziri +# Licensed under the Zlib license, see LICENSE.md for details + +# CMake less than version 3.5.2 +if(NOT COMMAND add_compile_options) + macro(add_compile_options options) + string(APPEND CMAKE_C_FLAGS ${options}) + string(APPEND CMAKE_CXX_FLAGS ${options}) + endmacro() +endif() + +# CMake less than version 3.14 +if(NOT COMMAND add_link_options) + macro(add_link_options options) + string(APPEND CMAKE_EXE_LINKER_FLAGS ${options}) + string(APPEND CMAKE_SHARED_LINKER_FLAGS ${options}) + endmacro() +endif()