| 1 | \page install-conan Installing with Conan |
| 2 | |
| 3 | To install D++ into a project using conan 2.0 and cmake: |
| 4 | |
| 5 | - Ensure conan is correctly installed, the most popular method is with pip. |
| 6 | - Create a conanfile.txt in the root of the project. |
| 7 | |
| 8 | ```conanfile |
| 9 | [requires] |
| 10 | dpp/10.0.34 |
| 11 | |
| 12 | [generators] |
| 13 | CMakeDeps |
| 14 | CMakeToolchain |
| 15 | ``` |
| 16 | |
| 17 | - You may now use the library within a `CMake` based project by adding instructions such as these to your `CMakeLists.txt`: |
| 18 | |
| 19 | ```cmake |
| 20 | set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_LIST_DIR}/build") |
| 21 | find_package(dpp CONFIG REQUIRED) |
| 22 | target_link_libraries(${PROJECT_NAME} dpp::dpp) |
| 23 | ``` |
| 24 | |
| 25 | - If you recieve any errors about CXX version you may need to set it |
| 26 | |
| 27 | ``` |
| 28 | set(CMAKE_CXX_STANDARD 17) |
| 29 | ``` |
| 30 | |
| 31 | - You will then also want to set your build type to match what you will be using in conan(Debug or Release) |
| 32 | |
| 33 | ``` |
| 34 | set(CMAKE_BUILD_TYPE Debug) |
| 35 | ``` |
| 36 | |
| 37 | OR |
| 38 | |
| 39 | ``` |
| 40 | set(CMAKE_BUILD_TYPE Release) |
| 41 | ``` |
| 42 | |
| 43 | - Now run the following commands |
| 44 | |
| 45 | ``` |
| 46 | mkdir build |
| 47 | conan install . --output-folder=build --build=missing -s build_type=Release |
| 48 | cd build |
| 49 | cmake .. -DCMAKE_TOOLCHAIN_FILE="conan_toolchain.cmake" |
| 50 | cmake --build build --config Release |
| 51 | ``` |
| 52 | |
| 53 | - NOTE: build_type= needs to match whatever was set in your CMake or you will get linker issues. |