include(CheckCXXCompilerFlag) macro (append_compile_flag _flag) string (MAKE_C_IDENTIFIER ${_flag} _name) if (NOT __append_compile_flag_${_name}) check_cxx_compiler_flag (${_flag} __append_compile_flag_${_name}) if (__append_compile_flag_${_name}) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_flag}") set (__append_compile_flag_${_name} 1 INTERNAL) endif () endif () endmacro(append_compile_flag)