cleanCppProject  0.2.0
readme.md
Go to the documentation of this file.
1 # cleanCppProject
2 
3 This is a empty frame for project in C++. It should help to start a new project without caring much about project/build environment setup.
4 
5 
6 ## Important pages
7 
8 * [Design document](doc/design.md)
9 * [List of todos](./todo.html)
10 * [Basic directory structure](doc/directoryStructure.md)
11 * [How to start working](doc/start_working.md)
12 
13 \todo see how todo works
14 
15 ## How to convert this to your new project
16 
17 ~~~
18 git clone https://github.com/kracejic/cleanCppProject.git yourNewProject
19 cd yourNewProject
20 rm -rf .git
21 git init
22 git add .
23 git commit -m "first commit"
24 ~~~
25 
26 Do not forget to change name of *example* binary in `source/CMakeLists.txt` and `test/CMakeLists.txt`.
27 
28 ## Building instructions
29 
30 ### Prerequisites
31 
32 * CMake 3.2 and newer
33 * Compiler with support for C++14
34 * git - for downloading external resources
35 * Doxygen for docs (*Graphviz for more graphs in docs, PlantUML for more UML diagrams*, PlantUML needs java)
36 * clang-tools for static analysis and formating
37 * cppcheck for another static analysis
38 
39 #### Prerequisites on Linux
40 
41 * Arch Linux: `sudo pacman -S cmake g++ graphviz git clang clang-tools-extra cppcheck java-runtime-common`
42  * download plantuml.jar and have it somewhere where *PATH* points to
43 
44 * Ubuntu 16.04: `sudo apt-get install cmake g++ graphviz plantuml git clang clang-tidy clang-format`
45 
46 #### Prerequisites on Windows
47 
48 Two ways, which were tested:
49 
50 * msys2 based
51  * Minimal: `pacman -S cmake g++ git`
52  * Additional software `pacman -S clang mingw-w64-x86_64-clang-tools-extra mingw-w64-x86_64-clang-analyzer doxygen`
53  * For graphs in documentation install Graphviz (to `c:\Program Files\Graphviz`, so scripts can find it) and add its `bin` subdirectory to *PATH*, install java (have it on *PATH*), download PlantUML jar file and have it on *PATH*.
54 
55 * Microsoft Visual Studio
56  * Install cmake
57  * Install git
58  * For additional features install clang with tools, doxygen, graphviz, plantuml, java and add them to the PATH (*not tested*)
59 
60 
61 
62 ### Build on Linux
63 
64 Standard Makefiles:
65 ~~~
66 mkdir build ; cd build
67 cmake ..
68 make -j8
69 ~~~
70 
71 
72 Ninja build witch clang, build all+doc and install it to dist folder:
73 ~~~
74 mkdir build ; cd build
75 cmake -GNinja -DCMAKE_CXX_COMPILER="clang++" ..
76 ninja all doc && ninja install
77 ~~~
78 
79 
80 ### Build on windows
81 
82 #### Build on windows using MSYS2 + ninja
83 
84 On windows you should prefer Ninja since it is much faster than make (but has no color in shell).
85 
86 With gcc:
87 ~~~
88 mkdir build ; cd build
89 cmake -GNinja ..
90 ninja install
91 ~~~
92 
93 
94 #### Build on Windows using Microsoft Visual Studio 14
95 
96 First you may wan to change project name in main `CMakeLists.txt`. Just go to the folder with the project and create new directory and create project files with this:
97 
98 ~~~
99 mkdir buildmsvc
100 cd buildmsvc
101 cmake -G "Visual Studio 14 2015" ..
102 ~~~
103 
104 and you can now open a `.sln` file with Visual Studio. You need to right click on executable target and *Set as StartUp project*. To really see the console window you want to do *Start without debugging*, since when run in debug mode only, console widow is closed too fast.
105 
106 ### Targets
107 
108 *Note:* Availability of some targets depends on availability certain executables (e.g. clang-format for *format* target)
109 
110 * Build
111  * *all* (the default if no target is provided)
112  * *clean*
113  * *install* - install binaries into *CMAKE_INSTALL_PREFIX*
114  * *example* - build example binary
115  * *example-run* - build, install and run example binary (for your convenience)
116  * *run* - alias for example-run (in order to keep it short)
117 * Testing
118  * *check* - run whole test suite (see test/CMakeLists.txt)
119  * *checkVerbose* - run whole test suite (see test/CMakeLists.txt), but more verbose
120  * *unit* - build and run unit tests only (see test/CMakeLists.txt)
121  * *unitall* - same as previous, only prints even successful unit tests results
122 * Miscellaneous
123  * *doc* - build documentation (if doxygen is available)
124  * *format* - run clang-format on all source files (.clang-format in root directory of a project is used)
125 * Static analysis
126  * *tidy* - run clang static analysis on all sources
127  * *cppcheck* - call cppcheck on all files (another static analysis)
128 * External
129  * *external-update-all* - update all external sources/projects
130  * *external-update-Catch* - update Catch (Unit test library)
131 
132 
133 ### CMAKE variables
134 
135 * `-DCMAKE_INSTALL_PREFIX`= - location for installation
136 * `-DVERSION_HOST`= - build machine name, see Version::getVersionLong
137 * `-DCMAKE_BUILD_TYPE`=RelWithDebInfo - for build type
138 
139 
140 
141 
142 # License
143 
144 > Copyright (c) 2016 Kracejic
145 >
146 > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
147 >
148 > The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
149 >
150 > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.