cmake_print_build_options.py 661 B

1234567891011121314151617181920212223242526
  1. # Apache License, Version 2.0
  2. # Simple utility that prints all WITH_* options in a CMakeLists.txt
  3. # Called by 'make help_features'
  4. import re
  5. import sys
  6. cmakelists_file = sys.argv[-1]
  7. def main():
  8. options = []
  9. for l in open(cmakelists_file, 'r').readlines():
  10. if not l.lstrip().startswith('#'):
  11. l_option = re.sub(r'.*\boption\s*\(\s*(WITH_[a-zA-Z0-9_]+)\s+\"(.*)\"\s*.*', r'\g<1> - \g<2>', l)
  12. if l_option != l:
  13. l_option = l_option.strip()
  14. if l_option.startswith('WITH_'):
  15. options.append(l_option)
  16. print('\n'.join(options))
  17. if __name__ == "__main__":
  18. main()