-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcmake_generate.py
More file actions
35 lines (28 loc) · 868 Bytes
/
cmake_generate.py
File metadata and controls
35 lines (28 loc) · 868 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import os
HEADER_TYPES = (".h", ".hpp", ".hxx")
SOURCE_TYPES = (".c", ".cpp", ".cxx")
ALL_TYPES = HEADER_TYPES + SOURCE_TYPES
def make_cmake():
tmp = []
for directory in { "include", "src" }:
for dirpath, dirnames, filenames in os.walk(directory):
for filename in filenames:
if filename.endswith(ALL_TYPES):
path = os.path.join(dirpath, filename)
tmp.append(os.path.normpath(path))
sources = []
for file in tmp:
name = file.replace("\\", "/")
sources.append(name)
sources.sort()
def do_make(a_filename, a_varname, a_files):
with open("cmake/{}.cmake".format(a_filename), "w", encoding="utf-8") as out:
out.write("set({}\n".format(a_varname))
for file in a_files:
out.write("\t{}\n".format(file))
out.write(")\n")
do_make("sourcelist", "SOURCES", sources)
def main():
make_cmake()
if __name__ == "__main__":
main()