Last active
June 12, 2023 00:35
-
-
Save alexios-angel/5c465da2781e5465656cb51ed3770572 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Welcome to Our Project - A Multi-Project C++ Template with Conan Dependency Management | |
| ------------------------------------------------------------------------------------- | |
| This is a template for a large and complex C++ project with Conan dependency management, consisting of multiple sub- | |
| projects. This readme will guide you through understanding our project structure and how to set up, build, and run the | |
| project. | |
| Project Structure | |
| ----------------- | |
| Understanding the project structure is key to navigating and working with the code effectively: | |
| /project_root | |
| | | |
| |-- CMakeLists.txt // Root CMake file that orchestrates the building of all sub-projects | |
| |-- conanfile.txt // Specifies the project's dependencies and how they should be handled by Conan | |
| | | |
| |-- /app1 // Each app directory represents a separate sub-project | |
| | | | |
| | |-- CMakeLists.txt // CMake file for app1 | |
| | |-- main1.cpp // Entry point for app1 | |
| | | |
| |-- /app2 // Repeat similar structure for each application | |
| | | | |
| | |-- CMakeLists.txt // CMake file for app2 | |
| | |-- main2.cpp // Entry point for app2 | |
| | | |
| |-- /app3 | |
| | | | |
| | |-- CMakeLists.txt | |
| | |-- main3.cpp | |
| | | |
| |-- /app4 | |
| | | |
| |-- CMakeLists.txt | |
| |-- main4.cpp | |
| conanfile.txt | |
| ------------- | |
| [requires] | |
| boost/1.75.0 | |
| OpenSSL/1.1.1j | |
| [generators] | |
| cmake | |
| CMakeLists.txt (root) | |
| ---------------------- | |
| cmake_minimum_required(VERSION 3.10) | |
| project(MyProject VERSION 1.0) | |
| set(CMAKE_CXX_STANDARD 14) | |
| set(CMAKE_CXX_STANDARD_REQUIRED True) | |
| include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | |
| conan_basic_setup() | |
| add_subdirectory(app1) | |
| add_subdirectory(app2) | |
| add_subdirectory(app3) | |
| add_subdirectory(app4) | |
| CMakeLists.txt (in each app directory) | |
| --------------------------------------- | |
| (add_executable for the app and target_link_libraries for its dependencies) | |
| Example for /app1/CMakeLists.txt: | |
| add_executable(app1 main1.cpp) | |
| target_link_libraries(app1 PRIVATE CONAN_PKG::boost) | |
| Development Environment | |
| ----------------------- | |
| Before you start working, you'll need to set up your development environment: | |
| - CMake (version 3.10 or later) | |
| - Conan | |
| - C++14 compliant compiler | |
| If you're new to any of these tools, don't worry. CMake is our build system. It takes our source code and the CMakeLists.txt | |
| files and produces the build files needed to compile the code. Conan is our dependency manager. It automatically downloads | |
| and builds the third-party libraries that our project depends on. C++14 is the version of C++ we're using in this project. | |
| Setup | |
| ----- | |
| Here's how you set everything up: | |
| 1. Install Conan using pip, the Python package manager. If you don't have pip, ask a team member for help setting it up: | |
| pip install conan | |
| 2. Add the Conan Center Index remote. This allows Conan to download packages from it: | |
| conan remote add conan-center https://center.conan.io | |
| 3. Clone this repository. If you're unsure about how to use Git, let someone on the team know, and they'll be happy to help: | |
| git clone <your repository URL> | |
| Build | |
| ----- | |
| To build the project, follow these steps: | |
| 1. Navigate to the project root directory: | |
| cd project_root | |
| 2. Create a new `build` directory and navigate into it: | |
| mkdir build | |
| cd build | |
| 3. Install the Conan dependencies. This uses the conanfile.txt to download and build our third-party libraries: | |
| conan install .. | |
| 4. Generate the build system files: | |
| cmake .. | |
| 5. Build the project: | |
| make | |
| Running The Code | |
| ---------------- | |
| After building the project, you'll find the executables for each subproject in the respective directories within the 'build' | |
| directory. Run the executable to run the application. | |
| Dependencies | |
| ------------ | |
| Understanding dependencies is key to understanding how our project works. All dependencies are listed in the `conanfile.txt` | |
| file in the project root. Each application's `CMakeLists.txt` file links against these libraries using the `CONAN_PKG::` | |
| prefix. If the project fails to build due to a missing dependency, ensure Conan is set up properly and try running ` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment