Added fallback macros for add_compile_options and add_link_options.

This commit is contained in:
Nathan Moinvaziri 2022-01-23 19:53:22 -08:00 committed by Hans Kristian Rosbach
parent 24291edbd6
commit 8927b8553d
2 changed files with 20 additions and 0 deletions

View File

@ -51,6 +51,7 @@ include(cmake/detect-install-dirs.cmake)
include(cmake/detect-coverage.cmake) include(cmake/detect-coverage.cmake)
include(cmake/detect-intrinsics.cmake) include(cmake/detect-intrinsics.cmake)
include(cmake/detect-sanitizer.cmake) include(cmake/detect-sanitizer.cmake)
include(cmake/fallback-macros.cmake)
if(CMAKE_TOOLCHAIN_FILE) if(CMAKE_TOOLCHAIN_FILE)
message(STATUS "Using CMake toolchain: ${CMAKE_TOOLCHAIN_FILE}") message(STATUS "Using CMake toolchain: ${CMAKE_TOOLCHAIN_FILE}")

View File

@ -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()