utils.cmake 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. include(CheckIncludeFiles)
  2. macro(check_header header)
  3. string(TOUPPER ${header} str1)
  4. string(REGEX REPLACE "[/.]" "_" str2 ${str1})
  5. set(str3 HAVE_${str2})
  6. check_include_files(${header} ${str3})
  7. if (${str3})
  8. set(${str3} 1)
  9. else()
  10. set(${str3} 0)
  11. endif()
  12. endmacro()
  13. include(CheckSymbolExists)
  14. macro(check_function function header)
  15. string(TOUPPER ${function} str1)
  16. set(str2 HAVE_${str1})
  17. check_symbol_exists(${function} ${header} ${str2})
  18. if (${str2})
  19. set(${str2} 1)
  20. else()
  21. set(${str2} 0)
  22. endif()
  23. endmacro()
  24. macro(list_source_directories srcs)
  25. unset(tmp)
  26. foreach(dir ${ARGN})
  27. aux_source_directory(${dir} tmp)
  28. endforeach()
  29. set(${srcs} ${tmp})
  30. list(FILTER ${srcs} EXCLUDE REGEX ".*_test\\.c")
  31. endmacro()
  32. macro(glob_headers_and_sources files)
  33. unset(tmp)
  34. foreach(dir ${ARGN})
  35. file(GLOB tmp ${dir}/*.h ${dir}/*.c ${dir}/*.hpp ${dir}/*.cpp)
  36. list(APPEND ${files} ${tmp})
  37. endforeach()
  38. list(FILTER ${files} EXCLUDE REGEX ".*_test\\.c")
  39. endmacro()