[go: up one dir, main page]

Skip to content

Latest commit

 

History

History
2557 lines (2023 loc) · 98.2 KB

package-managers.org

File metadata and controls

2557 lines (2023 loc) · 98.2 KB

CPP / C++ - Package Managers

Package Managers

Overview

Package Managers

There are several solutions for managing dependencies in C++ projects, however they are still no widely used or integrated to IDEs and building systems. A reasonable set of features for selecting a package manager is CMake support, CMake integration, IDE integration, command line interface and distributed repositories. Some of them are:

Considerations for package manager choice

  • The most mature package managers with CMake integration are Conan and Vcpkg. Vcpkg has the largest number of packages available. However, it is not possible to install multiple versions of the same package or host a local package repository.
  • Conan is more documented and provides more control over package versions. It has descentralized repositories and also allows users to host local or intranet private repositories. A minor problem of Conan is the Python installation requirement, but this issue could be quickly solved by turning Conan into a single native executable file by packing Conan Python module with the Python interpreter with tools like Py2Exe for Windows.

Comparative table:

Some reasonable set of features for a package managers

  • CMake integration
  • Default repository, descentralized and local repositories.
  • Cross platform
  • Easier to use from CMake without needing to call any external command, the packages to be installed should be defined in the CMakeLists.txt file.
  • Command line tools
  • Browse package metadata from command line or IDE like .net’s Nuget or Python’s pip.
  • Integration with IDEs
  • Standalone no depending on any interpreter or external dependency or fully packed with the interpreter making easier to install and deploy.

Low tech approaches for package or dependency management

  • GIT Submodules
  • Use system-specific package manager for instance: Ubuntu: apt-get; Fedora Linux: dnf; BSD Ports: …
    • Disadvantage: Hard to reproduce compilation across different machines as most Linux distributions only provide a single version and may not have all necessary libraries and header-only libraries.
  • Add libraries manually
  • Install packages manually in the systems:
    • ./configure && make && make install
  • Copy header-only libraries to project-directory
FeatureConanVcpkg
StandaloneNOYES
Decentralized repositoriesYESNO
Local RepositoryYESNO
Multiple versions of same packageYESNO
Integration with IDEsNONO
Most Simple-Winner
More packages-Winner
User controlWinner-
OverallWinner-

Interesting discussions:

Conan package Manager

Main Web Sites

Benefits and Capabilities

Benefits:

  • Reduce compile-time
  • Reduce library installation effort duplication
  • Increase library discoverability
  • Easier cross-compilation for different architectures
  • Host package recipes in local network or remotely

Capabilities:

  • Cache and reuse compilation binaries (aka object-code) such as intermediate object-code (*.o or *.obj), static libraries and shared libraries which reduces compile-time and effort duplication for installing a libraries since all projects using the same conan recipe can reuse the binaries.
  • Package with embedded sources: Sources can be embedded in a package.
  • Package with remote sources: Conan packages (aka recipes) can fetch source code from remote sources such as Github, Gitlab, Sourceforge, FTP or even a Conan Server in local network.
  • Conan Recipes can build package’s sources with a wide variety of tools such as:
    • GNU autotools
    • CMake
    • GNU Makefile
    • BSD Makefile

Videos

Webinar JFrog:

CppCon:

Selected Articles

Install Conan

Standalone Installers

Conan Standalone Installers for Windows, Linux and Mac OSX which does not require previous Python installation.

Installation via PIP

Installing Conan requires a Python installation with pip.

$ pip instal conan 

The easiest way to get Python for any platform, including Windows is through Miniconda distribution which is a lightweight version of Python Anaconda distribution:

Conan Addons for IDEs

Conan Extension (Addon) for Visual Studio

Conan Plugin for JetBrains’ CLION IDE:

Conan Package Repositories

Search Conan Packages at Conan Center repository:

Repository Lists:

Some Conan Repositories:

Libraries in Conan Center

Libraries in Conan Main Repositories

All libraries in Conan Community:

All libraries in Conan Bincrafters:

Selected Conan Libraries

Conan RecipeDescription
Fundamental
BoostBoost Libraries
Poco librariesPoco framework libraries for network, compression, process and database.
Google’s abseilGoogle’s abseil library - https://abseil.io/
fmtFast and type-safe and extensible printf library.
ranges-v3Ranges library derived from Boost that will be added to C++20 stdandard library.
CLI11Lightweight header-only command line parser.
CerealHeader-only serialization library
parallel stlC++ standard library algorithms with support for execution policies
Intel TBBIntel Threading Building Blocks (Intel TBB) for writing parallel C++ programs.
PugiXMLXML Parser library
IrrXMLSimple and fast open source xml parser for C++
Unit Testing
Google TestGoogle unit testing library, aka GTest
Catch2Single header unit test framework.
DoctestHeader-only unit testing library with fast compile-time.
Data Compression
ZlibZlib compression library
bzip2bzip2 is a freely available, patent free (see below), high-quality data compressor.
Scientific / Math
Conan LapackLapack linear algebra library
Open BLASOpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version.
eigenEigen is a C++ template library for linear algebra: matrices, vectors, numerical solvers, and related algorithms.
Computer Graphics
libpngPortable Network Graphics An Open, Extensible Image Format with Lossless Compression
freetypeRender text onto bitmaps, and provides support for other font-related operations.
imguiBloat-free Immediate Mode Graphical User interface for C++ with minimal dependencies
glmA C++ mathematics library for graphics programming
sdl2Simple Direct Media Layer
glfwGLFW is an Open Source, multi-platform library for OpenGL, OpenGL ES and Vulkan development on the desktop.
It provides a simple API for creating windows, contexts and surfaces, receiving input and events.
Computer Vision and
AI - Artificial Inteligence
OpenCVMost well-known Library for computer vision and image processing.
tiny-dnntiny-dnn is a C++14 implementation of deep learning on systems with limited computational resource.
Encryption and TSL/SSL
OpenSSLMost well-known library TLS/SSL - Transport Layer Security
cryptoppFree C++ class library of cryptographic schemes.
botanBotan is a cryptography library written in C++11
Miscellaneous
ncursesAPI to write text-based user interfaces, TUIs in a terminal.
LibCurlcurl library that provides clients for many network protocols: http, https, ftp, sftp, …
Pybind 11Library for creating Python native modules / libraries in C++.
pistacheC++ REST framework written by Mathieu Stefani at Datacratic. It is written in pure C++11.
stb - single-file public domainstb single-file public domain libraries for C/C++
wiringpiGPIO Interface library for the Raspberry Pi

Command Summary

Search Conan Packages

Search for Poco libraries in Conan Center repository:

$ conan search Poco* -r=conan-center
Existing package recipes:

Poco/1.7.8p3@pocoproject/stable
Poco/1.7.9@pocoproject/stable
Poco/1.7.9p1@pocoproject/stable
Poco/1.7.9p2@pocoproject/stable
Poco/1.8.0.1@pocoproject/stable
Poco/1.8.0@pocoproject/stable
Poco/1.8.1@pocoproject/stable
Poco/1.9.0@pocoproject/stable

Search for Google Test in Conan Center repository:

$ conan search gtest/* -r=conan-center
Existing package recipes:

gtest/1.7.0@bincrafters/stable
gtest/1.8.0@bincrafters/stable
gtest/1.8.1@bincrafters/stable

Search for libcurl package on BinCrafters repository:

λ conan search libcurl/* -r=bincrafters
Existing package recipes:

libcurl/7.50.3@bincrafters/stable
libcurl/7.52.1@bincrafters/stable
libcurl/7.56.1@bincrafters/stable
libcurl/7.60.0@bincrafters/stable
libcurl/7.61.1@bincrafters/stable

Search for pybind11 on all conan repositories:

$ conan search pybind* -r=all
Existing package recipes:

Remote 'conan-center':
pybind11/2.2.2@conan/stable
pybind11/2.2.3@conan/stable
pybind11/2.2.4@conan/stable
Remote 'conan-transit':
pybind11/0.1.0@jason2506/testing
pybind11/1.4@memsharded/stable
pybind11/any@memsharded/stable

List libraries in local cache / local repository

This command lists packages in local cache or local repository.

$ conan search
Existing package recipes:

OpenSSL/1.0.2o@conan/stable
Poco/1.9.0@pocoproject/stable
gtest/1.8.1@bincrafters/stable
zlib/1.2.11@conan/stable

List Conan storage directory ~/.conan on Unix-like (Linux, BSD, OSX …)

$ tree -L 2  ~/.conan/
/home/archbox/.conan/
├── artifacts.properties
├── cacert.pem
├── conan.conf
├── conan.conf.back
├── data
│   ├── gtest
│   ├── OpenSSL
│   ├── Poco
│   └── zlib
├── hooks
│   └── attribute_checker.py
├── profiles
│   └── default
├── registry.json
├── registry.json.lock
├── settings.yml
└── version.txt

7 directories, 10 files

List directory ~/.conan/data

$ tree -L 3  ~/.conan/data
/home/archbox/.conan/data
├── gtest
│   └── 1.8.1
│       └── bincrafters
├── OpenSSL
│   └── 1.0.2o
│       └── conan
├── Poco
│   └── 1.9.0
│       └── pocoproject
└── zlib
    └── 1.2.11
        └── conan

12 directories, 0 files

List Remote Repositories:

$ conan remote list

conan-center: https://conan.bintray.com [Verify SSL: True]
conan-transit: https://conan-transit.bintray.com [Verify SSL: True]

Add more remote repositories

Add Repositories:

  • Add Conan Center (Repository installed by default)
$ conan remote add conan-center https://conan.bintray.com
  • Add Conan Community:
$ conan remote add conan-community https://api.bintray.com/conan/conan-community/conan
  • Add bincrafters
$ conan remote add bincrafters https://api.bintray.com/conan/bincrafters/public-conan

Install library in local cache

Example install package libcurl version 7.61.1 from repository BinCrafters:

  • Installation on Windows 64 bits for 64 bits target. The build type is Release, however the installation lacks the debug building.
  • Linux, OS or Nix users don’t need to be concerned about Debug/Release build type.
λ conan install libcurl/7.61.1@bincrafters/stable

Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=Visual Studio
compiler.runtime=MD
compiler.version=15
os=Windows
os_build=Windows
[options]
[build_requires]
[env]

libcurl/7.61.1@bincrafters/stable: Not found in local cache, looking in remotes...
libcurl/7.61.1@bincrafters/stable: Trying with 'conan-center'...
Downloading conanmanifest.txt
[==================================================] 234B/234B
Downloading conanfile.py
[==================================================] 19.4KB/19.4KB
Downloading conan_export.tgz
[==================================================] 764B/764B
Decompressing conan_export.tgz: 100%|██████████| 764/764 [00:00<00:00, 46.3kB/s]
OpenSSL/1.0.2n@conan/stable: Not found in local cache, looking in remotes...
OpenSSL/1.0.2n@conan/stable: Trying with 'conan-center'...
Downloading conanmanifest.txt
[==================================================] 58B/58B
Downloading conanfile.py
[==================================================] 20.1KB/20.1KB
libcurl/7.61.1@bincrafters/stable: Installing package
Requirements
    OpenSSL/1.0.2n@conan/stable from 'conan-center' - Downloaded
    libcurl/7.61.1@bincrafters/stable from 'conan-center' - Downloaded
    zlib/1.2.11@conan/stable from 'conan-center' - Cache
Packages
    OpenSSL/1.0.2n@conan/stable:606fdb601e335c2001bdf31d478826b644747077 - Download
    libcurl/7.61.1@bincrafters/stable:ae6191bc1194317ff7cdbc84d4d302ab49975618 - Download
    zlib/1.2.11@conan/stable:6cc50b139b9c3d27b3e9042d5f5372d327b3a9f7 - Cache

zlib/1.2.11@conan/stable: Already installed!
OpenSSL/1.0.2n@conan/stable: Retrieving package 606fdb601e335c2001bdf31d478826b644747077 from remote 'conan-center'
Downloading conanmanifest.txt
[==================================================] 4.6KB/4.6KB
Downloading conaninfo.txt
[==================================================] 1.2KB/1.2KB
Downloading conan_package.tgz
[==================================================] 5.6MB/5.6MB
Decompressing conan_package.tgz: 100%|██████████| 5.32M/5.32M [00:00<00:00, 24.0MB/s]
OpenSSL/1.0.2n@conan/stable: Package installed 606fdb601e335c2001bdf31d478826b644747077
libcurl/7.61.1@bincrafters/stable: Retrieving package ae6191bc1194317ff7cdbc84d4d302ab49975618 from remote 'conan-center'
Downloading conanmanifest.txt
[==================================================] 1.0KB/1.0KB
Downloading conaninfo.txt
[==================================================] 1.8KB/1.8KB
Downloading conan_package.tgz
[==================================================] 704.7KB/704.7KB
Decompressing conan_package.tgz: 100%|██████████| 688k/688k [00:00<00:00, 14.9MB/s]
libcurl/7.61.1@bincrafters/stable: Package installed ae6191bc1194317ff7cdbc84d4d302ab49975618

Install debug build of libcurl package:

λ conan install libcurl/7.61.1@bincrafters/stable -s build_type=Debug
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Debug
compiler=Visual Studio
compiler.runtime=MDd
compiler.version=15
os=Windows
os_build=Windows
[options]
[build_requires]
[env]

 ...  ...  ...  ...  ... 

Decompressing conan_package.tgz: 100%|██████████| 967k/967k [00:00<00:00, 15.0MB/s]
libcurl/7.61.1@bincrafters/stable: Package installed 8f5289d9807917ac37fa3752916c824d2a8061ad

Install debug and release build of a library compiling it from source:

λ conan install libcurl/7.61.1@bincrafters/stable -s build_type=None 

Install release builds of libcurl for x86 target (32 bits):

λ conan install libcurl/7.61.1@bincrafters/stable -s build_type=Release -s arch=x86
Configuration:
[settings]
arch=x86
arch_build=x86_64
build_type=Release
compiler=Visual Studio
compiler.runtime=MD
compiler.version=15
os=Windows
os_build=Windows
[options]
[build_requires]
[env]

List installed library in local cache:

λ conan search
Existing package recipes:

OpenSSL/1.0.2n@conan/stable
OpenSSL/1.0.2o@conan/stable
Poco/1.9.0@pocoproject/stable
gtest/1.8.1@bincrafters/stable
libcurl/7.61.1@bincrafters/stable
zlib/1.2.11@conan/stable

Show pacakge information

λ conan info libcurl/7.61.1@bincrafters/stable

OpenSSL/1.0.2n@conan/stable
    ID: 606fdb601e335c2001bdf31d478826b644747077
    BuildID: None
    Remote: conan-center=https://conan.bintray.com
    URL: http://github.com/lasote/conan-openssl
    License: The current OpenSSL licence is an 'Apache style' license: https://www.openssl.org/source/license.html
    Recipe: Cache
    Binary: Cache
    Binary remote: conan-center
    Creation date: 2018-05-10 07:47:33
    Required by:
        libcurl/7.61.1@bincrafters/stable
    Requires:
        zlib/1.2.11@conan/stable
libcurl/7.61.1@bincrafters/stable
    ID: ae6191bc1194317ff7cdbc84d4d302ab49975618
    BuildID: None
    Remote: conan-center=https://conan.bintray.com
    URL: http://github.com/bincrafters/conan-libcurl
    Homepage: http://curl.haxx.se
    License: MIT
    Author: Bincrafters <bincrafters@gmail.com>
    Recipe: Cache
    Binary: Cache
    Binary remote: conan-center
    Creation date: 2018-11-16 03:42:43
    Required by:
        PROJECT
    Requires:
        OpenSSL/1.0.2n@conan/stable
        zlib/1.2.11@conan/stable
zlib/1.2.11@conan/stable
    ID: 6cc50b139b9c3d27b3e9042d5f5372d327b3a9f7
    BuildID: None
    Remote: conan-center=https://conan.bintray.com
    URL: http://github.com/conan-community/conan-zlib
    Homepage: https://zlib.net
    License: Zlib
    Author: Conan Community
    Recipe: Cache
    Binary: Cache
    Binary remote: conan-center
    Creation date: 2018-12-21 02:01:48
    Required by:
        OpenSSL/1.0.2n@conan/stable
        libcurl/7.61.1@bincrafters/stable

Example CMake/Conan project

Project Files

Gist: https://gist.github.com/caiorss/5067e2981488aff1b5765b02adbfdffc

File: conanfile.txt

  • Conan project file.
  • Poco:shared=False => Static link the library.
[requires]
Poco/1.9.0@pocoproject/stable
gtest/1.8.1@bincrafters/stable

[generators]
cmake

[options]
Poco:shared=False

File: CMakeLists.txt

cmake_minimum_required(VERSION 3.9)

#========== Global Configurations =============#
#----------------------------------------------#
project(ConanTesting CXX)
set(CMAKE_CXX_STANDARD 17)     
set(CMAKE_VERBOSE_MAKEFILE ON)

# ===>> Conan bootstrap  ===============

# Automatically install conan packages if they are not installed.
# Assumptions:
#  + The file conanfile.txt is in this directory
#  + This CMakeLists.txt file is in the project ROOT directory.
#  + The conan application is the project $PATH environment variable
#    and accessible from command line.
#-------------------------------------------------
if(NOT EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
  execute_process(
    COMMAND           conan install . --install-folder "${CMAKE_BINARY_DIR}"
    WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
 )
endif()

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

#========== Targets Configurations ============#

message(" [INFO] =>> CONAN_LIBS = ${CONAN_LIBS} " )

# ==> Target for testing POCO Libraries 
add_executable(poco demo-poco.cpp)
target_link_libraries(poco PRIVATE ${CONAN_LIBS})

# ==> Target for testing GogleTest 
add_executable(agtest demo-gtest.cpp)
target_link_libraries(agtest PRIVATE ${CONAN_LIBS})

# Add target to run executable 
add_custom_target(run-poco
  COMMAND poco 
  DEPENDS poco 
  WORKING_DIRECTORY ${CMAKE_PROJECT_DIR}
  )

add_custom_target(run-gtest
  COMMAND agtest 
  DEPENDS agtest 
  WORKING_DIRECTORY ${CMAKE_PROJECT_DIR}
  )

install(TARGETS poco agtest  DESTINATION ./bin)

File: demo-gtest.cpp

#include <iostream>
#include <Poco/Process.h>
#include <gtest/gtest.h>

auto FunctionObject = [](int n){ return 5 * n + 4; };

TEST(testA, FunctionObject)
{
    EXPECT_EQ(19, FunctionObject(3));
}

TEST(testC, FunctionObject)
{
    EXPECT_EQ(123, FunctionObject(5));
}

TEST(testB, FunctionObject)
{
    EXPECT_EQ(24, FunctionObject(4));
}

File: demo-poco.cpp

#include <iostream>
#include <Poco/Process.h>

int main()
{
    std::cout << "Running POCO Libraries Launch." << std::endl;
    std::cout << "Poco Libraries are AWESOME!" << std::endl;

    #if !defined(_WIN32)
      std::cerr << " [INFO] I am running on some Unix-like Operating System." << std::endl;
      Poco::Process::launch("cat", {"/etc/protocols"});
   #else
      std::cerr << " [INFO] I am running on Windows." << std::endl;
      Poco::Process::launch("notepad.exe", {});
   #endif
   return 0;
}
Building on Windows

Install Conan packages in the current project at directory ./build/ - the packages are download from the default remote repository and stored at the Conan cache. Once they were downloaded, further usages of those packages will use them from the cache.

$  conan install . --install-folder build 

Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=Visual Studio
compiler.runtime=MD
compiler.version=15
os=Windows
os_build=Windows
[options]
[build_requires]
[env]

gtest/1.8.1@bincrafters/stable: WARN: Package is corrupted, removing folder: C:\Users\archbox\.conan\data\gtest\1.8.1\bincrafters\stable\package\3f7b6d42d6c995a23d193db1f844ed23ae943226
PROJECT: Installing C:\Users\archbox\conan-test\conanfile.txt
Requirements
    OpenSSL/1.0.2o@conan/stable from 'conan-center' - Cache
    Poco/1.9.0@pocoproject/stable from 'conan-center' - Cache
    gtest/1.8.1@bincrafters/stable from 'conan-center' - Cache
    zlib/1.2.11@conan/stable from 'conan-center' - Cache
Packages
    OpenSSL/1.0.2o@conan/stable:606fdb601e335c2001bdf31d478826b644747077 - Download
    Poco/1.9.0@pocoproject/stable:09378ed7f51185386e9f04b212b79fe2d12d005c - Download
    gtest/1.8.1@bincrafters/stable:3f7b6d42d6c995a23d193db1f844ed23ae943226 - Download
    zlib/1.2.11@conan/stable:6cc50b139b9c3d27b3e9042d5f5372d327b3a9f7 - Download

 ... ....    ... ....    ... ....    ... ....    ... ....    ... ....    ... .... 

Poco/1.9.0@pocoproject/stable: Package installed 09378ed7f51185386e9f04b212b79fe2d12d005c
PROJECT: Generator cmake created conanbuildinfo.cmake
PROJECT: Generator txt created conanbuildinfo.txt
PROJECT: Generated conaninfo.txt
PROJECT: Generated graphinfo

List ./build directory:

λ ls build\
conanbuildinfo.cmake  conanbuildinfo.txt  conaninfo.txt  graph_info.json

Check project packages:

$ conan info .

PROJECT
    ID: 78e985959974aade35877b722f1e41355f5575f4
    BuildID: None
    Requires:
        Poco/1.9.0@pocoproject/stable
OpenSSL/1.0.2o@conan/stable
    ID: 35ea421ef4c1d32898da44c28e3cc900bc6459dc
    BuildID: None
    Remote: conan-center=https://conan.bintray.com
    URL: http://github.com/lasote/conan-openssl
    License: The current OpenSSL licence is an 'Apache style' license: https://www.openssl.org/source/license.html
    Recipe: Cache
    Binary: Cache
    Binary remote: conan-center
    Creation date: 2018-08-27 04:12:47
    Required by:
        Poco/1.9.0@pocoproject/stable
    Requires:
        zlib/1.2.11@conan/stable
Poco/1.9.0@pocoproject/stable
    ID: 67516f54281f3227d74b2b66f92537d98ff1103d
    BuildID: None
    Remote: conan-center=https://conan.bintray.com
    URL: http://github.com/pocoproject/conan-poco
    License: The Boost Software License 1.0
    Recipe: Cache
    Binary: Cache
    Binary remote: conan-center
    Creation date: 2018-08-30 08:28:08
    Required by:
        PROJECT
    Requires:
        OpenSSL/1.0.2o@conan/stable
zlib/1.2.11@conan/stable
    ID: 1d877a3df840030e6a8abb74c5ffb9088d08b47a
    BuildID: None
    Remote: conan-center=https://conan.bintray.com
    URL: http://github.com/conan-community/conan-zlib
    Homepage: https://zlib.net
    License: Zlib
    Author: Conan Community
    Recipe: Cache
    Binary: Cache
    Binary remote: conan-center
    Creation date: 2018-12-21 07:01:48
    Required by:
        OpenSSL/1.0.2o@conan/stable

Configure CMake on Windows for 64 bits target:

λ cmake -H. -Bbuild -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX=.

Compile with release build and install at ./bin:

λ cmake --build build --target install --config Release

  ...  ...  ...  ...  ...  ...  ...  ...  ... 
PostBuildEvent:
  setlocal
  "C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=Release -P cmake_install.cmake
  if %errorlevel% neq 0 goto :cmEnd
  :cmEnd
  endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
  :cmErrorLevel
  exit /b %1
  :cmDone
  if %errorlevel% neq 0 goto :VCEnd
  :VCEnd
  -- Install configuration: "Release"
  -- Installing: C:/Users/archbox/conan-test/./bin/poco.exe
  -- Installing: C:/Users/archbox/conan-test/./bin/agtest.exe
FinalizeBuildStatus:
  Deleting file "x64\Release\INSTALL\INSTALL.tlog\unsuccessfulbuild".
  Touching "x64\Release\INSTALL\INSTALL.tlog\INSTALL.lastbuildstate".
Done Building Project "C:\Users\archbox\conan-test\build\install.vcxproj" (default targets).


Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:11.72

List directory ./bin

λ where ls
C:\Program Files\Git\usr\bin\ls.exe

λ ls bin
agtest.exe*  poco.exe*

Run application bin/agtest.exe:

λ bin\agtest.exe
Running main() from gmock_main.cc
[==========] Running 3 tests from 3 test cases.
[----------] Global test environment set-up.
[----------] 1 test from testA
[ RUN      ] testA.FunctionObject
[       OK ] testA.FunctionObject (0 ms)
[----------] 1 test from testA (0 ms total)

[----------] 1 test from testC
[ RUN      ] testC.FunctionObject
C:\Users\archbox\conan-test\demo-gtest.cpp(14): error: Expected equality of these values:
  123
  FunctionObject(5)
    Which is: 29
[  FAILED  ] testC.FunctionObject (0 ms)
[----------] 1 test from testC (0 ms total)

[----------] 1 test from testB
[ RUN      ] testB.FunctionObject
[       OK ] testB.FunctionObject (0 ms)
[----------] 1 test from testB (0 ms total)

[----------] Global test environment tear-down
[==========] 3 tests from 3 test cases ran. (4 ms total)
[  PASSED  ] 2 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] testC.FunctionObject

 1 FAILED TEST

Note: Due to the following code in CMakeLists.txt, it is not needed to run the command conan-install before cmake to install the packages as this block will automatically run the conan-install command if the packages are not installed in the project ./build directory. It allows to configure CMake in a single step with $ cmake -Bbuild … or open the project in an IDE which supports CMake without running conan directly.

  • Summary: with this piece of code, it is not necessary to run conan, Cmake will run it automatically as a subprocess.
if(NOT EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
  execute_process(
    COMMAND           conan install . --install-folder "${CMAKE_BINARY_DIR}"
    WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
 )
endif()
Building on Linux

Clone gist:

$ git clone https://gist.github.com/caiorss/5067e2981488aff1b5765b02adbfdffc conan-test2
Cloning into 'conan-test2'...
remote: Enumerating objects: 8, done.
remote: Counting objects: 100% (8/8), done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 8 (delta 1), reused 3 (delta 1), pack-reused 0
Unpacking objects: 100% (8/8), done.

List directory:

$ ls
CMakeLists.txt  conanfile.txt  demo-gtest.cpp  demo-poco.cpp

CMake configuration step:

  • Note: The CMakeLists.txt file is set to automatically run Conan in the build directory.
  • Note: The packages weren’t download because they are already cached.
$ cmake -H. -Bbuild -G Ninja -DCMAKE_INSTALL_PREFIX=.
-- Current conanbuildinfo.cmake directory: /home/archbox/root-scripts/conan-test2/build
-- Conan: Compiler GCC>=5, checking major version 8
-- Conan: Checking correct version: 8
-- Conan: Using cmake global configuration
-- Conan: Adjusting default RPATHs Conan policies
-- Conan: Adjusting language standard
 [INFO] =>> CONAN_LIBS = PocoMongoDB;PocoNet;PocoNetSSL;PocoCrypto;PocoData;PocoDataSQLite;PocoZip;PocoUtil;PocoXML;PocoJSON;PocoFoundation;rt;gmock_main;gmock;gtest;pthread;ssl;crypto;dl;z 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/archbox/root-scripts/conan-test2/build


$ ls build/
bin/         CMakeCache.txt        conanbuildinfo.txt  rules.ninja
CMakeFiles/  cmake_install.cmake   conaninfo.txt
build.ninja  conanbuildinfo.cmake  graph_info.json

Run all targets: (build all executables and libraries)

$ cmake --build build --target
[4/4] Linking CXX executable bin/agtest

Install:

$ cmake --build build --target install
[0/1] Install the project...
-- Install configuration: ""
-- Installing: /home/archbox/root-scripts/conan-test2/./bin/poco
-- Set runtime path of "/home/archbox/root-scripts/conan-test2/./bin/poco" to ""
-- Installing: /home/archbox/root-scripts/conan-test2/./bin/agtest
-- Set runtime path of "/home/archbox/root-scripts/conan-test2/./bin/agtest" to ""

$ ls bin/
agtest*  poco*

Run the executable bin/agtest.

$ bin/agtest --gtest_list_tests
Running main() from gmock_main.cc
testA.
  FunctionObject
testC.
  FunctionObject
testB.
  FunctionObject


$ bin/agtest 
Running main() from gmock_main.cc
[==========] Running 3 tests from 3 test cases.
[----------] Global test environment set-up.
[----------] 1 test from testA
[ RUN      ] testA.FunctionObject
[       OK ] testA.FunctionObject (0 ms)
[----------] 1 test from testA (0 ms total)

... ... .... 

 1 FAILED TEST

Run the executable bin/poco

$ # /etc/protocols:
# $Id: protocols,v 1.12 2016/07/08 12:27 ovasik Exp $
#
# Internet (IP) protocols
#
#	from: @(#)protocols	5.1 (Berkeley) 4/17/89
#
# Updated for NetBSD based on RFC 1340, Assigned Numbers (July 1992).
# Last IANA update included dated 2011-05-03
#
# See also http://www.iana.org/assignments/protocol-numbers

ip	0	IP		# internet protocol, pseudo protocol number
hopopt	0	HOPOPT		# hop-by-hop options for ipv6

... .... ... ... .... ... ... .... ... ... .... ... ... .... ... 

Example CMake/Conan project with conan-cmake module

Project Files

This sample project uses the CMake wrapper cmake-conan for integrating Conan and CMake without the file conanfile.txt or running conan from command line before using CMake.

CMake Module cmake-conan:

Project Gist:

Packages used in this sample project: (Conan reference)

This project can be downloaded with:

# Clone repository 
$ git clone https://gist.github.com/caiorss/7b0732f5de5ebc40981521e63a122d8e gist 
$ cd gist 
 
# Open in QTCreator IDE 
$ qtcrator CMakeLists.txt 

File: CMakeLists.txt

cmake_minimum_required(VERSION 3.9)

#========== Global Configurations =============#
#----------------------------------------------#
project(ConanTesting CXX)
set(CMAKE_CXX_STANDARD 17)     
set(CMAKE_VERBOSE_MAKEFILE ON)

# ============= Conan Bootstrap =============================#

# Download automatically, you can also just copy the conan.cmake file
if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
   message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
   file(DOWNLOAD "https://github.com/conan-io/cmake-conan/raw/v0.13/conan.cmake"
                 "${CMAKE_BINARY_DIR}/conan.cmake")
endif()

include(${CMAKE_BINARY_DIR}/conan.cmake)

conan_cmake_run(REQUIRES

                # Libraries to be installed locally
                Poco/1.9.0@pocoproject/stable
                gtest/1.8.1@bincrafters/stable

                BASIC_SETUP
                BUILD missing
                )

#========== Find Packages =====================#

find_package(GTest REQUIRED)

# find_package(Poco  REQUIRED Foundation)

#========== Targets Configurations ============#


# ==> Target for testing POCO Libraries 
add_executable(poco demo-poco.cpp)
target_link_libraries(poco PRIVATE ${CONAN_LIBS})

# ==> Target for testing GogleTest 
add_executable(agtest demo-gtest.cpp)
target_link_libraries(agtest PRIVATE GTest::GTest GTest::Main)
add_test(MyGoogleTest agtest)

install(TARGETS poco agtest  DESTINATION ./bin)

File: demog-gtest.cpp

#include <iostream>
#include <Poco/Process.h>
#include <gtest/gtest.h>

auto FunctionObject = [](int n){ return 5 * n + 4; };

TEST(testA, FunctionObject)
{
        EXPECT_EQ(19, FunctionObject(3));
}

TEST(testC, FunctionObject)
{
        EXPECT_EQ(123, FunctionObject(5));
}

TEST(testB, FunctionObject)
{
        EXPECT_EQ(24, FunctionObject(4));
}

File: poco-test.cpp

#include <iostream>
#include <Poco/Process.h>

int main()
{
    std::cout << "Running POCO Libraries Launch." << std::endl;
    std::cout << "Poco Libraries are AWESOME!" << std::endl;

    #if !defined(_WIN32)
      std::cerr << " [INFO] I am running on some Unix-like Operating System." << std::endl;
      Poco::Process::launch("cat", {"/etc/protocols"});
   #else
      std::cerr << " [INFO] I am running on Windows." << std::endl;
      Poco::Process::launch("notepad.exe", {});
    #endif

   return 0;
}
Building on Linux/Unix

Clone repository:

$ git clone https://gist.github.com/caiorss/7b0732f5de5ebc40981521e63a122d8e gist 
Cloning into 'gist'...
remote: Enumerating objects: 8, done.
remote: Counting objects: 100% (8/8), done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 8 (delta 1), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (8/8), done.

Show project files:

$ ls gist/
CMakeLists.txt  demo-gtest.cpp  demo-poco.cpp

CMake - configuration => Generate project files.

  • $ cmake -Hgist -Bcache -GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=.
    • -Hgist
      • => Set source code location to directory ./gist
    • -Bcache
      • => Set binary output directory to ./cache
    • -GNinja
      • => Use Ninja build instead of Makefile
    • -DCMAKE_BUILD_TYPE=Debug
      • => Enable debug build which generates debugging symbols and disable optimization.
    • -DCMAKE_INSTALL_PREFIX=.
      • => Set install directory to current directory (PWD)
$ cmake -Hgist -Bcache -GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=. 

-- The CXX compiler identification is GNU 8.3.1
-- Check for working CXX compiler: /usr/lib64/ccache/c++
-- Check for working CXX compiler: /usr/lib64/ccache/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Downloading conan.cmake from https://github.com/conan-io/cmake-conan
-- Conan: Automatic detection of conan settings from cmake
-- Conan: Settings= -s;build_type=Debug;-s;compiler=gcc;-s;compiler.version=8;-s;compiler.libcxx=libstdc++11
-- Conan executing: conan install . -s build_type=Debug -s compiler=gcc -s compiler.version=8 -s compiler.libcxx=libstdc++11 -g=cmake --build=missing
-- Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Debug
compiler=gcc
compiler.libcxx=libstdc++11
compiler.version=8
os=Linux
os_build=Linux
[options]
[build_requires]
[env]

conanfile.txt: Installing package
Requirements
    OpenSSL/1.0.2o@conan/stable from 'conan-center' - Cache
    Poco/1.9.0@pocoproject/stable from 'conan-center' - Cache
    gtest/1.8.1@bincrafters/stable from 'conan-center' - Cache
    zlib/1.2.11@conan/stable from 'conan-center' - Cache
Packages
    OpenSSL/1.0.2o@conan/stable:9c111a8074926a7147291383e3d366f41bac77b3 - Cache
    Poco/1.9.0@pocoproject/stable:5d73f6d80f86b797938bd4121e0ee66b325e7063 - Cache
    gtest/1.8.1@bincrafters/stable:884a98ecd973519f5d71b74c29f9e7ddcbd902d4 - Cache
    zlib/1.2.11@conan/stable:761432f3453a17c960259b5b2605153e3bcffd7d - Cache

gtest/1.8.1@bincrafters/stable: Already installed!
zlib/1.2.11@conan/stable: Already installed!
OpenSSL/1.0.2o@conan/stable: Already installed!
Poco/1.9.0@pocoproject/stable: Already installed!
conanfile.txt: Generator cmake created conanbuildinfo.cmake
conanfile.txt: Generator txt created conanbuildinfo.txt
conanfile.txt: Generated conaninfo.txt
conanfile.txt: Generated graphinfo

-- Conan: Loading conanbuildinfo.cmake
-- Conan: Adjusting output directories
-- Conan: Using cmake global configuration
-- Conan: Adjusting default RPATHs Conan policies
-- Conan: Adjusting language standard
-- Current conanbuildinfo.cmake directory: /home/archbox/projects/cache
-- Conan: Compiler GCC>=5, checking major version 8
-- Conan: Checking correct version: 8
-- Found GTest: /home/archbox/.conan/data/gtest/1.8.1/bincrafters/stable/package/884a98ecd973519f5d71b74c29f9e7ddcbd902d4/lib/libgtestd.a  
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Configuring done
-- Generating done
-- Build files have been written to: /home/archbox/projects/cache

Show cache directory:

$ tree -L 2 cache
cache
├── bin
│   ├── agtest
│   └── poco
├── build.ninja
├── CMakeCache.txt
├── CMakeFiles
│   ├── 3.14.3
│   ├── agtest.dir
│   ├── CheckLibraryExists
│   ├── cmake.check_cache
│   ├── CMakeError.log
│   ├── CMakeOutput.log
│   ├── CMakeTmp
│   ├── feature_tests.bin
│   ├── feature_tests.cxx
│   ├── poco.dir
│   └── TargetDirectories.txt
├── cmake_install.cmake
├── conanbuildinfo.cmake
├── conanbuildinfo.txt
├── conan.cmake
├── conanfile.txt
├── conaninfo.txt
├── graph_info.json
└── rules.ninja

7 directories, 18 files

Build all targets:

$ cmake --build cache --target 
[4/4] Linking CXX executable bin/agtest

Run executable agtest (GoogleTest)

$ cache/bin/agtest  

Run executable poco

$ cache/bin/poco 

Install:

 $ cmake --build cache --target install
 [0/1] Install the project...
 -- Install configuration: "Debug"
 -- Installing: /home/archbox/projects/./bin/poco
 -- Set runtime path of "/home/archbox/projects/./bin/poco" to ""
 -- Installing: /home/archbox/projects/./bin/agtest
 -- Set runtime path of "/home/archbox/projects/./bin/agtest" to ""

$ ls bin/
agtest*  poco*

# Run app ./agtest 
$ bin/agtest 

# Run app poco 
$ bin/poco 

Make conan-cmake module globally available

The cmake-conan cmake module can be installed globally in the system by moving the file conan.cmake to the default location where CMake built-in modules are stored.

Those locations are:

  • For Linux
    • //usr/share/cmake/Modules/
  • For Mac OSX
    • Similar path schema to Linux
  • For Windows NT
    • C:\Program Files (x86)\CMake\Modules

Installation on Linux:

$ mkdir -p /usr/share/cmake/Modules/custom && cd /usr/share/cmake/Modules/custom
$ curl -O https://github.com/conan-io/cmake-conan/raw/v0.13/conan.cmake

Project Usage:

cmake_minimum_required(VERSION 2.8)
project(test-package)

# ============= Conan Boosttrap =========================#
include(custom/conan)

set(CONAN_PROFILE default)
conan_cmake_run(REQUIRES
                   Poco/1.9.0@pocoproject/stable
                   gtest/1.8.1@bincrafters/stable
                BASIC_SETUP
                BUILD missing)

# ============= Find Package ===========================#
add_executable(test-package "main.cpp")
target_link_libraries(test-package hello)

Vcpkg package manager

Documentation

Windows Vcpkg Intallation

Assumption: Visual studio development tools are already installed.

1 Download and install VCPKG

  • Note: Assumes that vcpkg will be installed at C:\vcpkg
$ cd C:\
$ git clone https://github.com/Microsoft/vcpkg
$ cd vcpkg/
$ bootstrap-vcpkg.bat

2 Run the command Windows Key + R or execute from the terminal the following command. It opens the environment variables Window.

$ rundll32.exe sysdm.cpl,EditEnvironmentVariables

3 Set the following environment variables.

  • Set PATH to %PATH%;C:\vcpkg
  • Add new variable VCPKG_ROOT and set it to: C:\vcpkg

4 Test installation. Open a new terminal and enter:

# Show where is the vcpkg.exe executable 
C:\Users\archbox> where vcpkg
C:\vcpkg\vcpkg.exe

# Check whether environment variable VCPKG_ROOT is set:
C:\Users\archbox> echo %VCPKG_ROOT%
C:\vcpkg

# List installed package 
C:\Users\archbox>vcpkg list
freeglut:x64-windows                               3.0.0-5          Open source implementation of GLUT with source a...
freeglut:x86-windows                               3.0.0-5          Open source implementation of GLUT with source a...
libjpeg-turbo:x86-windows                          1.5.3-1          libjpeg-turbo is a JPEG image codec that uses SI...
libpng:x86-windows                                 1.6.35-1         libpng is a library implementing an interface fo...
opengl:x86-windows                                 0.0-5            Open Graphics Library (OpenGL)[3][4][5] is a cro...
pybind11:x64-windows                               2.2.3-1          pybind11 is a lightweight header-only library th...
python3:x64-windows                                3.6.4-2          The Python programming language as an embeddable...
zlib:x86-windows                                   1.2.11-3         A compression library

Linux Vcpkg Installation

1 Create install directory

  • In this instruction: VCPKG will be installed at directory $HOME/opt/vcpkg or /home/<<MY-USER>/opt/vcpkg/
$ mkdir -p ~/opt && cd ~/opt

2 Download and compile VCPKG

$ git clone https://github.com/Microsoft/vcpkg
$ cd vcpkg/
$ sh bootstrap-vcpkg.sh 

3 Run VCPKG:

$ ./vcpkg
Commands:
  vcpkg search [pat]              Search for packages available to be built
  vcpkg install <pkg>...          Install a package
  vcpkg remove <pkg>...           Uninstall a package
  vcpkg remove --outdated         Uninstall all out-of-date packages
  vcpkg list                      List installed packages
  vcpkg update                    Display list of packages for updating

  ... ... ... ... ... ....   ... . .. ... . .. ... .. .... 

For more help (including examples) see the accompanying README.md.

4 Add VCPKG to search $PATH variable in order to be able to call it from any directory.

  • Edit: ~/.bashrc or ~/.bash_profile and add the following code and restart the REPL.
# Directory where installed VCPKG
export VCPKG_ROOT=$HOME/opt/vcpkg/

# Make vcpkg tool callable from anywhere 
export PATH=$PATH:$VCPKG_ROOT

Show all available packages

  • $ vcpkg search
$ vcpkg search 

3fd                  2.6.2            C++ Framework For Fast Development
abseil               2018-11-08-1     an open-source collection designed to augment the C++ standard library. Abseil...
ace                  6.5.3            The ADAPTIVE Communication Environment
aixlog               1.2.1            Header-only C++ logging library 
alac                 2017-11-03-c3... The Apple Lossless Audio Codec (ALAC) is a lossless audio codec developed by A...
alac-decoder         0.2              ALAC C implementation of a decoder, written from reverse engineering the file ...
alembic              1.7.10           Alembic is an open framework for storing and sharing scene data that includes ...
allegro5             5.2.4.0          Allegro is a cross-platform library mainly aimed at video game and multimedia ...

 ... ...  ... ...  ... ...  ... ...  ... ...  ... ...  ... ... 

aws-sdk-cpp[waf]                      C++ SDK for the AWS waf service
aws-sdk-cpp[waf-regional]             C++ SDK for the AWS waf-regional service
aws-sdk-cpp[workdocs]                 C++ SDK for the AWS workdocs service
aws-sdk-cpp[workmail]                 C++ SDK for the AWS workmail service
aws-sdk-cpp[workspaces]               C++ SDK for the AWS workspaces service
aws-sdk-cpp[xray]                     C++ SDK for the AWS xray service

 ... ...  ... ...  ... ...  ... ...  ... ...  ... ...  ... ... 

boost-polygon        1.68.0           Boost polygon module
boost-pool           1.68.0           Boost pool module
boost-predef         1.68.0           Boost predef module
boost-preprocessor   1.68.0           Boost preprocessor module
boost-process        1.68.0           Boost process module
boost-program-opt... 1.68.0           Boost program_options module
boost-property-map   1.68.0           Boost property_map module
boost-property-tree  1.68.0           Boost property_tree module
boost-proto          1.68.0           Boost proto module
boost-ptr-container  1.68.0           Boost ptr_container module
boost-python         1.68.0-2         Boost python module
boost-qvm            1.68.0           Boost qvm module
boost-random         1.68.0           Boost random module
boost-range          1.68.0           Boost range module

 ... ...  ... ...  ... ...  ... ...  ... ...  ... ...  ... ... 

Removing package

$ vcpkg.exe remove libjpeg-turbo:x86-windows
Your feedback is important to improve Vcpkg! Please take 3 minutes to complete our survey by running: vcpkg contact --survey
The following packages will be removed:
    libjpeg-turbo:x86-windows
Removing package libjpeg-turbo:x86-windows...
Removing package libjpeg-turbo:x86-windows... done
Purging package libjpeg-turbo:x86-windows...
Purging package libjpeg-turbo:x86-windows... done

Example: Project with spdlog and Boost Ublas

File: CMakeLists.txt

cmake_minimum_required(VERSION 3.9)

if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
  set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
    CACHE STRING "")
  message(" [INFO] VCPKG CMAKE_TOOLCHAIN_FILE = ${CMAKE_TOOLCHAIN_FILE}")
endif()

#========== Global Configurations =============#
#----------------------------------------------#
project(SpdLogVCPKGTest)
set(CMAKE_CXX_STANDARD 17)     
set(CMAKE_VERBOSE_MAKEFILE ON)

#========== Targets Configurations ============#

# Build an executable (Unix-like OSes generates ./AppDemo1, on
# Windows ./opengDemo1.exe)
# ..........................................
find_package(spdlog CONFIG REQUIRED)
add_executable(AppDemo1 demo.cpp)
target_link_libraries(AppDemo1 PRIVATE spdlog::spdlog)

# Add target to run executable 
add_custom_target(run-app
  COMMAND AppDemo1 
  DEPENDS AppDemo1 
  WORKING_DIRECTORY ${CMAKE_PROJECT_DIR}
  )

install(TARGETS AppDemo1 DESTINATION ./bin)
if(WIN32)
  # Install DLL depedency.
  # The only way to know the required dependencies is to
  # take a look at the build tree directory <<BUILD-TREE>>\Debug
  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Debug/fmtd.dll
    DESTINATION "bin")
endif()

File: demo.cpp

#include <iostream>
#include <spdlog/spdlog.h>
#include <spdlog/sinks/stdout_sinks.h>

// Headers for vectors 
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/io.hpp>

namespace ub = boost::numeric::ublas;

int main(){
    auto console = spdlog::stdout_logger_mt("stdout-console");
    console->info("Testing logging information to command line");

    console->info("Welcome to spdlog version {}.{}.{} !", SPDLOG_VER_MAJOR, SPDLOG_VER_MINOR, SPDLOG_VER_PATCH);
    console->warn("Easy padding in numbers like {:08d}", 12);
    console->critical("Support for int: {0:d};  hex: {0:x};  oct: {0:o}; bin: {0:b}", 42);
    console->info("Support for floats {:03.2f}", 1.23456);
    console->info("Positional args are {1} {0}..", "too", "supported");
    console->info("{:>8} aligned, {:<8} aligned", "right", "left");

    ub::vector<double> vec1(3, 2.2) ; vec1[2] = -5.1;
    ub::vector<double> vec2(3, -1.2); vec2[2] = 1.1;

    std::cout << "Vec1 = " << vec1 << std::endl;
    std::cout << "3.0 * Vec1 = " << 3.0 * vec1 << std::endl;
    std::cout << "Norm1(Vec1) = " << ub::norm_1(vec1) << std::endl;
    std::cout << "Vec2 - Vec1 = " << vec2 - vec1 << std::endl;

    std::cout << "\n Enter RETURN to exit" << std::endl;
    std::cin.get();
    return 0;
}

Install Vcpkg libraries Boost Ublas and spdlog:

# Windows installation 
$ vcpkg install spdlog:x64-windows
$ vcpkg install boost-ublas:x64-windows

# Installation on Linux, OSX, or any other Unix-like OS. 
$ vcpkg install spdlog
$ vcpkg install boost-ublas

Visual Studio

  • The project can be compiled, modified, debugged and managed by opening it with Visual Studio as a directory or by invoking Visual Studio form command developer command prompt with the following command.
# devenv <PATH-TO-PROJECT DIRECTORY>

# Assumes that the current directory is the project top directory
$ devenv .

All CMake Targets can be viewed from the VS Solution Explorer.

images/solution-explorer-visual-spdlog.png

images/cmake-project-vs-spdlog.png

Manual Compilation - CMake Configuration Step

CMake Configuration on Windows with Visual Studio building tools as backed:

  • In the project directory run:
$ cmake -H. -Bbuild -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX=.

CMake Configuration on Linux using Makefiles:

# Configuration using Makefiles 
$ cmake -H. -Bbuild -DCMAKE_INSTALL_PREFIX=.

# Configuration using Ninja building system 
$ cmake -H. -Bbuild -G Ninja -DCMAKE_INSTALL_PREFIX=.

Manual Compilation - CMake Building Step

Building all CMake targets (compilation targets to build executables and libraries):

$ cmake --build build --target 

Run install target on Windows:

$ cmake --build build --target install 

  ... ... ... ... .... 
PrepareForBuild:
  Creating directory "x64\Debug\INSTALL\".
  Creating directory "x64\Debug\INSTALL\INSTALL.tlog\".
InitializeBuildStatus:
  Creating "x64\Debug\INSTALL\INSTALL.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
PostBuildEvent:
  setlocal
  "C:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=Debug -P cmake_install.cmake
  if %errorlevel% neq 0 goto :cmEnd
  :cmEnd
  endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
  :cmErrorLevel
  exit /b %1
  :cmDone
  if %errorlevel% neq 0 goto :VCEnd
  :VCEnd
  -- Install configuration: "Debug"
  -- Installing: C:/Users/archbox/Desktop/spdlogtest/./bin/AppDemo1.exe
  -- Up-to-date: C:/Users/archbox/Desktop/spdlogtest/bin/fmtd.dll
FinalizeBuildStatus:
  Deleting file "x64\Debug\INSTALL\INSTALL.tlog\unsuccessfulbuild".
  Touching "x64\Debug\INSTALL\INSTALL.tlog\INSTALL.lastbuildstate".
Done Building Project "C:\Users\archbox\Desktop\spdlogtest\build\install.vcxproj" (default targets).
Build succeeded.
 .... ... .... ... .... ... .... ...

Run install target on Linux:

$ cmake --build build --target install
[2/3] Install the project...
-- Install configuration: ""
-- Installing: /home/archbox/root-scripts/spdlog/./bin/AppDemo1

Check install output on Windows:

$ ls bin
AppDemo1.exe*  fmtd.dll*

Check install output on Linux:

$ ls bin/
AppDemo1*

Run program:

# Run on Windows
bin\AppDemo1.exe 

[2019-01-09 16:17:13.360] [stdout-console] [info] Testing logging information to command line
[2019-01-09 16:17:13.361] [stdout-console] [info] Welcome to spdlog version 1.2.0 !
[2019-01-09 16:17:13.361] [stdout-console] [warning] Easy padding in numbers like 00000012
[2019-01-09 16:17:13.361] [stdout-console] [critical] Support for int: 42;  hex: 2a;  oct: 52; bin: 101010
[2019-01-09 16:17:13.361] [stdout-console] [info] Support for floats 1.23
[2019-01-09 16:17:13.362] [stdout-console] [info] Positional args are supported too..
[2019-01-09 16:17:13.362] [stdout-console] [info]    right aligned, left     aligned
Vec1 = [3](2.2,2.2,-5.1)
3.0 * Vec1 = [3](6.6,6.6,-15.3)
Norm1(Vec1) = 9.5
Vec2 - Vec1 = [3](-3.4,-3.4,6.2)

 Enter RETURN to exit

Example: Project with OpenGL + FreeGLUT

GIST: Cmake C++ project with VCPKG package manager and OpengGL/FreeGlut

File: CMakeLists.txt

cmake_minimum_required(VERSION 3.9)

if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
  set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
    CACHE STRING "")
    message(" [INFO] VCPKG CMAKE_TOOLCHAIN_FILE = ${CMAKE_TOOLCHAIN_FILE}")
endif()

#========== Global Configurations =============#
#----------------------------------------------#
project(OpengGL_Widnows)
set(CMAKE_CXX_STANDARD 17)     
set(CMAKE_VERBOSE_MAKEFILE ON)

find_package(OpenGL REQUIRED)
find_package(GLUT REQUIRED)
find_package(GLU  REQUIRED)

#========== Targets Configurations ============#

# Build an executable (Unix-like OSes generates ./openglDemo1, on
# Windows ./opengDemo1.exe)
# ..........................................
add_executable(openglDemo1 opengl1.cpp)
target_link_libraries(openglDemo1 PRIVATE GLUT::GLUT)

if(UNIX)
  target_link_libraries(openglDemo1 PRIVATE GL)
endif()

# Add extension .bin to executable name to make it easier
# to identify that the binary file is an executable.
# So, it turns  openglDemo1 becomes openglDemo1.bin 
if(UNIX)
  set_target_properties(openglDemo1 PROPERTIES SUFFIX ".bin")
endif()

# Add target to run executable 
add_custom_target(run-ex1
    COMMAND openglDemo1 
    DEPENDS openglDemo1 
    WORKING_DIRECTORY ${CMAKE_PROJECT_DIR}
)

# It installs (copies) the target files to a path relative to CMAKE_INSTALL_PREFIX
# So, it will copy the built files to ${CMAKE_INSTALL_PREFIX}/out
message(" Freeglut DLL = ${GLUT_RUNTIME_LIBRARY} ${FREEGLUT_DYNAMIC}
") install(TARGETS openglDemo1 DESTINATION out) install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/freeglut.dll" DESTINATION out)

File: opengl1.cpp

#include <iostream>
#if defined(_WIN32)
  #include <windows.h>
#endif 
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>

void renderFunction();

int main(int argc, char ** argv){

    std::cerr << "[INFO] Starting OpenGL main loop." << std::endl;
	
    glutInit(&argc, argv);  
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    glutInitWindowSize(500, 500);
    glutCreateWindow("Window 1");
    // Display Callback Function 
    glutDisplayFunc(&renderFunction);
    // Start main loop 
    glutMainLoop();
    std::cerr << "[INFO] Exit OpenGL main loop." << std::endl;
    return 0;
}

void renderFunction(){
        std::cerr << "[INFO] Running loop." << std::endl;
    // Clear the current output buffer
    glClear(GL_COLOR_BUFFER_BIT);   

    // Rotate 10 degrees counterclockwise around z axis
    glRotated(10, 0, 0, 1);

    // Set the current color (RGB) drawing to blue
    glColor3f(0.0, 0.0, 1.0);

    // Start polygon 
    glBegin(GL_POLYGON);
    glVertex3f(-0.5, -0.5, 0);
    glVertex3f( 0.5, -0.5, 0);
    glVertex3f( 0.5,  0.5, 0);
    glVertex3f(-0.5,  0.5, 0);
    // End polygon 
    glEnd();

    glFlush();
}

Install FreeGlut library:

Search FreeGlut library:

$ vcpkg search freeglut

freeglut             3.0.0-5          Open source implementation of GLUT with source and binary backwards compatibil...

If your library is not listed, please open an issue at and/or consider making a pull request:
    https://github.com/Microsoft/vcpkg/issues

Install FreeGlut Library:

  • $ vcpkg install freeglut:x64-Windows
    • Install library compiled for 64 bits target.
  • $ vcpkg install freeglut:x86-Windows
    • Install library compiled for x86 bits target.
$ vcpkg install freeglut:x64-Windows

The following packages will be built and installed:
    freeglut[core]:x64-windows
Starting package 1/1: freeglut:x64-windows
Building package freeglut[core]:x64-windows...
A suitable version of git was not found (required v2.20.0). Downloading portable git v2.20.0...
Downloading git...
  https://github.com/git-for-windows/git/releases/download/v2.20.0.windows.1/PortableGit-2.20.0-32-bit.7z.exe -> C:\vcpkg\downloads\PortableGit-2.20.0-32-bit.7z.exe
Extracting git...
A suitable version of 7zip was not found (required v18.1.0). Downloading portable 7zip v18.1.0...
Downloading 7zip...
  https://www.nuget.org/api/v2/package/7-Zip.CommandLine/18.1.0 -> C:\vcpkg\downloads\7-zip.commandline.18.1.0.nupkg
Extracting 7zip...
A suitable version of nuget was not found (required v4.6.2). Downloading portable nuget v4.6.2...
Downloading nuget...
  https://dist.nuget.org/win-x86-commandline/v4.6.2/nuget.exe -> C:\vcpkg\downloads\nuget.exe
-- Downloading http://downloads.sourceforge.net/project/freeglut/freeglut/3.0.0/freeglut-3.0.0.tar.gz...
-- Extracting source C:/vcpkg/downloads/freeglut-3.0.0.tar.gz
-- Configuring x64-windows
-- Building x64-windows-dbg
-- Building x64-windows-rel
-- Performing post-build validation
-- Performing post-build validation done
Building package freeglut[core]:x64-windows... done
Installing package freeglut[core]:x64-windows...
Installing package freeglut[core]:x64-windows... done
Elapsed time for package freeglut:x64-windows: 2.215 min

Total elapsed time: 2.215 min

The package freeglut is compatible with built-in CMake targets:

    find_package(GLUT REQUIRED)
    target_link_libraries(main PRIVATE GLUT::GLUT)

Clone the GIST for avoiding crating the sources manually:

$ git clone https://gist.github.com/caiorss/4e36d7423cfd456f39c26ba476873a3c opengl-cmake-demo
Cloning into 'opengl-cmake-demo'...
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (4/4), done.
Unpacking objects: 100% (4/4), done.
remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0

$ cd opengl-cmake-demo\

$ dir
 Volume in drive C has no label.
 Volume Serial Number is 

 Directory of C:\Users\archbox\Desktop\opengl-cmake-demo

01/08/2019  05:57 PM    <DIR>          .
01/08/2019  05:57 PM    <DIR>          ..
01/08/2019  05:57 PM             1,630 CMakeLists.txt
01/08/2019  05:57 PM             1,188 opengl1.cpp
               2 File(s)          2,818 bytes
               2 Dir(s)   1,157,586,944 bytes free

Perform CMake configuration step generating building scripts:

$ cmake -H. -Bbuild -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX=.
 [INFO] VCPKG CMAKE_TOOLCHAIN_FILE = C:\vcpkg/scripts/buildsystems/vcpkg.cmake
-- The C compiler identification is MSVC 19.16.27025.1
-- The CXX compiler identification is MSVC 19.16.27025.1
 ... ...  ... ...  ... ...  ... ...  ... ...  ... ...  ... ... 
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenGL: opengl32
-- Found GLUT: C:/vcpkg/installed/x64-windows/debug/lib/freeglut.lib
-- WARNING: you are using the obsolete 'GLU' package, please use 'OpenGL' instead
 Freeglut DLL =
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/archbox/Desktop/opengl-cmake-demo/build

Build all targets:

  • $ cmake –build build –config debug
  • $ cmake –build build –config release
$ cmake --build build --config debug

Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 1/8/2019 6:02:01 PM.
Project "C:\Users\archbox\Desktop\opengl-cmake-demo\build\ALL_BUILD.vcxproj" on node 1 (default targets).
Project "C:\Users\archbox\Desktop\opengl-cmake-demo\build\ALL_BUILD.vcxproj" (1) is building "C:\Users\archbox\Desktop\opengl-cmake-demo\buil d\ZERO_CHECK.vcxproj" (2) on node 1 (default targets).

 .. .. .   ... .. .   ... .. .   ... .. .   ... .. .   ... .. .   ... .. .   ... .. .   ... .. . 

ClCompile:
  C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\CL.exe /c /I"C:\vcpkg\installed\x6
  4-windows\include" /Zi /W3 /WX- /diagnostics:classic /Od /Ob0 /D WIN32 /D _WINDOWS /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /EHsc /RTC1 /M
  Dd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR /std:c++17 /Fo"openglDemo1.dir\Debug\\" /Fd"openglDemo1.dir\Debug\vc141.pdb" /Gd
   /TP /errorReport:queue "C:\Users\archbox\Desktop\opengl-cmake-demo\opengl1.cpp"
  Microsoft (R) C/C++ Optimizing Compiler Version 19.16.27025.1 for x64
  opengl1.cpp
  Copyright (C) Microsoft Corporation.  All rights reserved.

  cl /c /I"C:\vcpkg\installed\x64-windows\include" /Zi /W3 /WX- /diagnostics:classic /Od /Ob0 /D WIN32 /D _WINDOWS /D "CMAKE_INTDIR=\"Debug\"
  " /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR /std:c++17 /Fo"openglDemo1.dir\Debug\\" /Fd"opengl
  Demo1.dir\Debug\vc141.pdb" /Gd /TP /errorReport:queue "C:\Users\archbox\Desktop\opengl-cmake-demo\opengl1.cpp"

Link:
  C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\link.exe /ERRORREPORT:QUEUE /OUT:"
  C:\Users\archbox\Desktop\opengl-cmake-demo\build\Debug\openglDemo1.exe" /INCREMENTAL /NOLOGO "C:\vcpkg\installed\x64-windows\debug\lib\free
  glut.lib" kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /M
  ANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"C:/Users/archbox/Desktop/opengl-cmake-demo/build/Debug/openglD
  emo1.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:/Users/archbox/Desktop/opengl-cmake-demo/build/Debug/openglDemo1.li
  b" /MACHINE:X64  /machine:x64 openglDemo1.dir\Debug\opengl1.obj

....   ....   ....   ....   ....   ....   ....   ....   ....   ....   ....   ....   ....   ....   ....   ....   ....   .... 

Done Building Project "C:\Users\archbox\Desktop\opengl-cmake-demo\build\ALL_BUILD.vcxproj" (default targets).


Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:06.76

Run executable (target run-ex1):

  • This is conveniced target was added for making easier to run the executable from the terminal. It is not needed for IDEs like Visual Studio, JetBrains - Clion and so on.
$ cmake --build build --target run-ex1

Compile and run on Linux:

$ vcpkg install freeglut   
$ git clone https://gist.github.com/caiorss/4e36d7423cfd456f39c26ba476873a3c opengl
$ cd opengl 
$ cmake -H. -Bbuild 
$ cmake --build build --target run-ex1 

Example: Project with Nana GUI Library

GIST: Nana GUI + VCPKG + CMake project

File: CMakeLists.txt

cmake_minimum_required(VERSION 3.9)

if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
  set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
    CACHE STRING "")
    message(" [INFO] VCPKG CMAKE_TOOLCHAIN_FILE = ${CMAKE_TOOLCHAIN_FILE}")
endif()

#======= Global Project Configuration =========#

project(DummyProject)
set(CMAKE_CXX_STANDARD 17)     

#========== Targets Configurations ============#

## ==> Target: gui1 - Executable: gui1

find_package(unofficial-nana CONFIG REQUIRED)
add_executable(gui1 gui1.cpp)
target_link_libraries(gui1 PRIVATE
  unofficial::nana::nana fontconfig stdc++fs)

# Add target to run executable gui1 (similar to $ make run)
add_custom_target(run-gui1
    COMMAND gui1
    DEPENDS gui1
    WORKING_DIRECTORY ${CMAKE_PROJECT_DIR}
)

# Install directory relative to ${CMAKE_PREFIX_PATH}
install(TARGETS gui1 DESTINATION ./bin)

File: gui1.cpp

#include <nana/gui.hpp>
#include <nana/gui/widgets/label.hpp>
#include <nana/gui/widgets/button.hpp>

int main()
{
    using namespace nana;

    //Define a form.
    form fm;
    //Define a label and display a text.
    label lab{fm, "Hello, <bold blue size=16>Nana C++ Library</>"};
    lab.format(true);
    //Define a button and answer the click event.
    button btn{fm, "Quit"};
    btn.events().click([&fm]{
        fm.close();
    });
    //Layout management
    fm.div("vert <><<><weight=80% text><>><><weight=24<><button><>><>");
    fm["text"]<<lab;
    fm["button"] << btn;
    fm.collocate();
    //Show the form
    fm.show();
    //Start to event loop process, it blocks until the form is closed.
    exec();
}

Project directory:

$ tree -L 1
.
├── build
├── CMakeLists.txt
└── gui1.cpp

1 directory, 2 files

Install Linux dependency libraries (Tested on Linux Fedora):

  • Note: Sometimes VCPKG cannot install system libraries. In this case, it is necessary to use the current distribution package manager.
$ sudo dnf install libX11-devel.x86_x64
$ sudo dnf install libXft-devel.x86_64

Clone gist containing the project:

$ git clone https://gist.github.com/caiorss/724942d43cd11c6ee5b3461ac067c846 sample-vcpkg-proj
$ cd sample-vcpkg-proj

Install package Nana with vcpkg:

$ vcpkg install nana

 ...  ...  ...  ... 
-- Using cached /home/archbox/opt/vcpkg/downloads/cnjinhao-nana-v1.6.2.tar.gz
-- Using source at /home/archbox/opt/vcpkg/buildtrees/nana/src/v1.6.2-51b575c248
-- Configuring x64-linux-dbg
-- Configuring x64-linux-rel
-- Building x64-linux-dbg
-- Building x64-linux-rel
-- Performing post-build validation
-- Performing post-build validation done
Building package nana[core]:x64-linux... done
Installing package nana[core]:x64-linux... 
Installing package nana[core]:x64-linux... done
Elapsed time for package nana:x64-linux: 1.825 min

Total elapsed time: 1.825 min

The package nana:x64-linux provides CMake targets:

    find_package(unofficial-nana CONFIG REQUIRED)
    target_link_libraries(main PRIVATE unofficial::nana::nana)

List installed packages:

$ vcpkg list
boost-accumulators:x64-linux                       1.68.0           Boost accumulators module
boost-algorithm:x64-linux                          1.68.0           Boost algorithm module
boost-any:x64-linux                                1.68.0           Boost any module
boost-array:x64-linux                              1.68.0           Boost array module

... ... ...   ... ... ...   ... ... ...   ... ... ...   ... ... ...   ... ... ...   ... ... ...
  
gsl:x64-linux                                      2.4-3            The GNU Scientific Library is a numerical librar...
gtest:x64-linux                                    1.8.1-1          GoogleTest and GoogleMock testing frameworks.
libiconv:x64-linux                                 1.15-5           GNU Unicode text conversion
libjpeg-turbo:x64-linux                            1.5.3-1          libjpeg-turbo is a JPEG image codec that uses SI...
liblzma:x64-linux                                  5.2.4            Compression library with an API similar to that ...
libpng:x64-linux                                   1.6.35-1         libpng is a library implementing an interface fo...
nana:x64-linux                                     1.6.2            Cross-platform library for GUI programming in mo...
pybind11:x64-linux                                 2.2.3-1          pybind11 is a lightweight header-only library th...
spdlog:x64-linux                                   1.2.1            Very fast, header only, C++ logging library
zlib:x64-linux                                     1.2.11-3         A compression librar

Filter nana package:

$ vcpkg list | grep nana
nana:x64-linux                                     1.6.2            Cross-platform library for GUI programming in mo...

Building with CMake Ninja or Makefile

Cmake configuration step

  • Default system building system
    • $ cmake -H. -Bbuild
  • Ninja building System:
    • $ cmake -H. -Bbuild -G Ninja
# Install executable at (.) curret directory
$ cmake -H. -Bbuild -G Ninja  -DCMAKE_PREFIX_PATH=.

 [INFO] VCPKG CMAKE_TOOLCHAIN_FILE = /home/archbox/opt/vcpkg/scripts/buildsystems/vcpkg.cmake
-- The C compiler identification is GNU 8.2.1
-- The CXX compiler identification is GNU 8.2.1
-- Check for working C compiler: /usr/lib64/ccache/cc

 ... ... ... ... ... ... 

-- Found Freetype: /home/archbox/build/vcpkg/installed/x64-linux/lib/libfreetype.a (found version "2.8.1") 
-- Found ZLIB: /home/archbox/build/vcpkg/installed/x64-linux/debug/lib/libz.a (found version "1.2.11") 
-- Found PNG: /home/archbox/build/vcpkg/installed/x64-linux/share/png/../../lib/libpng16.a (found version "1.6.35") 
-- Found BZip2: /home/archbox/build/vcpkg/installed/x64-linux/lib/libbz2.a (found version "1.0.6") 
-- Looking for BZ2_bzCompressInit
-- Looking for BZ2_bzCompressInit - found
-- Looking for XOpenDisplay in /usr/lib64/libX11.so;/usr/lib64/libXext.so
-- Looking for XOpenDisplay in /usr/lib64/libX11.so;/usr/lib64/libXext.so - found

 ... ... ... ... ... ... 

-- Looking for shmat - found
-- Found X11: /usr/lib64/libX11.so
-- Found JPEG: /home/archbox/build/vcpkg/installed/x64-linux/debug/lib/libjpeg.a  
-- Configuring done
-- Generating done
-- Build files have been written to: /home/archbox/root-scripts/vcpkg2/build

Build all targets:

$ cmake --build build --target 

Build and run executable target gui1 (target: run-gui1)

$ cmake --build build --target run-gui1
[3/3] cd /home/archbox/root-scripts/vcpkg2/build && /home/archbox/root-scripts/vcpkg2/build/gui1

Install executable:

$ cmake --build build --target install
[2/3] Install the project...
-- Install configuration: ""
-- Installing: /home/archbox/root-scripts/vcpkg2/./bin/gui1

Run installed executable at ./bin

$ bin/gui1 

Directory after compilation:

$ tree . -L 2
.
├── bin
│   └── gui1
├── build
│   ├── build.ninja
│   ├── CMakeCache.txt
│   ├── CMakeFiles
│   ├── cmake_install.cmake
│   ├── gui1
│   ├── install_manifest.txt
│   └── rules.ninja
├── CMakeLists.txt
└── gui1.cpp

3 directories, 9 files

Analyse executable:

Check binary format

$ file bin/gui1 

bin/gui1: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux),
dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for
GNU/Linux 3.2.0,
BuildID[sha1]=b2273c2b397213af8c8b8e8808da1ebc195d3b4d, with
debug_info, not stripped

Check file size

# File size 
$ du -h bin/gui1
19M	bin/gui1
19M	total

Remove debugging symbols

$ strip bin/gui1 

Check file size again:

$ du -h bin/gui1
3.3M	bin/gui1
3.3M	total

Check shared libraries dependencies:

$ ldd bin/gui1
        linux-vdso.so.1 (0x00007fff18930000)
        libfontconfig.so.1 => /lib64/libfontconfig.so.1 (0x00007f5f73116000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f5f72ef7000)
        libX11.so.6 => /lib64/libX11.so.6 (0x00007f5f72bb6000)
        libXext.so.6 => /lib64/libXext.so.6 (0x00007f5f729a4000)
        libXft.so.2 => /lib64/libXft.so.2 (0x00007f5f7278d000)
        libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f5f723fa000)
        libm.so.6 => /lib64/libm.so.6 (0x00007f5f72066000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f5f71e4e000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f5f71a8f000)
        libfreetype.so.6 => /lib64/libfreetype.so.6 (0x00007f5f717d8000)
        libexpat.so.1 => /lib64/libexpat.so.1 (0x00007f5f7159d000)
        libuuid.so.1 => /lib64/libuuid.so.1 (0x00007f5f71396000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f5f7335a000)
        libxcb.so.1 => /lib64/libxcb.so.1 (0x00007f5f7116d000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007f5f70f69000)
        libXrender.so.1 => /lib64/libXrender.so.1 (0x00007f5f70d5e000)
        libbz2.so.1 => /lib64/libbz2.so.1 (0x00007f5f70b4d000)
        libpng16.so.16 => /lib64/libpng16.so.16 (0x00007f5f70919000)
        libz.so.1 => /lib64/libz.so.1 (0x00007f5f70702000)
        libXau.so.6 => /lib64/libXau.so.6 (0x00007f5f704fe000)