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