1%%%%%%%%%%%%%%%%%%%
2% XLiFE++ is an extended library of finite elements written in C++
3%     Copyright (C) 2014  Lunéville, Eric; Kielbasiewicz, Nicolas; Lafranche, Yvon; Nguyen, Manh-Ha; Chambeyron, Colin
4%
5%     This program is free software: you can redistribute it and/or modify
6%     it under the terms of the GNU General Public License as published by
7%     the Free Software Foundation, either version 3 of the License, or
8%     (at your option) any later version.
9%     This program is distributed in the hope that it will be useful,
10%     but WITHOUT ANY WARRANTY; without even the implied warranty of
11%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12%     GNU General Public License for more details.
13%     You should have received a copy of the GNU General Public License
14%     along with this program.  If not, see <http://www.gnu.org/licenses/>.
15%%%%%%%%%%%%%%%%%%%
16
17\section{General purpose}
18
19With \xlifepp, we want to develop a C++ library, that we can use easily and at list on Windows, Unix and Mac OS platforms. The last two are very similar, whereas the Windows platform is a very different working environment as far as compiling is concerned. Generally, developing code on Windows means the use of an IDE, such as Visual Dev C++, Eclipse, CodeBlocks, \ldots On Unix and Mac OS, you can use a "basic" text editor and Gnu Makefile. You can also use IDE, such as XCode on Mac OS.
20
21As we do not want to impose an IDE, the multi-platform solution comes with \cmake !!!
22
23\section{\cmake and IDE generators}
24
25\subsection{\cmake and Windows}
26
27It is very easy to have a IDE generator with \cmake. The GUI was very well thought. The most important part is to give the path to the CMakeLists.txt file.
28
29\subsection{\cmake and Unix or Mac OS}
30
31If you does not want to use an IDE, you just have to execute the following command :
32
33\begin{lstlisting}
34cmake PATH_TO_CMakeLists.txt
35\end{lstlisting}
36
37\subsection{New files and IDE generators}
38
39When you change the name of some source files or delete some source files or create source files, you have to rerun \cmake to take them into account. If you modify file contents, it is unnecessary.
40
41This means you have to rebuild the IDE generator you use. A new file will not be detected and compiled.
42
43\section{\cmake and \xlifepp}
44
45Whatever your OS or IDE choice, you may have to go to the {\tt build} directory to launch \cmake. As a result, every file generated by \cmake will be in this directory, even for a IDE generator. The {\tt CMakeLists.txt} file is in the \xlifepp root directory.
46
47\medskip
48
49How does the {\tt CMakeLists.txt} work ?
50
51\subsection{Building libraries}
52
53First, it lists all files in the {\tt src} directory with extension .hpp or .cpp and extracts the names of the direct sub-directories of {\tt src}. This list is the list of the libraries to compile.
54
55Then, for each library, it lists all files with extension .hpp or .cpp and builds targets for the library generation. The name of the lib is libXXX.a where XXX is the name of the directory in the lib list and is supposed to be placed in the {\tt lib} directory. More precisely, it will be in subdirectories of {\tt lib} whose names are built according to the compiler used (version included), the architecture of the computer, and the build type (debug, release, \ldots).
56
57\subsection{Building and linking test executables}
58
59\cmake lists all files in the {\tt tests} directory with pattern XXX/XXX\_YYY.cpp. Each of these files correspond to a function having the same name. \cmake uses a template file to build the test main program : main\_XXX\_YYY.cpp. The main function will take an argument, edit or check, to define the value of the boolean check.
60
61These files are placed in the sub-directory {\tt build} of the directory {\tt tests} are are linked to an executable. Furthermore, one additional file is generated : main\_test.cpp to launch all tests.
62
63