Use Conan: An Open Source C/C++ Package Manager | by Eldad Uzman | Feb, 2022

Managing your C/C++ packages may very well be messy, however it may be considerably improved

Person leaning against a wall
Picture by Dawid Zawiła on Unsplash.
+root
- mainapp.c
- CMakeLists.txt
mainapp.c
CMakeLists.txt
cmake --build ./construct --config Debug --target MyProject -j 10 --
./construct/MyProject -a foo -b bar
a: foo
b: bar

Possibility 1. Eat supply code

git submodules add https://github.com/jibsen/parg.git
[submodule "parg"]path = pargurl = https://github.com/jibsen/parg.git
git submodules init
cmake --build ./construct --config Debug --target MyProject -j 10 --
./construct/MyProject -a foo -b bar
a: foo
b: bar

Possibility 2 . Eat compiled library

cmake --build ./construct --config Debug --target MyProject -j 10 --
./construct/MyProject -a foo -b bar
a: foo
b: bar

Possibility 3. Use Conan for crying out loud!

pip set up conan
conan profile new myprofile
Empty profile created: C:Usersuser.conanprofilesmyprofile
[env]CC=C:/Program Information (x86)/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/bin/gcc.exeCXX=C:/Program Information (x86)/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/bin/g++.exe[settings]os_build=Home windowsarch_build=x86os=Home windowsarch=x86compiler=gcccompiler.model=8compiler.libcxx=libstdc++11build_type=Launch
[requires]
parg/1.0.2
[generators]
cmake
conan set up . -pr=myprofile
Configuration:
[settings]
arch=x86
arch_build=x86
build_type=Launch
compiler=gcc
compiler.libcxx=libstdc++11
compiler.model=8
os=Home windows
os_build=Home windows
[options]
[build_requires]
[env]
CC=C:/Program Information (x86)/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/bin/gcc.exe
CXX=C:/Program Information (x86)/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/bin/g++.exe
conanfile.txt: Putting in package deal
Necessities
parg/1.0.2 from 'conancenter' - Cache
Packages
parg/1.0.2:a955db98e980a5ab86ae50d6df8bfee361185c27 - Cache
Putting in (downloading, constructing) binaries...
parg/1.0.2: Already put in!
conanfile.txt: Generator txt created conanbuildinfo.txt
conanfile.txt: Generator cmake created conanbuildinfo.cmake
conanfile.txt: Aggregating env mills
conanfile.txt: Generated conaninfo.txt
conanfile.txt: Generated graphinfo
cmake --build ./construct --config Debug --target MyProject -j 10 --
./construct/MyProject -a foo -b bar
a: foo
b: bar

More Posts