All Projects → pabloariasal → Modern Cmake Sample

pabloariasal / Modern Cmake Sample

Licence: mit
Example library that shows best practices and proper usage of CMake by using targets

Labels

Projects that are alternatives of or similar to Modern Cmake Sample

Ark
ARK is a lightweight, agility, elastic, distributed plugin framework written in C++,make it easier and faster to create your own application service.
Stars: ✭ 370 (-20.09%)
Mutual labels:  cmake
Opencv Mingw Build
👀 MinGW 32bit and 64bit version of OpenCV compiled on Windows. Including OpenCV 3.3.1, 3.4.1, 3.4.1-x64, 3.4.5, 3.4.6, 3.4.7, 3.4.8-x64, 3.4.9, 4.0.0-alpha-x64, 4.0.0-rc-x64, 4.0.1-x64, 4.1.0, 4.1.0-x64, 4.1.1-x64, 4.5.0-with-contrib
Stars: ✭ 401 (-13.39%)
Mutual labels:  cmake
Cgold
🐋 The Hitchhiker’s Guide to the CMake
Stars: ✭ 428 (-7.56%)
Mutual labels:  cmake
Cmake Conan
CMake wrapper for conan C and C++ package manager
Stars: ✭ 374 (-19.22%)
Mutual labels:  cmake
Kicad Packages3d
Official KiCad 3D model libraries for rendering and MCAD integration
Stars: ✭ 392 (-15.33%)
Mutual labels:  cmake
Innoextract
A tool to unpack installers created by Inno Setup
Stars: ✭ 407 (-12.1%)
Mutual labels:  cmake
Cmake Templates
Some CMake Templates (examples). Qt, Boost, OpenCV, C++11, etc 一些栗子
Stars: ✭ 368 (-20.52%)
Mutual labels:  cmake
Tprpix
a Cross-Platform, 2D Survival Sandbox Game Project. Based on C++17/cmake/OpenGL/SQLite3.
Stars: ✭ 448 (-3.24%)
Mutual labels:  cmake
Cnl
A Compositional Numeric Library for C++
Stars: ✭ 397 (-14.25%)
Mutual labels:  cmake
Uikit Cross Platform
Cross-platform Swift implementation of UIKit, mostly for Android
Stars: ✭ 421 (-9.07%)
Mutual labels:  cmake
Cmakeconverter
This project aims to facilitate the conversion of Visual Studio to CMake projects.
Stars: ✭ 387 (-16.41%)
Mutual labels:  cmake
Mumble
Mumble is an open-source, low-latency, high quality voice chat software.
Stars: ✭ 4,418 (+854.21%)
Mutual labels:  cmake
Rules foreign cc
Build rules for interfacing with "foreign" (non-Bazel) build systems (CMake, configure-make, GNU Make, boost, ninja)
Stars: ✭ 418 (-9.72%)
Mutual labels:  cmake
Ifopt
An Eigen-based, light-weight C++ Interface to Nonlinear Programming Solvers (Ipopt, Snopt)
Stars: ✭ 372 (-19.65%)
Mutual labels:  cmake
Cpp Reflection
C++ Reflection Parser / Runtime Skeleton
Stars: ✭ 440 (-4.97%)
Mutual labels:  cmake
Cget
C++ package retrieval
Stars: ✭ 370 (-20.09%)
Mutual labels:  cmake
Ros 21 tutorials
《古月 · ROS入门21讲》课件&源码
Stars: ✭ 405 (-12.53%)
Mutual labels:  cmake
Coherent Line Drawing
🖼✨Automatically generates line drawing from a photograph
Stars: ✭ 461 (-0.43%)
Mutual labels:  cmake
Cmake Raytracer
Ray tracer written in pure CMake
Stars: ✭ 444 (-4.1%)
Mutual labels:  cmake
Tensorflow Cmake
TensorFlow examples in C, C++, Go and Python without bazel but with cmake and FindTensorFlow.cmake
Stars: ✭ 418 (-9.72%)
Mutual labels:  cmake

Modern CMake Sample

Sample project that shows proper modern CMake usage on a dummy library and an executable that uses it. Accompanying code to my blog post It's Time To Do CMake Right

Build Instructions

Dependencies

  • cmake >= 3.13
  • Boost >= 1.65
  • rapidjson >= 1.1

Building the Library

cd libjsonutils
cmake -Bbuild
cmake --build build

You can run the tests:

cmake --build build -- test

Installing the library

You can install the lib in two ways. First, in a classical way: put it somewhere in your system so that executable can find it, or two, build it but register it in the CMake's User Package Registry, avoiding installation.

Normal Installation

sudo cmake --build build -- install

This will install the example library under /usr/local/ on UNIX systems.

Alternatively, you can specify a custom installation directory by setting -DCMAKE_INSTALL_PREFIX in the cmake configure step:

cmake -Bbuild -DCMAKE_INSTALL_PREFIX=<custom_install_dir>
sudo cmake --build build -- install

To uninstall the library, you can run:

cd build
xargs rm < install_manifest.txt

see F.A.Q

Using CMake's User Package Registry

Instead of actually installing the library, you can just build it and register the build in CMake's User Package Registry

cd libjsonutils
cmake -Bbuild -DCMAKE_EXPORT_PACKAGE_REGISTRY

This will register the library's build in CMake's User Package Registry (on UNIX systems it defaults to ~/.cmake).

This is convenient, as packages depending on the library (e.g. via find_package) will be able to find it through the registry, even when the library hasn't been installed.

Building the example executable

If the library is in the CMake's User Package Registry or installed in a system known location, like /usr/local/, you just build the executable with:

cd example_exec
cmake -Bbuild
cmake --build build

If you installed the library in a custom location you must point CMake to the installation directory:

cd example_exec
cmake -Bbuild -DJSONUtils_DIR=<custom_install_dir>/lib/cmake/JSONUtils
cmake --build build

Run the executable

You are done!

cd example_exec
./build/example_exec
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].