Chi-Tech
devman_01_01_addingcode.h
Go to the documentation of this file.
1/**\page DevManAddingCode Adding code to the system
2
3The underlying build system used by ChiTech is cmake and its entry point
4is 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
10Create 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
18In the folder you just created, make a file called "CMakeLists.txt" and
19add the following code to it
20
21\code
22file (GLOB_RECURSE MORE_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.cc")
23
24set(SOURCES ${SOURCES} ${MORE_SOURCES} PARENT_SCOPE)
25\endcode
26
27This 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
32Create appropriate headers and source code.
33
34\subsection devman0_sec0_4 Step 4 - Add the folder to the master CMakeLists.txt
35
36The 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
40Look for the line with comment "Define source directories" and your folder
41to the "add_subdirectory" logic:
42
43\code
44#================================================ Define source directories
45set(SOURCES "${CHI_TECH_DIR}/chi_tech_main.cc")
46add_subdirectory("${CHI_TECH_DIR}/CHI_CONSOLE")
47add_subdirectory("${CHI_TECH_DIR}/CHI_LIB")
48add_subdirectory("${CHI_TECH_DIR}/CHI_LUA")
49add_subdirectory("${CHI_TECH_DIR}/CHI_MATH")
50add_subdirectory("${CHI_TECH_DIR}/CHI_PHYSICS")
51add_subdirectory("${CHI_TECH_DIR}/CHI_GRAPH")
52
53add_subdirectory("${CHI_TECH_DIR}/CHI_TIMER")
54add_subdirectory("${CHI_TECH_DIR}/CHI_TOOLS")
55add_subdirectory("${CHI_TECH_DIR}/CHI_MESH")
56add_subdirectory("${CHI_TECH_DIR}/CHI_MPI")
57add_subdirectory("${CHI_TECH_DIR}/chi::log")
58
59add_subdirectory("${CHI_TECH_MOD}/CHI_MONTECARLON")
60add_subdirectory("${CHI_TECH_MOD}/CHI_DIFFUSION")
61add_subdirectory("${CHI_TECH_MOD}/CHI_NPTRANSPORT")
62
63add_subdirectory("${CHI_TECH_MOD}/MyTestModule")
64\endcode
65
66\subsection devman0_sec0_5 Step 5 - Include headers and use the code
67
68That's it! The cmake system needs to be run again by executing the
69configure script.
70
71\code
72./configure.sh
73\endcode
74
75And your code will be linked in. Now just make as usual.
76
77\code
78make -j5
79\endcode
80
81\date Aug 19, 2019
82
83 */