-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
146 lines (116 loc) · 4.93 KB
/
Makefile
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
CMAKE_FILES=$(shell find src -name "CMakeLists.txt")
CXX=g++
.PHONY: all
all : cmake-cheatsheet.pdf
cmake-cheatsheet.pdf : cmake-cheatsheet.tex $(CMAKE_FILES)
.PHONY: examples
examples : \
simple_executable \
static_library \
shared_library \
object_library \
find_package \
add_test \
headeronly_library \
import_library \
externalproject \
app_qt5 \
lib_install \
package
.PHONY: simple_executable
simple_executable :
(mkdir -p build/$@ ; cd build/$@ ; cmake -DCMAKE_CXX_COMPILER=$(CXX) ../../src/$@ ; cmake --build .)
.PHONY: static_library
static_library :
(mkdir -p build/$@ ; cd build/$@ ; cmake -DCMAKE_CXX_COMPILER=$(CXX) ../../src/$@ ; cmake --build .)
.PHONY: shared_library
shared_library :
(mkdir -p build/$@ ; cd build/$@ ; cmake -DCMAKE_CXX_COMPILER=$(CXX) ../../src/$@ ; cmake --build .)
.PHONY: object_library
object_library :
(mkdir -p build/$@ ; cd build/$@ ; cmake -DCMAKE_CXX_COMPILER=$(CXX) ../../src/$@ ; cmake --build .)
.PHONY: find_package
find_package :
(mkdir -p build/$@ ; cd build/$@ ; cmake -DCMAKE_CXX_COMPILER=$(CXX) ../../src/$@ ; cmake --build .)
.PHONY: add_test
add_test :
(mkdir -p build/$@ ; cd build/$@ ; cmake -DCMAKE_CXX_COMPILER=$(CXX) ../../src/$@ ; cmake --build .)
.PHONY: headeronly_library
headeronly_library :
(mkdir -p build/$@ ; cd build/$@ ; cmake -DCMAKE_CXX_COMPILER=$(CXX) ../../src/$@ ; cmake --build .)
.PHONY: import_library
import_library :
(mkdir -p build/$@ ; cd build/$@ ; cmake -DCMAKE_CXX_COMPILER=$(CXX) ../../src/$@ ; cmake --build .)
.PHONY: externalproject
externalproject :
(mkdir -p build/$@ ; cd build/$@ ; cmake -DCMAKE_CXX_COMPILER=$(CXX) ../../src/$@ ; cmake --build .)
.PHONY: app_qt5
app_qt5 :
(mkdir -p build/$@ ; cd build/$@ ; cmake -DCMAKE_CXX_COMPILER=$(CXX) ../../src/$@ ; cmake --build .)
.PHONY: lib_install
lib_install :
(mkdir -p build/$@ ; cd build/$@ ; cmake -DCMAKE_CXX_COMPILER=$(CXX) -DCMAKE_INSTALL_PREFIX=`pwd`/local -B build ../../src/$@ ; cmake --build build ; cmake --build build --target install)
.PHONY: package
package :
(mkdir -p build/$@ ; cd build/$@ ; cmake -DCMAKE_CXX_COMPILER=$(CXX) ../../src/$@ ; cmake --build . ; cpack -G ZIP)
.PHONY: clean
clean :
rm -f *.aux
rm -f *.log
rm -f *.out
rm -f *.pdf
rm -fr build
rm -f cmake-*.txt
rm -f sheet-*.txt
%.pdf : %.tex
pdflatex $<
# following targets are to list parts of the cheatsheet in order to compare
# them to the cmake help output. Example:
#
# $ make prepare-diff
# $ gvimdiff cmake-module.txt sheet-module.txt
#
list = @grep -E "cmake$(1)$(2)" cmake-cheatsheet.tex \
| grep -Ev "newcommand" \
| sed -e 's/^.*cmake$(1)$(2){\(.*\)}.*/\1/' \
| sort -u
listcmd = @grep -E "cmake$(1)" cmake-cheatsheet.tex \
| grep -Ev "newcommand" \
| sed -e 's/^.*cmake$(1){\([a-zA-Z0-9\_]*\)}.*/\1/' \
| sed -e 's/\\_/_/g' \
| sort -u
# ignore deprecated commands
cmakelist-command = @cmake --help-command-list \
| sort -u \
| grep -Ev "\<(build_name|exec_program|export_library_dependencies|install_files|install_programs|install_targets|load_command|make_directory|output_required_files|remove|subdir_depends|subdirs|use_mangled_mesa|utility_source|variable_requires|write_file)\>"
# ignore deprecated modules
cmakelist-module = @cmake --help-module-list \
| sort -u \
| grep -Ev "\<(CPackArchive|CPackBundle|CPackCygwin|CPackDeb|CPackDMG|CPackFreeBSD|CPackNSIS|CPackNuGet|CPackPackageMaker|CPackProductBuild|CPackRPM|CPackWIX)\>"
# ignore deprecated properties
cmakelist-property = @cmake --help-property-list \
| sort -u \
| grep -Ev "\<COMPILE_DEFINITIONS_<CONFIG>|\<(TEST_INCLUDE_FILE|POST_INSTALL_SCRIPT|PRE_INSTALL_SCRIPT)\>"
cmakelist-variable = @cmake --help-variable-list \
| sort -u
prepare-diff :
@$(call cmakelist-command) > cmake-command.txt
@$(call cmakelist-module) > cmake-module.txt
@$(call cmakelist-property) > cmake-property.txt
@$(call cmakelist-variable) > cmake-variable.txt
@$(call listcmd,command) > sheet-command.txt
@$(call list,module) > sheet-module.txt
@$(call list,prop,gbl) > sheet-property.tmp.txt
@$(call list,prop,dir) >> sheet-property.tmp.txt
@$(call list,prop,sourcefiles) >> sheet-property.tmp.txt
@$(call list,prop,cache) >> sheet-property.tmp.txt
@$(call list,prop,installedfiles) >> sheet-property.tmp.txt
@$(call list,prop,target) >> sheet-property.tmp.txt
@$(call list,prop,test) >> sheet-property.tmp.txt
@sort -u sheet-property.tmp.txt > sheet-property.txt
@rm sheet-property.tmp.txt
@$(call list,variable) > sheet-variable.txt
@-diff cmake-command.txt sheet-command.txt 1>/dev/null && rm cmake-command.txt sheet-command.txt ; true
@-diff cmake-module.txt sheet-module.txt 1>/dev/null && rm cmake-module.txt sheet-module.txt ; true
@-diff cmake-property.txt sheet-property.txt 1>/dev/null && rm cmake-property.txt sheet-property.txt ; true
@-diff cmake-variable.txt sheet-variable.txt 1>/dev/null && rm cmake-variable.txt sheet-variable.txt ; true