Debian Codegraph @

docs/src/cmake-files.txt

raw
1 /* */
2 /* KIM-API: An API for interatomic models */
3 /* Copyright (c) 2013--2022, Regents of the University of Minnesota. */
4 /* All rights reserved. */
5 /* */
6 /* Contributors: */
7 /* Ryan S. Elliott */
8 /* */
9 /* SPDX-License-Identifier: LGPL-2.1-or-later */
10 /* */
11 /* This library is free software; you can redistribute it and/or */
12 /* modify it under the terms of the GNU Lesser General Public */
13 /* License as published by the Free Software Foundation; either */
14 /* version 2.1 of the License, or (at your option) any later version. */
15 /* */
16 /* This library is distributed in the hope that it will be useful, */
17 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
18 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
19 /* Lesser General Public License for more details. */
20 /* */
21 /* You should have received a copy of the GNU Lesser General Public License */
22 /* along with this library; if not, write to the Free Software Foundation, */
23 /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
24 /* */
25
26 /* */
27 /* Release: This file is part of the kim-api.git repository. */
28 /* */
29
30 /**
31 \page cmake_files Explaination of CMake Files for %KIM API Items and Simulators
32
33 Previous Section: \ref implementation.
34
35 This section describes the content of [CMake](https://cmake.org) files
36 necessary for the configuration and build of %KIM API items (Model Drivers,
37 Portable Models, and Simulator Models) as well as for Simulators. Details are
38 also provided for Simulators that do not use the CMake build system.
39
40 - \link cmake_files_model_drivers Model Driver CMakeLists.txt files\endlink
41
42 - \link cmake_files_portable_model_using Portable Model Using a Driver
43 CMakeLists.txt files\endlink
44
45 - \link cmake_files_portable_model_standalone Portable Model (not using a
46 Driver) CMakeLists.txt files\endlink
47
48 - \link cmake_files_simulator_model Simulator Model CmakeLists.txt files\endlink
49
50 - \link cmake_files_simulators_with_cmake Simulators using CMake CmakeLists.txt
51 files\endlink
52
53 - \link make_files_simulators Simulators not using CMake\endlink
54
55
56
57 \anchor cmake_files_model_drivers
58 ## Model Driver CMakeLists.txt files
59
60 Here is the `CMakeLists.txt` file for the example Model Driver \link
61 ../examples/model-drivers/ex_model_driver_P_LJ ex_model_driver_P_LJ\endlink.
62
63 \dontinclude ex_model_driver_P_LJ/CMakeLists.txt
64 \skip cmake_minimum
65 \until target_sources
66
67 Let us go through this line by line to explain.
68
69 \dontinclude ex_model_driver_P_LJ/CMakeLists.txt
70 \skipline cmake_minimum
71
72 This line ensures that an appropriate version of CMake is being used.
73
74 \skip list
75 \until find_package
76
77 These lines tell CMake to find the settings for building %KIM API items with
78 the %KIM API library installed on the system.
79
80 \skipline kim_api_items_setup_before
81
82 This line performs various setup necessary to configure and build a Model
83 Driver item. (These settings must be performed before the `project` command on
84 the next line.)
85
86 \skipline project
87
88 This line tells CMake to create a "project" with name equal to the item's name
89 `ex_model_driver_P_LJ` and that the item will require a `Fortran` compiler to
90 be built.
91
92 \skipline kim_api_items_setup_after
93
94 This line performs various setup necessary to configure and build a Model
95 Driver item. (These settings must be performed after the `project` command on
96 the previous line.)
97
98 \skip add_kim_api
99 \until )
100
101 These lines register the item with the %KIM API CMake build system and provide
102 necessary metadata. The `NAME` argument is required and here the CMake
103 variable `PROJECT_NAME`, which was set as a result of the `project` command
104 (above), is used to provide the name of the Model Driver item.
105
106 The `CREATE_ROUTINE_NAME` argument specifies the identifier used to define the
107 KIM::ModelDriverCreate routine for the item. This argument is required.
108
109 The `CREATE_ROUTINE_LANGUAGE` argument specifies the programming language in
110 which the create routine is written (valid values are: `cpp`, `c`, and
111 `fortran`).
112
113 There is also an additional (optional) argument `METADATA_FILES`. This can be
114 set to a space separated list of file names that should be included with the
115 Model Driver item as metadata files. These metadata files will not be directly
116 used by the %KIM API in any way, but they may be accessed through the
117 KIM::Collections interface.
118
119 \skipline target_sources
120
121 This line associates the item's source code files with its CMake "target",
122 which is set to the value given for the `NAME` argument in the call to
123 `add_kim_api_model_driver_library`. After the `PRIVATE` keyword a space
124 separated list of source code file names can be given. This list of files
125 should contain all source code (not header) files that are necessary to compile
126 and build the Model Driver item. In this example there is just a single
127 Fortran soruce file with the same name as the item.
128
129
130 \anchor cmake_files_portable_model_using
131 ## Portable Model using a Model Driver CMakeLists.txt files
132
133 Here is the `CMakeLists.txt` file for the example Portable Model \link
134 ../examples/portable-models/ex_model_Ar_P_Morse ex_model_Ar_P_Morse\endlink.
135
136 \dontinclude ex_model_Ar_P_Morse/CMakeLists.txt
137 \skip cmake_minimum
138 \until PARAMETER
139 \skipline )
140
141 Let us go through this line by line to explain.
142
143 \dontinclude ex_model_Ar_P_Morse/CMakeLists.txt
144 \skipline cmake_minimum
145
146 This line ensures that an appropriate version of CMake is being used.
147
148 \skip list
149 \until find_package
150
151 These lines tell CMake to find the settings for building %KIM API items with
152 the %KIM API library installed on the system.
153
154 \skipline kim_api_items_setup_before
155
156 This line performs various setup necessary to configure and build a Portable
157 Model item. (These settings must be performed before the `project` command on
158 the next line.)
159
160 \skipline project
161
162 This line tells CMake to create a "project" with name equal to the item's name
163 `ex_model_Ar_P_Morse` and that the item does not explicitly require compiler to
164 be built.
165
166 \skipline kim_api_items_setup_after
167
168 This line performs various setup necessary to configure and build a Portable
169 Model item. (These settings must be performed after the `project` command on
170 the previous line.)
171
172 \skip add_kim_api
173 \until )
174
175 These lines register the item with the %KIM API CMake build system and provide
176 necessary metadata. The `NAME` argument is required and here the CMake
177 variable `PROJECT_NAME`, which was set as a result of the `project` command
178 (above), is used to provide the name of the Portable Model item.
179
180 The `DRIVER_NAME` argument specifies the Model Driver used used by Portable
181 Model item. This argument is required.
182
183 The `PARAMETER_FILES` argument specifies an ordered, space separated list of
184 parameter files required for use by the Model Driver. In this case there is
185 just a single parameter file, but in general a Model Driver may require any
186 number of such files. In addition to the number of parameter files, the Model
187 Driver also specifies the order in which they must be listed and the file
188 format(s) for their content.
189
190 There is also an additional (optional) argument `METADATA_FILES`. This can be
191 set to a space separated list of file names that should be included with the
192 Portable Model item as metadata files. These metadata files will not be
193 directly used by the %KIM API in any way, but they may be accessed through the
194 KIM::Collections interface.
195
196
197 \anchor cmake_files_portable_model_standalone
198 ## Portable Model (not using a Model Driver) CMakeLists.txt files
199
200 Here is the `CMakeLists.txt` file for the example Portable Model \link
201 ../examples/portable-models/ex_model_Ar_P_Morse_07C ex_model_Ar_P_Morse_07C\endlink.
202
203 \dontinclude ex_model_Ar_P_Morse_07C/CMakeLists.txt
204 \skip cmake_minimum
205 \until target_sources
206
207 Let us go through this line by line to explain.
208
209 \dontinclude ex_model_Ar_P_Morse_07C/CMakeLists.txt
210 \skipline cmake_minimum
211
212 This line ensures that an appropriate version of CMake is being used.
213
214 \skip list
215 \until find_package
216
217 These lines tell CMake to find the settings for building %KIM API items with
218 the %KIM API library installed on the system.
219
220 \skipline kim_api_items_setup_before
221
222 This line performs various setup necessary to configure and build a Portable
223 Model item. (These settings must be performed before the `project` command on
224 the next line.)
225
226 \skipline project
227
228 This line tells CMake to create a "project" with name equal to the item's name
229 `ex_model_Ar_P_Morse_07C` and that the item will require a `C` compiler to be
230 built.
231
232 \skipline kim_api_items_setup_after
233
234 This line performs various setup necessary to configure and build a Portable
235 Model item. (These settings must be performed after the `project` command on
236 the previous line.)
237
238 \skip add_kim_api
239 \until )
240
241 These lines register the item with the %KIM API CMake build system and provide
242 necessary metadata. The `NAME` argument is required and here the CMake
243 variable `PROJECT_NAME`, which was set as a result of the `project` command
244 (above), is used to provide the name of the Portable Model item.
245
246 The `CREATE_ROUTINE_NAME` argument specifies the identifier used to define the
247 KIM::ModelCreate routine for the item. This argument is required.
248
249 The `CREATE_ROUTINE_LANGUAGE` argument specifies the programming language in
250 which the create routine is written (valid values are: `cpp`, `c`, and
251 `fortran`).
252
253 There is also an additional (optional) argument `METADATA_FILES`. This can be
254 set to a space separated list of file names that should be included with the
255 Portable Model item as metadata files. These metadata files will not be
256 directly used by the %KIM API in any way, but they may be accessed through the
257 KIM::Collections interface.
258
259 \skipline target_sources
260
261 This line associates the item's source code files with its CMake "target",
262 which is set to the value given for the `NAME` argument in the call to
263 `add_kim_api_model_library`. After the `PRIVATE` keyword a space separated
264 list of source code file names can be given. This list of files should contain
265 all source code (not header) files that are necessary to compile and build the
266 Portable Model item. In this example there is just a single C soruce file with
267 the same name as the item.
268
269
270 \anchor cmake_files_simulator_model
271 ## Simulator Model CMakeLists.txt files
272
273 Here is the `CMakeLists.txt` file for the example Simulator Model \link
274 ../examples/simulator-models/Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu
275 Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu\endlink.
276
277 \dontinclude Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu/CMakeLists.txt
278 \skip cmake_minimum
279 \until PARAMETER
280 \skipline )
281
282 Let us go through this line by line to explain.
283
284 \dontinclude Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu/CMakeLists.txt
285 \skipline cmake_minimum
286
287 This line ensures that an appropriate version of CMake is being used.
288
289 \skip list
290 \until find_package
291
292 These lines tell CMake to find the settings for building %KIM API items with
293 the %KIM API library installed on the system.
294
295 \skipline kim_api_items_setup_before
296
297 This line performs various setup necessary to configure and build a Simulator
298 Model item. (These settings must be performed before the `project` command on
299 the next line.)
300
301 \skipline project
302
303 This line tells CMake to create a "project" with name equal to the item's name
304 `Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu` and that the item will not
305 explicitly require a compiler to be built.
306
307 \skipline kim_api_items_setup_after
308
309 This line performs various setup necessary to configure and build a Simulator
310 Model item. (These settings must be performed after the `project` command on
311 the previous line.)
312
313 \skip add_kim_api
314 \until )
315
316 These lines register the item with the %KIM API CMake build system and provide
317 necessary metadata. The `NAME` argument is required and here the CMake
318 variable `PROJECT_NAME`, which was set as a result of the `project` command
319 (above), is used to provide the name of the Simulator Model item.
320
321 The `SM_SPEC_FILE` argument specifies the name of the \ref
322 kim_api_sm_schema_version_1 "KIM API/SMI Specification File" for the Simulator
323 Model.
324
325 The `PARAMETER_FILES` argument specifies an ordered, space separated list of
326 parameter files required for use by the Simulator Model. In this case there is
327 just a single parameter file, but in general a Simulator Model may require any
328 number of such files. In addition to the number of parameter files, the
329 Simulator Model also specifies the order in which they must be listed and the
330 file format(s) for their content.
331
332 There is also an additional (optional) argument `METADATA_FILES`. This can be
333 set to a space separated list of file names that should be included with the
334 Simulator Model item as metadata files. These metadata files will not be
335 directly used by the %KIM API in any way, but they may be accessed through the
336 KIM::Collections interface.
337
338
339 \anchor cmake_files_simulators_with_cmake
340 ## Simulators using CMake CMakeLists.txt files
341
342 \todo Add description of CMakeLists.txt files for simulators/projects that use
343 the %KIM-API library and use CMake.
344
345 For now, see \link ../examples/simulators/utility_forces_numer_deriv
346 utility_forces_numer_deriv\endlink and its CMakeLists.txt file given here.
347
348 \dontinclude utility_forces_numer_deriv/CMakeLists.txt
349 \skip cmake_minimum
350 \until target_link
351 \skipline )
352
353
354 \anchor make_files_simulators
355 ## Simulators not using CMake
356
357 \todo Add description of getting build details via `pkg-config` for
358 simulators/projects that use the %KIM-API library but do not use CMake.
359
360
361 Next Section: \ref version2_differences.
362
363 */