A sample project, written in CPP/C++ which uses CMake, Conan and OpenCV to build the opencv-cpp-example app.
This project demonstrates how Conan revolutionized packages/dependencies management in CPP/C++.
WORK-IN-PROGRESS: Currently, I've only tested it on my macOS, though I do intend to add more profiles and configurations so this project will be built cross-platform.
- CMake 3.18+
- Python 3.6+
- conan 1.47.0+
python3 -m pip install conan
- Git clone this project
git clone https://github.com/unfor19/cpp-conan-example.git cd cpp-conan-example
- IMPORTANT: From now on, the working dir is the cloned project's root dir
- Copy configuration files to
~/.conan/
cp conan_files/conan.conf conan_files/settings.yml ~/.conan/ && \ cp conan_files/profiles/* ~/.conan/profiles/
I want to know more - Expand/Collapse
I'm using Conan Profiles per operating system and architecture.
Profiles allows users to set a complete configuration set for settings, options, environment variables, and build requirements in a file. Source
Check the conan_files/profiles that I've created to build this project.
The input settings for packages in Conan are predefined in ~/.conan/settings.yml file, so only a few like os or compiler are possible. These are the default values, but it is possible to customize them, see Customizing settings. Source
I customized this file by adding the value 13.1
to compiler.apple-clang.version
.
We'll use conancenter as the default remote registry to fetch dependencies, that is why I haven't added it.
- OS: Monterey
- Xcode 13.3+ - includes apple-clang 13.1.6
- Install dependencies
- macOS
conan install ./conan_files \ --install-folder ./build \ -pr:b macos \ --build missing \ -pr:h macos-requirements
- macOS
- Build the app
conan build conan_files --build-folder build --source-folder .
- Run the app for the first time to allow camera usage
-
Terminal > Run the app by executing
# macOS/Linux/WSL2 ./build/bin/opencv_example
# powershell .\build\bin\opencv_example
-
Allow camera access for the first time
-
Terminate the app in the terminal by hitting
CTRL+C
-
- Run the app again as mentioned above and watch yourself, I hope you're smiling
Built with OpenCV 4.5.5 Capture is opened ^C # Hit CTRL+C
- IDE does not recognize
opencv2
as an available library, make sure to add conan local packages to the includePath, in VSCode it's"${HOME}/.conan/**"
, an example for.vscode/c_cpp_properties.json
file:{ "configurations": [ { "name": "Mac", "includePath": ["${workspaceFolder}/**", "${HOME}/.conan/**"], "defines": [], "macFrameworkPath": [], "compilerPath": "/usr/bin/clang", "cStandard": "gnu17", "cppStandard": "gnu++17", "intelliSenseMode": "macos-clang-x64" } ], "version": 4 }
Created and maintained by Meir Gabay
This project is licensed under the MIT License - see the LICENSE file for details