CheckFunctionKeywords.cmake 560 B

123456789101112131415
  1. include(CheckCSourceCompiles)
  2. macro(check_function_keywords _wordlist)
  3. set(${_result} "")
  4. foreach(flag ${_wordlist})
  5. string(REGEX REPLACE "[-+/ ()]" "_" flagname "${flag}")
  6. string(TOUPPER "${flagname}" flagname)
  7. set(have_flag "HAVE_${flagname}")
  8. check_c_source_compiles("${flag} void func(); void func() { } int main() { func(); return 0; }" ${have_flag})
  9. if(${have_flag} AND NOT ${_result})
  10. set(${_result} "${flag}")
  11. # break()
  12. endif(${have_flag} AND NOT ${_result})
  13. endforeach(flag)
  14. endmacro(check_function_keywords)