Skip to content

Commit 9d3f112

Browse files
Manual update.
1 parent 386e7c5 commit 9d3f112

File tree

4 files changed

+55
-2
lines changed

4 files changed

+55
-2
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ install-doc:
225225
doxygen
226226
-cd doc; sh Makedoc
227227
rsync -e ssh -r -z --progress --delete doc/classdesc $(DOCPREFIX)
228-
rsync -e ssh -r -z --progress --delete html/* $(DOCPREFIX)/doxygen
228+
rsync -e ssh -r -z --progress --delete html/ $(DOCPREFIX)/doxygen/
229229

230230
lcov:
231231
$(MAKE) clean

doc/classdesc-common.tex

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,59 @@
212212

213213
See the polymorph example, which uses this technique.
214214

215+
\psubsection{Using Classdesc: Method 3, inlining with CMake}\label{cmake-method}
216+
217+
Using Makefiles is ideal, as it is possible to generate Makefile
218+
dependencies automatically from the source code, and to create the
219+
generated .cd files automatically via a Makefile rule.
220+
221+
When using other systems, eg CMake, you will need to explicitly list
222+
the header files that need to be generated by classdesc. An example
223+
CMake function that is useful for this purpose is:
224+
225+
\begin{verbatim}
226+
function(classdesc)
227+
foreach(header ${ARGV})
228+
get_filename_component(stem ${header} NAME_WLE)
229+
set(source ${CMAKE_CURRENT_SOURCE_DIR}/${stem}.h)
230+
set(dest ${stem}.cd)
231+
add_custom_command(OUTPUT ${dest} MAIN_DEPENDENCY ${source} COMMAND ${CLASSDESC} -respect_private -typeName -i ${source} ParserSerialise ParserDeserialise >${dest})
232+
set(HEADERS ${HEADERS} ${stem}.cd)
233+
include_directories(SYSTEM ${CMAKE_CURRENT_BINARY_DIR})
234+
endforeach()
235+
endfunction()
236+
include_directories(SYSTEM ${CMAKE_BINARY_DIR})
237+
\end{verbatim}
238+
239+
Within each project's CMakeLists.txt file, simply declare the header
240+
files needing to be processed via a CLASSDESC line, eg
241+
\begin{verbatim}
242+
CLASSDESC(foo.h bla.h)
243+
\end{verbatim}
244+
245+
The .cd files are placed within the build directory, in a tree
246+
hierarchy corresponding to where the source header files. So if foo.h
247+
is found in \verb+include/somelib/foo.h+, the .cd is placed in the build
248+
directory (aka \verb+CMAKE_BINARY_DIR+) under
249+
\verb+include/somelib/foo.cd+. The last \verb+include_directories+
250+
ensures that the cd file can be found via
251+
\begin{verbatim}
252+
#include "include/somelib/foo.cd"
253+
\end{verbatim}
254+
255+
The above function, which is run at cmake time, creates a single rule
256+
dependency for every header file mentioned, such that alterations to
257+
the source header file will cause the .cd file to be rebuilt, a
258+
consequently the object file that includes it via being added the the
259+
\verb+HEADERS+ special variable.
260+
261+
Classdesc has been used with other build systems too, such a Visual Studio.
262+
The strategy there is to create a separate project which all others
263+
in the solution depend on. Thus all .cd files are regenerated at the start
264+
of the run if any dependent header file is changed. This is a little
265+
wasteful, but the classdesc preprocessor is generally so quick that it
266+
doesn't impact compile times much.
267+
215268
\psubsection{Synopsis of classdesc}
216269

217270
\begin{description}

doc/classdesc.ps

7.57 KB
Binary file not shown.

0 commit comments

Comments
 (0)