@@ -14,93 +14,66 @@ works.
14
14
15
15
[ TOC]
16
16
17
- <br >
18
-
19
17
# Software
20
18
Requirements:
21
19
- gcc >= 11 or clang >= 17
22
20
- cmake >= 3.16
23
21
- git
24
22
25
- ## Installing GCC
26
-
27
- Sharg requires GCC >= 11 or LLVM/Clang >= 17. Current versions of VisualStudio/MSVC are ** not yet supported** .
28
- We will briefly explain how to install GCC-11 (or the latest GCC if such an option is available) on some popular
29
- operating systems. We recommend using the latest version of GCC available. For more information, refer to your
30
- operating system's documentation.
23
+ ## Installing a Compiler
31
24
32
- \startcollapsible{Linux-based}
33
-
34
- #### Ubuntu >= 22.04
35
- ``` bash
36
- # Installs default compiler version (gcc-11 for Ubuntu 22.04).
37
- sudo apt install g++
38
- # To install gcc-12, follow below instructions.
39
- ```
25
+ Sharg requires GCC >= 11 or LLVM/Clang >= 17. Presently, VisualStudio/MSVC is ** not supported** .
26
+ We'll offer a brief tutorial on compiler updates through common package managers and suggest some web-based
27
+ alternatives. For further details, consult your OS documentation.
40
28
41
- #### Ubuntu < 22.04
29
+ <div class =" tabbed " >
30
+ - <b class =" tab-title " >Ubuntu</b >
42
31
``` bash
32
+ # Installs gcc-13
43
33
sudo add-apt-repository --no-update --yes ppa:ubuntu-toolchain-r/ppa
44
34
sudo add-apt-repository --no-update --yes ppa:ubuntu-toolchain-r/test
45
35
sudo apt-get update
46
- sudo apt install g++-11
36
+ sudo apt install g++-13
47
37
```
48
-
49
- #### Using [ conda ] ( https://conda.io )
38
+ See https://apt.llvm.org/ if you prefer to use LLVM's Clang.
39
+ - < b class = " tab-title " >Conda</ b >
50
40
To avoid interference with system packages, we recommend creating a new environment when using conda.
51
41
``` bash
52
42
conda create -n conda_gcc_env -c conda-forge gcc_linux-64
53
43
conda activate conda_gcc_env
54
44
```
55
45
This will put GCC in a separate environment ` conda_gcc_env ` which can be activated via ` conda activate conda_gcc_env `
56
46
and deactivated via ` conda deactivate ` .
57
-
58
- \endcollapsible
59
-
60
- \startcollapsible{macOS}
61
-
62
- #### Using [ Homebrew] ( https://brew.sh/ )
47
+ - <b class =" tab-title " >Homebrew</b >
63
48
``` bash
64
- brew install gcc@11
49
+ brew install gcc@13
50
+ brew install llvm@17
65
51
```
66
-
67
- #### Using [ MacPorts] ( https://www.macports.org/ )
52
+ - <b class =" tab-title " >Macports</b >
68
53
``` bash
69
- sudo port install gcc11
54
+ sudo port install gcc13
55
+ sudo port install llvm-17
70
56
```
71
-
72
- \endcollapsible
73
-
74
- \startcollapsible{Windows}
75
-
76
- #### Using [ WSL] ( https://docs.microsoft.com/en-us/windows/wsl/about )
57
+ - <b class =" tab-title " >Windows</b >
77
58
The Windows Subsystem for Linux offers an easy way to run a Linux distribution under Windows.
78
59
Follow [ Microsoft's setup guide] ( https://docs.microsoft.com/en-us/windows/wsl/about ) to install WSL and then follow
79
60
the steps listed for Linux-based systems.
80
-
81
- \endcollapsible
82
-
83
- \startcollapsible{Browser-based}
84
-
85
- #### Using [ gitpod.io] ( https://gitpod.io/#https://github.com/seqan/sharg-parser/ )
86
- [ gitpod.io] ( https://gitpod.io ) allows you to edit, compile and run code from within your browser. The free version
87
- includes 50 hours of use per month, which is plenty for our tutorials. A GitHub account is required.
88
- [ Click here] ( https://gitpod.io/#https://github.com/seqan/sharg-parser/ ) to open Sharg in gitpod.
89
-
90
- <!-- Codespaces are currently not free. Revisit in the future.
91
- #### Using [GitHub codespaces](https://github.com/codespaces)
92
- GitHub offers a service similar to gitpod. Codespaces are currently in **public beta** and may not be available to
93
- everyone. [Click here](https://github.com/codespaces) to check for availability.
94
-
61
+ - <b class =" tab-title " >gitpod.io</b >
62
+ [ gitpod.io] ( https://gitpod.io ) allows you to edit, compile and run code from within your browser. The free version includes 50
63
+ hours of use per month, which is plenty for our tutorials. A GitHub account is required.
64
+ [ Click here] ( https://gitpod.io/#https://github.com/seqan/sharg-parser ) to open Sharg in gitpod.
65
+ - <b class =" tab-title " >GitHub Codespaces</b >
66
+ [ GitHub Codespaces] ( https://github.com/codespaces ) offer a service similar to gitpod, including a free monthly quota.
67
+ [ Click here] ( https://codespaces.new/seqan/sharg-parser ) to open Sharg in Codespaces.
95
68
Please note that you may have to manually clone the submodules by running ` git submodule update --init ` .
96
- -->
97
69
98
- \endcollapsible
70
+ </ div >
99
71
100
- \attention After installing, ` g++ --version ` should print the desired version.
101
- If not, you may have to use, for example, ` g++-11 --version ` or even specify the full path to your compiler.
72
+ <br >
73
+ \note After installing, ` g++ --version ` should print the desired GCC version.
74
+ If not, you may have to use, for example, ` g++-11 --version ` or even specify the full path to your compiler.
102
75
103
- Similarly, you may need to install CMake and git, e.g. ` apt install cmake git ` .
76
+ Similarly, you may need to install CMake and git, e.g. ` sudo apt install cmake git` .
104
77
105
78
# Directory Structure
106
79
In this section we will use the ` tree ` command to show the directory structure. This program may not be installed
@@ -116,16 +89,13 @@ tutorial
116
89
└── source
117
90
```
118
91
119
- To set these directories up you can follow this script:
92
+ To set these directories up you can follow this script (note the < b > \- -recurse-submodules</ b > when cloning Sharg) :
120
93
``` bash
121
94
mkdir tutorial
122
95
cd tutorial
123
96
mkdir build
124
97
mkdir source
125
- git clone https://github.com/seqan/sharg-parser.git
126
- cd sharg-parser
127
- git submodule update --init
128
- cd ..
98
+ git clone --recurse-submodules https://github.com/seqan/sharg-parser.git
129
99
```
130
100
131
101
The output of the command ` tree -L 2 ` should now look like this:
@@ -135,18 +105,9 @@ The output of the command `tree -L 2` should now look like this:
135
105
├── sharg-parser
136
106
│ ├── CHANGELOG.md
137
107
│ ├── CMakeLists.txt
138
- │ ├── CODE_OF_CONDUCT.md
139
- │ ├── CONTRIBUTING.md
140
- │ ├── LICENSE.md
141
- │ ├── README.md
142
- │ ├── build_system
143
- │ ├── doc
144
- │ ├── include
145
- │ ├── submodules
108
+ │ ├── ...
146
109
│ └── test
147
110
└── source
148
-
149
- 7 directories, 6 files
150
111
```
151
112
152
113
# Compiling and Running
@@ -155,42 +116,27 @@ To test whether everything works, we will now compile and run a small example.
155
116
156
117
First we create the file ` hello_world.cpp ` in the ` source ` directory with the following contents:
157
118
158
- ```
159
- #include <sharg/core/debug_stream.hpp>
160
-
161
- int main()
162
- {
163
- sharg::debug_stream << "Hello World!\n";
164
- return 0;
165
- }
166
- ```
119
+ \include test/external_project/src/hello_world.cpp
167
120
168
121
To compile it, we first create a ` CMakeLists.txt ` file in the ` source ` directory:
169
-
170
- ```
171
- cmake_minimum_required (VERSION 3.16)
172
- project (sharg_tutorial CXX)
173
-
174
- # add sharg to search path
175
- list (APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../sharg/build_system")
176
-
177
- # require sharg with a version >=1.0.0
178
- find_package (sharg 1.0 REQUIRED)
179
-
180
- # build app with sharg
181
- add_executable (hello_world hello_world.cpp)
182
- target_link_libraries (hello_world sharg::sharg)
183
- ```
122
+ <!-- Parsing the snippet like this to avoid verbatim includes of the snippet identifiers if we used nested snippets. -->
123
+ <!-- Snippet start -->
124
+ \dontinclude test/external_project/sharg_setup_tutorial/CMakeLists.txt
125
+ \until cmake_minimum_required
126
+ \skipline project
127
+ \until target_link_libraries
128
+ <!-- Snippet end -->
184
129
185
130
The directories should now look like this:
186
131
187
132
```
188
133
.
189
134
├── build
190
135
├── sharg-parser
191
- │ ├── build_system
192
- │ ├── ...
193
- │ └── test
136
+ │ ├── CHANGELOG.md
137
+ │ ├── CMakeLists.txt
138
+ │ ├── ...
139
+ │ └── test
194
140
└── source
195
141
├── CMakeLists.txt
196
142
└── hello_world.cpp
@@ -204,30 +150,25 @@ make
204
150
./hello_world
205
151
```
206
152
207
- The output should be ` Hello World! ` . Note that the build type is specified with ` -DCMAKE_BUILD_TYPE=Release ` .
153
+ This should output a basic help page . Note that the build type is specified with ` -DCMAKE_BUILD_TYPE=Release ` .
208
154
Specifying ` Release ` enables an optimized build where no debug information is available. Release mode is therefore
209
155
suitable for the end user. Programs built using ` -DCMAKE_BUILD_TYPE=Debug ` will run slower, but also make the detection
210
156
of errors easier. ` Debug ` is suitable for contributors, and we recommend using it while working with our
211
157
[ Tutorials] ( usergroup1.html ) .
212
158
159
+ \anchor remark_cmake_cxx_compiler
213
160
\remark Depending on the standard C++ compiler on your system, you may need to specify the compiler via
214
161
` -DCMAKE_CXX_COMPILER= ` , for example:
215
162
``` bash
216
- cmake -DCMAKE_CXX_COMPILER=/path/to/executable/g++-11 ../source
163
+ cmake -DCMAKE_CXX_COMPILER=/path/to/executable/g++-13 ../source
217
164
```
218
165
219
166
# Adding a new source file to your project
220
167
221
168
If you create a new ` cpp ` file and want to compile it, you need to add another ` add_executable ` and
222
169
` target_link_libraries ` directive to you ` CMakeLists.txt ` .
223
170
For example, after adding ` another_program.cpp ` your ` CMakeLists.txt ` may look like this:
224
-
225
- ```
226
- # ... former cmake code from above
227
-
228
- add_executable (another_program another_program.cpp)
229
- target_link_libraries (another_program sharg::sharg)
230
- ```
171
+ \snippet test/external_project/sharg_setup_tutorial/CMakeLists.txt adding_files
231
172
232
173
# Encountered issues
233
174
0 commit comments