CBuild
C++ build system with scripts written in c++
Loading...
Searching...
No Matches
pkgconfig.cpp
Go to the documentation of this file.
1
21// C++ libs
22#include "string"
23// Project headers
27/* pkgconfig */
29 bool disabled = false;
32 disabled = true;
33 }
34 CBuild::print("Searching pkg-config for package \"" + package->name + "\"", CBuild::MAGENTA);
35 std::string largs = CBuild::system_piped("pkg-config --libs " + package->name, 64 * 1024);
36 if (largs[0] != '-') {
37 CBuild::print("Package \"" + package->name + "\" not found!", CBuild::RED);
38 package->largs = "";
39 package->cargs = "";
40 if (disabled) {
42 }
43 return false;
44 }
45 package->largs = largs;
46 package->cargs = CBuild::system_piped("pkg-config --cflags " + package->name, 64 * 1024);
47 if (disabled) {
49 }
50 if (package->cargs.size() > 3) {
51 package->cargs = package->cargs.substr(0, package->cargs.size() - 1);
52 } else {
53 package->cargs = "";
54 }
55 package->largs = package->largs.substr(0, package->largs.size() - 1);
56 return true;
57}
bool is_system_enabled()
Check if CBuild::system enabled.
Definition system.cpp:83
void print(std::string msg, color fg=CBuild::WHITE)
Print colored text to STDOUT.
Definition print.cpp:70
@ RED
Definition print.hpp:34
@ MAGENTA
Definition print.hpp:38
void enable_system()
Reanable system commands execution, used only in pkg-config.
Definition system.cpp:80
bool get_pkg_info(CBuild::package_info *package)
Get the package info from pkg-config database.
Definition pkgconfig.cpp:28
void disable_system()
Disable system commands execution.
Definition system.cpp:77
std::string system_piped(std::string cmd, unsigned int buffsize)
Execute command and return it's output.
Definition system.cpp:58
pkg-config interface header Provides interface to pkg-config cli tool, including some parts of error ...
Custom print that support color codes.
Package info struct for data for pkg-config.
Definition pkgconfig.hpp:30
std::string largs
Package link args.
Definition pkgconfig.hpp:38
std::string name
Package name.
Definition pkgconfig.hpp:34
std::string cargs
Package compile args.
Definition pkgconfig.hpp:42
Custom system() wraper.