| 1 | _**Contents**_ |
| 2 | |
| 3 | * [Quick guide using presets](#quick-guide-using-presets) |
| 4 | * [Building on Windows](#building-on-windows) |
| 5 | |
| 6 | # Quick guide using presets |
| 7 | |
| 8 | To build the library quickly on any platform with the least possible effort use following commands inside the checked out source directory: |
| 9 | |
| 10 | ```bash |
| 11 | cmake --preset default -DLibBGCode_BUILD_DEPS=ON |
| 12 | cmake --build --preset default |
| 13 | ``` |
| 14 | |
| 15 | The library can also be installed with modifying the previous commands: |
| 16 | |
| 17 | ```bash |
| 18 | cmake --preset default -DLibBGCode_BUILD_DEPS=ON -DCMAKE_INSTALL_PREFIX=<install-dir> |
| 19 | cmake --build --preset default --target install |
| 20 | ``` |
| 21 | |
| 22 | where `<install-dir>` is an arbitrary install folder. |
| 23 | |
| 24 | # Building the Python bindings |
| 25 | |
| 26 | The library ships with a Python language binding which can be built in the standard way using the following command: |
| 27 | |
| 28 | ```bash |
| 29 | python -m pip install ./ |
| 30 | ``` |
| 31 | |
| 32 | run inside the checked out source directory. |
| 33 | |
| 34 | # Building on Windows |
| 35 | |
| 36 | ## Step by Step Visual Studio Instructions |
| 37 | |
| 38 | ### Install the tools |
| 39 | |
| 40 | Install Visual Studio Community 2019, or higher from [visualstudio.microsoft.com/vs/](https://visualstudio.microsoft.com/vs/). |
| 41 | Older versions are not supported as libbgcode requires support for C++17. |
| 42 | Select all workload options for C++ and make sure to launch Visual Studio after install (to ensure that the full setup completes). |
| 43 | Following instructions assume you are using VS 2019. |
| 44 | |
| 45 | Install CMake for Windows from [cmake.org](https://cmake.org/) |
| 46 | Download and run the exe accepting all defaults |
| 47 | |
| 48 | Install git for Windows from [gitforwindows.org](https://gitforwindows.org/) |
| 49 | Download and run the exe accepting all defaults |
| 50 | |
| 51 | ### Download sources |
| 52 | |
| 53 | Clone the respository. |
| 54 | To place it in C:\src\libbgcode, run: |
| 55 | ``` |
| 56 | c:> mkdir src |
| 57 | c:> cd src |
| 58 | c:\src> git clone https://github.com/prusa3d/libbgcode.git |
| 59 | ``` |
| 60 | |
| 61 | ### Build dependencies |
| 62 | |
| 63 | Open Visual Studio x64 Native Tools Command Prompt. |
| 64 | To create build folder for dependencies, run: |
| 65 | ``` |
| 66 | c:\src> cd libbgcode |
| 67 | c:\src\libbgcode> cd deps |
| 68 | c:\src\libbgcode\deps> mkdir build |
| 69 | c:\src\libbgcode\deps> cd build |
| 70 | ``` |
| 71 | |
| 72 | To build `Release` configuration, run: |
| 73 | ``` |
| 74 | c:\src\libbgcode\deps\build> cmake .. -G "Visual Studio 16 2019" -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release |
| 75 | c:\src\libbgcode\deps\build> cmake --build . |
| 76 | ``` |
| 77 | |
| 78 | To build `Debug` configuration, run: |
| 79 | ``` |
| 80 | c:\src\libbgcode\deps\build> cmake .. -G "Visual Studio 16 2019" -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Debug |
| 81 | c:\src\libbgcode\deps\build> cmake --build . |
| 82 | ``` |
| 83 | |
| 84 | All the dependencies files will be generated into the folder: |
| 85 | ``` |
| 86 | c:\src\libbgcode\deps\build\destdir\usr\local |
| 87 | ``` |
| 88 | |
| 89 | ### Generate Visual Studio project file for libbgcode, referencing the precompiled dependencies. |
| 90 | |
| 91 | Open Visual Studio x64 Native Tools Command Prompt. |
| 92 | To create build folder for libbgcode, run: |
| 93 | ``` |
| 94 | c:\src> cd libbgcode |
| 95 | c:\src\libbgcode> mkdir build |
| 96 | c:\src\libbgcode> cd build |
| 97 | ``` |
| 98 | |
| 99 | To generate the VS solution for libbgcode, run: |
| 100 | ``` |
| 101 | c:\src\libbgcode\build> cmake -G "Visual Studio 16 2019" .. -A x64 -DCMAKE_PREFIX_PATH=C:\src\libbgcode\deps\build\destdir\usr\local -DCMAKE_INSTALL_PREFIX=C:\src\libbgcode\retail |
| 102 | ``` |
| 103 | Note that `CMAKE_PREFIX_PATH` must be absolute path. A relative path like "....\deps\build\destdir\usr\local" does not work. |
| 104 | |
| 105 | ### Compile/Install libbgcode. |
| 106 | |
| 107 | Double-click c:\src\libbgcode\build\LibBGCode.sln to open in Visual Studio 2019 or open Visual Studio for C++ development (VS asks this the first time you start it). |
| 108 | |
| 109 | To compile, run Build->Build Solution or press F7 for every variant (Debug/Release) you want to build. |
| 110 | |
| 111 | To install, select INSTALL project in the Solution Explorer and run Build->Build INSTALL or right-click on INSTALL project in Solution Explorer and select Build. |
| 112 | |
| 113 | All the library files will be installed into the folder: |
| 114 | ``` |
| 115 | c:\src\libbgcode\retail |
| 116 | ``` |