Skip to content

Commit 68711f2

Browse files
committed
docs: add steps to build for distribution
1 parent e359bea commit 68711f2

File tree

2 files changed

+146
-6
lines changed

2 files changed

+146
-6
lines changed

goldenmaster/README.md

+73-3
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ outputfolder
7171
| | ...
7272
└───implementation
7373
```
74-
## Build
74+
## Build for development
7575

7676
The template supports two build methods. Depending on your environment you can choose between a [pure CMake](#CMake-pure) approach and additional one with [Conan support](#Conan-support).
7777

@@ -83,7 +83,7 @@ If you want to manage and install dependencies manually into the environment, th
8383
#### Windows Setup
8484

8585
For ease of use, we use the Conan package manager to install needed dependencies first. [Documentation for Conan](https://conan.io/).
86-
If you do not want or can use conan, the poco libraries must installed separately.
86+
If you do not want or can not use conan, the poco libraries must installed separately.
8787

8888
1. If you have not done before, install conan 1.x and then set up your profile. The default configuration is usually in your home folder at `.conan/profiles/default`. More details on the conan profile can be found [here](https://docs.conan.io/en/latest/reference/profiles.html).
8989
This can be set like:
@@ -172,7 +172,7 @@ For ease of use and package distribution we generate all files necessary files t
172172
This can be set like:
173173
174174
```
175-
compiler.libcxx=libstdc++11
175+
conan profile update settings.compiler.libcxx=libstdc++11 default
176176
```
177177
2. Execute the test script depending on the host platform. This will build all dependencies and module files, including examples.
178178
* Or on **Linux, Mac** execute the shell script `test_conan.sh`.
@@ -186,6 +186,76 @@ For ease of use and package distribution we generate all files necessary files t
186186
>test_conan.bat
187187
```
188188
189+
## Build for distribution
190+
191+
In some cases you may want to share the build artifacts. The easiest approach is to build everything in release mode and link statically against external libraries.
192+
In general the following steps are similar to the development build. We use conan to build the static version of the poco libraries.
193+
194+
The procedure is almost identical for Windows and Linux, but it is important to use the right path format corresponding to each platform.
195+
196+
1. If you have not done before, install conan 1.x and then set up your release profile. More details on the conan profile can be found [here](https://docs.conan.io/en/latest/reference/profiles.html).
197+
198+
A new profile can be created like this:
199+
```
200+
$ conan profile new release --detect
201+
```
202+
203+
And additionally we need to make platform specific changes to the conan configuration:
204+
* On **Linux**:
205+
206+
```
207+
$ conan profile update settings.compiler.libcxx=libstdc++11 release
208+
$ conan profile update settings.build_type=Release release
209+
```
210+
* On **Windows**
211+
212+
```
213+
> conan profile update settings.compiler.runtime=MD release
214+
> conan profile update settings.build_type=Release release
215+
```
216+
217+
2. Once conan is set up, we use it to install the necessary dependencies and build them if not available.
218+
It is recommended to do this in a new folder, which we later use to configure cmake.
219+
For instance, create a folder ` deps` and simply copy the `conan install` line:
220+
```
221+
$ mkdir deps
222+
$ cd deps
223+
$ conan install --profile release poco/1.11.3@ --build missing -o poco:shared=False -o poco:enable_data_mysql=False -o openssl:shared=False -o poco:enable_activerecord=False -o poco:enable_apacheconnector=False -o poco:enable_cppparser=False -o poco:enable_crypto=True -o poco:enable_data=False -o poco:enable_data_odbc=False -o poco:enable_data_postgresql=False -o poco:enable_data_sqlite=False -o poco:enable_encodings=False -o poco:enable_json=False -o poco:enable_jwt=False -o poco:enable_mongodb=False -o poco:enable_net=True -o poco:enable_netssl=True -o poco:enable_pagecompiler=False -o poco:enable_pagecompiler_file2page=False -o poco:enable_pdf=False -o poco:enable_pocodoc=False -o poco:enable_redis=False -o poco:enable_sevenzip=False -o poco:enable_util=True -o poco:enable_xml=False -o poco:enable_zip=False --generator cmake_find_package --generator virtualenv
224+
$ cd ..
225+
```
226+
The `conan install` step downloads the poco source package, configures it to a minium version and builds it, including its dependencies.
227+
Also make sure to use the previously created release profile with `--profile release`.
228+
3. With poco available in the `deps` folder we can configure our project and build it.
229+
230+
The `CMAKE_INSTALL_PREFIX` defines the where built files shall be installed. In this example we use `tmp`.
231+
The `CMAKE_MODULE_PATH` tells CMake where it can find the necessary dependencies like poco. In the previous step we used `deps` - so we specify the full path to the deps folder here, e.g. "/home/user/project/deps" or "C:/workspace/project/deps".
232+
```
233+
$ cmake -Bbuild -DCMAKE_INSTALL_PREFIX=tmp -DCMAKE_MODULE_PATH="/home/user/project/deps" -DCMAKE_BUILD_TYPE=Release
234+
```
235+
236+
After the configuration step finished successfully we can build the project
237+
```
238+
$ cmake --build build/ --config Release
239+
```
240+
4. The last step is to install the built project files into our previously specified folder("tmp") and package it.
241+
242+
```
243+
$ cmake --build build/ --target install --config Release
244+
```
245+
246+
The files are in "tmp/bin", "tmp/lib" and "tmp/include".
247+
248+
5. In order to run the files on Windows it is sufficient to just execute the following command, e.g.:
249+
```
250+
> tmp\bin\OLinkServer.exe
251+
```
252+
253+
For Linux, it is necessary to point to the dynamically linked executables since they are in the "lib" folder.
254+
```
255+
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/user/project/tmp/lib
256+
$ ./tmp/bin/OLinkServer
257+
```
258+
189259
## Run
190260
Once the build was successful you can easily launch one of the examples applications.
191261

templates/README.md

+73-3
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ outputfolder
7171
| | ...
7272
└───implementation
7373
```
74-
## Build
74+
## Build for development
7575

7676
The template supports two build methods. Depending on your environment you can choose between a [pure CMake](#CMake-pure) approach and additional one with [Conan support](#Conan-support).
7777

@@ -83,7 +83,7 @@ If you want to manage and install dependencies manually into the environment, th
8383
#### Windows Setup
8484

8585
For ease of use, we use the Conan package manager to install needed dependencies first. [Documentation for Conan](https://conan.io/).
86-
If you do not want or can use conan, the poco libraries must installed separately.
86+
If you do not want or can not use conan, the poco libraries must installed separately.
8787

8888
1. If you have not done before, install conan 1.x and then set up your profile. The default configuration is usually in your home folder at `.conan/profiles/default`. More details on the conan profile can be found [here](https://docs.conan.io/en/latest/reference/profiles.html).
8989
This can be set like:
@@ -172,7 +172,7 @@ For ease of use and package distribution we generate all files necessary files t
172172
This can be set like:
173173
174174
```
175-
compiler.libcxx=libstdc++11
175+
conan profile update settings.compiler.libcxx=libstdc++11 default
176176
```
177177
2. Execute the test script depending on the host platform. This will build all dependencies and module files, including examples.
178178
* Or on **Linux, Mac** execute the shell script `test_conan.sh`.
@@ -186,6 +186,76 @@ For ease of use and package distribution we generate all files necessary files t
186186
>test_conan.bat
187187
```
188188
189+
## Build for distribution
190+
191+
In some cases you may want to share the build artifacts. The easiest approach is to build everything in release mode and link statically against external libraries.
192+
In general the following steps are similar to the development build. We use conan to build the static version of the poco libraries.
193+
194+
The procedure is almost identical for Windows and Linux, but it is important to use the right path format corresponding to each platform.
195+
196+
1. If you have not done before, install conan 1.x and then set up your release profile. More details on the conan profile can be found [here](https://docs.conan.io/en/latest/reference/profiles.html).
197+
198+
A new profile can be created like this:
199+
```
200+
$ conan profile new release --detect
201+
```
202+
203+
And additionally we need to make platform specific changes to the conan configuration:
204+
* On **Linux**:
205+
206+
```
207+
$ conan profile update settings.compiler.libcxx=libstdc++11 release
208+
$ conan profile update settings.build_type=Release release
209+
```
210+
* On **Windows**
211+
212+
```
213+
> conan profile update settings.compiler.runtime=MD release
214+
> conan profile update settings.build_type=Release release
215+
```
216+
217+
2. Once conan is set up, we use it to install the necessary dependencies and build them if not available.
218+
It is recommended to do this in a new folder, which we later use to configure cmake.
219+
For instance, create a folder ` deps` and simply copy the `conan install` line:
220+
```
221+
$ mkdir deps
222+
$ cd deps
223+
$ conan install --profile release poco/1.11.3@ --build missing -o poco:shared=False -o poco:enable_data_mysql=False -o openssl:shared=False -o poco:enable_activerecord=False -o poco:enable_apacheconnector=False -o poco:enable_cppparser=False -o poco:enable_crypto=True -o poco:enable_data=False -o poco:enable_data_odbc=False -o poco:enable_data_postgresql=False -o poco:enable_data_sqlite=False -o poco:enable_encodings=False -o poco:enable_json=False -o poco:enable_jwt=False -o poco:enable_mongodb=False -o poco:enable_net=True -o poco:enable_netssl=True -o poco:enable_pagecompiler=False -o poco:enable_pagecompiler_file2page=False -o poco:enable_pdf=False -o poco:enable_pocodoc=False -o poco:enable_redis=False -o poco:enable_sevenzip=False -o poco:enable_util=True -o poco:enable_xml=False -o poco:enable_zip=False --generator cmake_find_package --generator virtualenv
224+
$ cd ..
225+
```
226+
The `conan install` step downloads the poco source package, configures it to a minium version and builds it, including its dependencies.
227+
Also make sure to use the previously created release profile with `--profile release`.
228+
3. With poco available in the `deps` folder we can configure our project and build it.
229+
230+
The `CMAKE_INSTALL_PREFIX` defines the where built files shall be installed. In this example we use `tmp`.
231+
The `CMAKE_MODULE_PATH` tells CMake where it can find the necessary dependencies like poco. In the previous step we used `deps` - so we specify the full path to the deps folder here, e.g. "/home/user/project/deps" or "C:/workspace/project/deps".
232+
```
233+
$ cmake -Bbuild -DCMAKE_INSTALL_PREFIX=tmp -DCMAKE_MODULE_PATH="/home/user/project/deps" -DCMAKE_BUILD_TYPE=Release
234+
```
235+
236+
After the configuration step finished successfully we can build the project
237+
```
238+
$ cmake --build build/ --config Release
239+
```
240+
4. The last step is to install the built project files into our previously specified folder("tmp") and package it.
241+
242+
```
243+
$ cmake --build build/ --target install --config Release
244+
```
245+
246+
The files are in "tmp/bin", "tmp/lib" and "tmp/include".
247+
248+
5. In order to run the files on Windows it is sufficient to just execute the following command, e.g.:
249+
```
250+
> tmp\bin\OLinkServer.exe
251+
```
252+
253+
For Linux, it is necessary to point to the dynamically linked executables since they are in the "lib" folder.
254+
```
255+
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/user/project/tmp/lib
256+
$ ./tmp/bin/OLinkServer
257+
```
258+
189259
## Run
190260
Once the build was successful you can easily launch one of the examples applications.
191261

0 commit comments

Comments
 (0)