Skip to content

Instantly share code, notes, and snippets.

@mandyedi
Created November 30, 2021 22:44
Show Gist options
  • Save mandyedi/507abcc4b503e4d48f25bf1beb9e227d to your computer and use it in GitHub Desktop.
Save mandyedi/507abcc4b503e4d48f25bf1beb9e227d to your computer and use it in GitHub Desktop.
import sys
import os
# todo: add main entry
# todo: check arg length
# todo: dd readme comment
'''
Pattern
set(SOURCE_BRDFS)
src/BRDFs/BRDF.cpp
src/BRDFs/BRDF.h
src/BRDFs/GlossySpecular.cpp
src/BRDFs/GlossySpecular.h
src/BRDFs/Lambertian.cpp
src/BRDFs/Lambertian.h
)
set(SOURCE_CAMERAS)
src/Cameras/Camera.cpp
src/Cameras/Camera.h
src/Cameras/FishEye.cpp
src/Cameras/FishEye.h
)
...
source_group ("src/BRDFs" FILES ${SOURCE_BRDFS})
source_group ("src/Cameras" FILES ${SOURCE_CAMERAS})
...
add_library (libRTF STATIC
${SOURCE_BRDFS}
${SOURCE_CAMERAS}
...
)
'''
path = sys.argv[1]
print("path: {}".format(path))
directories = []
for root, dirs, files in os.walk(path):
if len(dirs) == 0:
last_index = root.rindex("\\")
dir_name = root[last_index+1:len(root)]
if len(files) == 0:
continue
directories.append(dir_name)
print("set (SOURCE_{}".format(dir_name.upper()))
for file in files:
print(" src/{}/{}".format(dir_name, file))
print(")\n")
for dir in directories:
print("source_group (\"src/{}\" FILES ${{SOURCE_{}}})".format(dir, dir.upper()))
print("\nadd_library (libRTF STATIC")
for dir in directories:
print(" ${{SOURCE_{}}}".format(dir.upper()))
print(")")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment