MakePlan.cmake 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. function(makePlan abi outputLocation)
  2. if(NOT abi)
  3. file(GLOB abidir build/*/include/*)
  4. foreach(dir ${abidir})
  5. if(IS_DIRECTORY "${dir}")
  6. string(REGEX REPLACE "^.*/([^/]*)$" "\\1" abi "${dir}")
  7. endif()
  8. endforeach()
  9. endif()
  10. set(impls)
  11. set(types)
  12. file(GLOB files build/*/include/*/*.h)
  13. foreach(header ${files})
  14. file(STRINGS ${header} content)
  15. foreach(line ${content})
  16. if ("${line}" MATCHES "#define .*_IMPLEMENTATION \"")
  17. string(REGEX REPLACE "#define .*_IMPLEMENTATION (\".*\")" "\\1" impl "${line}")
  18. list(APPEND impls "${impl}\n")
  19. endif()
  20. if ("${line}" MATCHES "^typedef ")
  21. list(APPEND types "\"${line}\"\n")
  22. endif()
  23. endforeach()
  24. endforeach()
  25. set(tmp)
  26. list(APPEND tmp "set(PLAN_IMPLEMENTATIONS\n")
  27. list(APPEND tmp "${impls}")
  28. list(APPEND tmp ")\n")
  29. list(APPEND tmp "set(PLAN_TYPES\n")
  30. list(APPEND tmp "${types}")
  31. list(APPEND tmp ")\n")
  32. string(REPLACE "\n;" "\n" tmpoutStr "${tmp}")
  33. if("${outputLocation}" STREQUAL "")
  34. set(outputLocation "cmake/plans/${abi}_plan.cmake")
  35. endif()
  36. message("Created new build plan for [${abi}]")
  37. message("${tempOutStr}")
  38. message("Writing plan to [${outputLocation}]")
  39. file(WRITE "${outputLocation}" "${tmpoutStr}")
  40. endfunction()