39 lines
1.1 KiB
CMake
39 lines
1.1 KiB
CMake
include_guard(GLOBAL)
|
||
|
||
# Добавление флага к списку используемых после проверки
|
||
# возможности его использования текущим компилятором
|
||
# Основано на https://github.com/bluescarni/yacma
|
||
include(CheckCXXCompilerFlag)
|
||
|
||
macro(check_enable_cxx_compiler_flag FLAG)
|
||
set(options)
|
||
set(oneValueArgs TARGET)
|
||
set(multiValueArgs)
|
||
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||
|
||
set(CMAKE_REQUIRED_QUIET TRUE)
|
||
check_cxx_compiler_flag("${FLAG}" check_cxx_flag)
|
||
unset(CMAKE_REQUIRED_QUIET)
|
||
|
||
if(check_cxx_flag)
|
||
myx_message_notice("'${FLAG}': flag is supported.")
|
||
if(ARG_TARGET)
|
||
target_compile_options(${ARG_TARGET} PUBLIC ${FLAG})
|
||
else()
|
||
add_compile_options(${FLAG})
|
||
endif()
|
||
else()
|
||
myx_message_status("'${FLAG}': flag is NOT supported.")
|
||
endif()
|
||
|
||
unset(check_cxx_flag CACHE)
|
||
foreach(__iter IN LISTS oneValueArgs multiValueArgs)
|
||
unset(ARG_${__iter})
|
||
endforeach()
|
||
unset(ARG_UNPARSED_ARGUMENTS)
|
||
unset(multiValueArgs)
|
||
unset(oneValueArgs)
|
||
unset(options)
|
||
endmacro()
|
||
|