1
+ macro (subDirList result curdir)
2
+ file (GLOB children ${curdir} ${curdir} /*)
3
+ set (dirlist "" )
4
+ foreach (child ${children} )
5
+ if (IS_DIRECTORY ${child} )
6
+ list (APPEND dirlist ${child} )
7
+ endif ()
8
+ endforeach ()
9
+ list (REMOVE_ITEM dirlist "${curdir} " )
10
+ set (${result} ${dirlist} )
11
+ endmacro ()
12
+
13
+ macro (subDirListMask result curdir mask)
14
+ file (GLOB children ${curdir} ${curdir} /${mask} )
15
+ set (dirlist "" )
16
+ foreach (child ${children} )
17
+ if (IS_DIRECTORY ${child} )
18
+ list (APPEND dirlist ${child} )
19
+ endif ()
20
+ endforeach ()
21
+ list (REMOVE_ITEM dirlist "${curdir} " )
22
+ set (${result} ${dirlist} )
23
+ endmacro ()
24
+
25
+ macro (replaceExtension newPathVar oldPath newExtension)
26
+ string (FIND ${oldPath} "." found REVERSE )
27
+ if (NOT (${found} EQUAL -1))
28
+ string (SUBSTRING ${oldPath} 0 "${found} -1" ${newPathVar} )
29
+ else ()
30
+ set (${newPathVar} ${oldPath} )
31
+ endif ()
32
+
33
+ set (${newPathVar} "${${newPathVar} }.${newExtension} " )
34
+
35
+ endmacro ()
36
+
37
+ macro (setupOutputFile newPathVar sourceFile newExtension)
38
+ replaceExtension(${newPathVar}
39
+ ${sourceFile} ${newExtension}
40
+ )
41
+
42
+ replaceParent(${newPathVar}
43
+ ${${newPathVar} }
44
+ ${CMAKE_SOURCE_DIR}
45
+ ${PROJECT_BINARY_DIR}
46
+ )
47
+ endmacro ()
48
+
49
+ macro (createSubDirFor file)
50
+ get_filename_component (fileDir ${file} DIRECTORY )
51
+ if (NOT (EXISTS ${fileDir} ))
52
+ trace("Creating directory ${fileDir} " )
53
+ file (MAKE_DIRECTORY ${fileDir} )
54
+ endif ()
55
+ endmacro ()
56
+
57
+ macro (replaceParent newPathVar oldPath oldParent newParent)
58
+ string (REPLACE ${oldParent} ${newParent} ${newPathVar} ${oldPath} )
59
+ endmacro ()
60
+
61
+ macro (filesListMask result curdir mask)
62
+ trace("Looking for ${mask} files in ${curdir} ..." )
63
+ file (GLOB children ${curdir} ${curdir} /${mask} )
64
+ set (dirlist "" )
65
+ foreach (child ${children} )
66
+ if (NOT (IS_DIRECTORY ${child} ))
67
+ trace("Found ${child} " )
68
+ list (APPEND dirlist ${child} )
69
+ endif ()
70
+ endforeach ()
71
+ list (REMOVE_ITEM dirlist "${curdir} " )
72
+ set (${result} ${${result} } ${dirlist} )
73
+ endmacro ()
74
+
75
+ macro (subDirListRecursive result curdir)
76
+ set (dirlist "" )
77
+ set (dirlist2 "" )
78
+ subDirList(dirlist ${curdir} )
79
+ list (LENGTH dirlist current)
80
+ list (LENGTH dirlist2 new)
81
+ set (${result} ${dirlist} )
82
+ while (NOT (${current} EQUAL ${new} ))
83
+ set (dirlist2 "" )
84
+ foreach (d ${dirlist} )
85
+ if (NOT (${d} STREQUAL ${curdir} ) AND
86
+ NOT (${d} STREQUAL ${PROJECT_BINARY_DIR} )
87
+ )
88
+ subDirList(newDirList ${d} )
89
+ set (dirlist2 ${dirlist2} ${newDirList} )
90
+ endif ()
91
+ endforeach ()
92
+ set (tmp ${dirlist2} )
93
+ set (dirlist2 ${dirlist} )
94
+ set (dirlist ${tmp} )
95
+ list (LENGTH dirlist current)
96
+ list (LENGTH dirlist2 new)
97
+ set (${result} ${${result} } ${dirlist} )
98
+ endwhile ()
99
+ endmacro ()
100
+
101
+ macro (auxSources dir sourcesVar)
102
+ set (newSources "" )
103
+ aux_source_directory (${dir} newSources)
104
+ trace("Scanning sources at ${dir} " )
105
+ trace("Found sources: ${newSources} " )
106
+ set (${sourcesVar} ${${sourcesVar} } ${newSources} )
107
+ endmacro ()
0 commit comments