Chi-Tech
devman_01_01_addingcode.h
Go to the documentation of this file.
1
/**\page DevManAddingCode Adding code to the system
2
3
The underlying build system used by ChiTech is cmake and its entry point
4
is the *CMakeLists.txt* file located in the root directory.
5
6
\section devman0_sec0 So you want to add your own code
7
8
\subsection devman0_sec0_1 Step 1 - Create your directory
9
10
Create a directory where you want to add your code. For example, let us
11
suppose you want to add a new module. Add a directory to the
12
CHI_TECH/CHI_MODULES folder:
13
14
\image html devman_newdir.gif "Creating a new directory" width=600px
15
16
\subsection devman0_sec0_2 Step 2 - If there is no CMakeLists.txt, create one
17
18
In the folder you just created, make a file called "CMakeLists.txt" and
19
add the following code to it
20
21
\code
22
file (GLOB_RECURSE MORE_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.cc")
23
24
set(SOURCES ${SOURCES} ${MORE_SOURCES} PARENT_SCOPE)
25
\endcode
26
27
This code will get executed by cmake and will recursively find all files
28
with a .cc extension and compile it.
29
30
\subsection devman0_sec0_3 Step 3 - Create your source code
31
32
Create appropriate headers and source code.
33
34
\subsection devman0_sec0_4 Step 4 - Add the folder to the master CMakeLists.txt
35
36
The final step is to add the folder you created to the master *CMakeLists.txt*
37
document contained in the root folder. If the new folder is already recursed by
38
a higher level *CMakeLists.txt* file then this step is not needed.
39
40
Look for the line with comment "Define source directories" and your folder
41
to the "add_subdirectory" logic:
42
43
\code
44
#================================================ Define source directories
45
set(SOURCES "${CHI_TECH_DIR}/chi_tech_main.cc")
46
add_subdirectory("${CHI_TECH_DIR}/CHI_CONSOLE")
47
add_subdirectory("${CHI_TECH_DIR}/CHI_LIB")
48
add_subdirectory("${CHI_TECH_DIR}/CHI_LUA")
49
add_subdirectory("${CHI_TECH_DIR}/CHI_MATH")
50
add_subdirectory("${CHI_TECH_DIR}/CHI_PHYSICS")
51
add_subdirectory("${CHI_TECH_DIR}/CHI_GRAPH")
52
53
add_subdirectory("${CHI_TECH_DIR}/CHI_TIMER")
54
add_subdirectory("${CHI_TECH_DIR}/CHI_TOOLS")
55
add_subdirectory("${CHI_TECH_DIR}/CHI_MESH")
56
add_subdirectory("${CHI_TECH_DIR}/CHI_MPI")
57
add_subdirectory("${CHI_TECH_DIR}/chi::log")
58
59
add_subdirectory("${CHI_TECH_MOD}/CHI_MONTECARLON")
60
add_subdirectory("${CHI_TECH_MOD}/CHI_DIFFUSION")
61
add_subdirectory("${CHI_TECH_MOD}/CHI_NPTRANSPORT")
62
63
add_subdirectory("${CHI_TECH_MOD}/MyTestModule")
64
\endcode
65
66
\subsection devman0_sec0_5 Step 5 - Include headers and use the code
67
68
That's it! The cmake system needs to be run again by executing the
69
configure script.
70
71
\code
72
./configure.sh
73
\endcode
74
75
And your code will be linked in. Now just make as usual.
76
77
\code
78
make -j5
79
\endcode
80
81
\date Aug 19, 2019
82
83
*/
doc
PAGES
ProgrammersManual
devman_01_01_addingcode.h
Generated by
1.9.3