This repository was archived by the owner on Dec 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdbstruct.cmake
More file actions
181 lines (151 loc) · 4.89 KB
/
dbstruct.cmake
File metadata and controls
181 lines (151 loc) · 4.89 KB
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# enable/disable cmake debug messages related to this pile
set (DBSTRUCT_DEBUG_MSG OFF)
# make sure support code is present; no harm
# in including it twice; the user, however, should have used
# pileInclude() from pile_support.cmake module.
include(pile_support)
# initialize this module
macro (dbstructInit
dbstruct__use_mode)
# default name
if (NOT DBSTRUCT_INIT_NAME)
set(DBSTRUCT_INIT_NAME "DbStruct")
endif ()
# compose the list of headers and sources
set(DBSTRUCT_HEADERS
"dbobject.h"
"dbtaew.h"
"dbrecord.h"
"dbview.h"
"dbcolumn.h"
"dbtable.h"
"dbstruct.h")
set(DBSTRUCT_SOURCES
"dbobject.cc"
"dbtaew.cc"
"dbrecord.cc"
"dbview.cc"
"dbcolumn.cc"
"dbtable.cc"
"dbstruct.cc")
set(DBSTRUCT_QT_MODS
Core Sql)
pileSetSources(
"${DBSTRUCT_INIT_NAME}"
"${DBSTRUCT_HEADERS}"
"${DBSTRUCT_SOURCES}")
pileSetCommon(
"${DBSTRUCT_INIT_NAME}"
"0;0;1;d"
"ON"
"${dbstruct__use_mode}"
""
"category1"
"tag1;tag2")
find_package(PythonInterp)
FILE(GLOB DBSTRUCT_TEMPLATE_H
"${DBSTRUCT_SOURCE_DIR}/qt-templates/*.h.template")
FILE(GLOB DBSTRUCT_TEMPLATE_CC
"${DBSTRUCT_SOURCE_DIR}/qt-templates/*.cc.template")
endmacro ()
# ============================================================================
# Create a target that generates .sql from .xml
#
# The command that will be execute will resemble
# python pileschema.py sql --schema=PileSchema.xsd input.xml outputdir
#
macro (dbstructModelToSql
dbstruct__xml
dbstruct__output
dbstruct__target)
if (NOT PYTHONINTERP_FOUND)
message (FATAL_ERROR "Python interpreter was not found; can't use dbstructModelToSql without it")
endif()
unset(dbstruct__cmd)
set(dbstruct__cmd "${PYTHON_EXECUTABLE}"
"${DBSTRUCT_SOURCE_DIR}/pileschema.py"
"sql"
"--schema=${DBSTRUCT_SOURCE_DIR}/PileSchema.xsd"
"${dbstruct__xml}"
"${dbstruct__output}")
add_custom_target(
"${dbstruct__target}"
${dbstruct__cmd}
DEPENDS
"${DBSTRUCT_SOURCE_DIR}/pileschema.py"
"${dbstruct__xml}"
WORKING_DIRECTORY
"${CMAKE_CURRECT_BINARY_DIR}"
COMMENT "Expanding Sql models"
VERBATIM
SOURCES
"${DBSTRUCT_SOURCE_DIR}/pileschema.py"
"${dbstruct__xml}")
# also generate this right now so CMake finds files
# generated by this process
execute_process(
COMMAND "${dbstruct__cmd}"
WORKING_DIRECTORY
"${CMAKE_CURRECT_BINARY_DIR}"
OUTPUT_QUIET)
endmacro ()
# ============================================================================
# Create a target that generates C++ source files from .xml
#
# The command that will be execute will resemble
# python pileschema.py cpp --driver=qt --namespace=Xxx input.xml outputfile
#
macro (dbstructModelToQt
dbstruct__xml
dbstruct__output
dbstruct__target
dbstruct__namespace
dbstruct__include
dbstruct__export
dbstruct__template)
if (NOT PYTHONINTERP_FOUND)
message (FATAL_ERROR "Python interpreter was not found; can't use dbstructModelToQt without it")
endif()
unset(dbstruct__template_used)
set(dbstruct__template_used "${dbstruct__template}")
if(NOT dbstruct__template_used)
set(dbstruct__template_used "${DBSTRUCT_SOURCE_DIR}/qt-templates")
endif()
unset(dbstruct__cmd)
set(dbstruct__cmd "${PYTHON_EXECUTABLE}"
"${DBSTRUCT_SOURCE_DIR}/pileschema.py"
"cpp"
"--driver=qt"
"--namespace=${dbstruct__namespace}"
"--schema=${DBSTRUCT_SOURCE_DIR}/PileSchema.xsd"
"--templates=${dbstruct__template_used}"
"--exportm=${dbstruct__export}"
"--importh=${dbstruct__include}"
"${dbstruct__xml}"
"${dbstruct__output}")
add_custom_target(
"${dbstruct__target}"
${dbstruct__cmd}
DEPENDS
"${DBSTRUCT_SOURCE_DIR}/pileschema.py"
"${dbstruct__xml}"
"${DBSTRUCT_TEMPLATE_H}"
"${DBSTRUCT_TEMPLATE_CC}"
WORKING_DIRECTORY
"${CMAKE_CURRECT_BINARY_DIR}"
COMMENT "Expanding Sql models"
VERBATIM
SOURCES
"${DBSTRUCT_SOURCE_DIR}/pileschema.py"
"${dbstruct__xml}"
"${DBSTRUCT_TEMPLATE_H}"
"${DBSTRUCT_TEMPLATE_CC}")
# also generate this right now so CMake finds files
# generated by this process
execute_process(
COMMAND "${dbstruct__cmd}"
WORKING_DIRECTORY
"${CMAKE_CURRECT_BINARY_DIR}"
OUTPUT_QUIET)
endmacro ()
# ============================================================================