forked from revelationnow/PlannerPDF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
155 lines (131 loc) · 3.89 KB
/
CMakeLists.txt
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
146
147
148
149
150
151
152
153
154
155
cmake_minimum_required(VERSION 3.10)
if(NOT START_YEAR)
set(START_YEAR 2021)
endif()
if(NOT NUM_YEARS)
set(NUM_YEARS 5)
endif()
if(NOT PDF_FILENAME)
set(PDF_FILENAME planner)
endif()
if(NOT COMPRESSED_FILE)
set(COMPRESSED_FILE ${PDF_FILENAME}_compressed)
endif()
if(NOT Planner_PDF_Start_Day)
set(Planner_PDF_Start_Day 0)
elseif( ${Planner_PDF_Start_Day} GREATER 6)
message("Start day parameter exceeds 6, make sure to set it to something less. 0 : Sunday, 1 : Monday, 2 : Tuesday, 3 : Wednesday, 4 : Thursday, 5: Friday, 6 : Saturday")
set(Planner_PDF_Start_Day 0)
endif()
if(NOT Planner_PDF_VERSION_MAJOR)
set(Planner_PDF_VERSION_MAJOR 1)
endif()
if(NOT Planner_PDF_VERSION_MINOR)
set(Planner_PDF_VERSION_MINOR 1)
endif()
if(NOT Planner_PDF_Left_Handed)
set(Planner_PDF_Left_Handed 0)
endif()
if(NOT Planner_PDF_Portrait)
set(Planner_PDF_Portrait 0)
endif()
set(EXEC_NAME Planner_PDF)
# set the project name
project(Planner_PDF VERSION ${Planner_PDF_VERSION_MAJOR}.${Planner_PDF_VERSION_MINOR})
configure_file(include/planner_pdf_config.h.in planner_pdf_config.h)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# specify the C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# add the executable
add_executable(${EXEC_NAME} src/planner_pdf.cpp)
target_link_libraries( Planner_PDF hpdf )
target_include_directories( Planner_PDF PUBLIC
"${PROJECT_BINARY_DIR}"
)
target_include_directories( Planner_PDF PUBLIC
"${PROJECT_SOURCE_DIR}/include"
)
add_custom_target(
create
COMMAND ./${EXEC_NAME}
${START_YEAR}
${NUM_YEARS}
${PDF_FILENAME}.pdf
DEPENDS ${EXEC_NAME}
)
add_custom_target(
compress
COMMAND gs
-sDEVICE=pdfwrite
-dCompatibilityLevel=1.4
-dPDFSETTINGS=/prepress
-dDownsampleGrayImages=true
-dGrayImageResolution=72
-dNOPAUSE
-dQUIET
-dBATCH
-sOutputFile=${COMPRESSED_FILE}.pdf
${PDF_FILENAME}.pdf
DEPENDS create
)
add_custom_target(
clangformat
COMMAND clang-format
-style=file
-i
${PROJECT_SOURCE_DIR}/include/*.hpp
${PROJECT_SOURCE_DIR}/src/*
)
set(HANDEDNESS_TEXT "right")
if(${Planner_PDF_Left_Handed} MATCHES 1)
set(HANDEDNESS_TEXT "left")
endif()
set(START_DAY_TEXT "Sunday")
if(${Planner_PDF_Start_Day} MATCHES 1)
set(START_DAY_TEXT "Monday")
elseif(${Planner_PDF_Start_Day} MATCHES 2)
set(START_DAY_TEXT "Tueday")
elseif(${Planner_PDF_Start_Day} MATCHES 3)
set(START_DAY_TEXT "Wednesday")
elseif(${Planner_PDF_Start_Day} MATCHES 4)
set(START_DAY_TEXT "Thursday")
elseif(${Planner_PDF_Start_Day} MATCHES 5)
set(START_DAY_TEXT "Friday")
elseif(${Planner_PDF_Start_Day} MATCHES 6)
set(START_DAY_TEXT "Saturday")
endif()
set(PORTRAIT_TEXT "Landscape")
if(${Planner_PDF_Portrait} MATCHES 1)
set(PORTRAIT_TEXT "Portrait")
endif()
set(SAMPLE_FILE_TAG "${START_YEAR}_${NUM_YEARS}year_${START_DAY_TEXT}_start_${HANDEDNESS_TEXT}_handed_${PORTRAIT_TEXT}_v${Planner_PDF_VERSION_MAJOR}_${Planner_PDF_VERSION_MINOR}"
)
add_custom_target(
update_samples
COMMAND ${CMAKE_COMMAND} -E copy
${PDF_FILENAME}.pdf
'../samples/${HANDEDNESS_TEXT}_handed/${PORTRAIT_TEXT}/${START_DAY_TEXT}_start/v${Planner_PDF_VERSION_MAJOR}_${Planner_PDF_VERSION_MINOR}/${PDF_FILENAME}_${SAMPLE_FILE_TAG}.pdf'
DEPENDS create
)
add_custom_target(
update_compressed_samples
COMMAND ${CMAKE_COMMAND} -E copy
${COMPRESSED_FILE}.pdf
'../samples/${HANDEDNESS_TEXT}_handed/${PORTRAIT_TEXT}/${START_DAY_TEXT}_start/v${Planner_PDF_VERSION_MAJOR}_${Planner_PDF_VERSION_MINOR}/${COMPRESSED_FILE}_${SAMPLE_FILE_TAG}.pdf'
DEPENDS compress
)
unset(PDF_FILENAME)
unset(COMPRESSED_FILE)
unset(NUM_YEARS)
unset(START_YEAR)
unset(Planner_PDF_Portrait)
unset(Planner_PDF_Left_Handed)
unset(Planner_PDF_Start_Day)
unset(Planner_PDF_VERSION_MAJOR)
unset(Planner_PDF_VERSION_MINOR)
unset(EXEC_NAME)
unset(HANDEDNESS_TEXT)
unset(START_DAY_TEXT)
unset(PORTRAIT_TEXT)
unset(SAMPLE_FILE_TAG)