All Projects → robotology → How To Export Cpp Library

robotology / How To Export Cpp Library

Licence: mit
An OS-agnostic C++ library template in plain CMake.

Labels

Projects that are alternatives of or similar to How To Export Cpp Library

Pothossdr
Pothos SDR windows development environment
Stars: ✭ 193 (-15.35%)
Mutual labels:  cmake
Papyros
General issue tracking and wikis for Papyros
Stars: ✭ 205 (-10.09%)
Mutual labels:  cmake
Repository
Repository of LuaDist modules available for installation using the luadist-git command line tool
Stars: ✭ 218 (-4.39%)
Mutual labels:  cmake
Cpp Boilerplate
A small c++ template with modern CMake
Stars: ✭ 197 (-13.6%)
Mutual labels:  cmake
Fixed point
C++ Binary Fixed-Point Arithmetic
Stars: ✭ 199 (-12.72%)
Mutual labels:  cmake
Directx Vs Templates
Direct3D Visual Studio Templates
Stars: ✭ 205 (-10.09%)
Mutual labels:  cmake
Gazebo ros demos
Example robots and code for interfacing Gazebo with ROS
Stars: ✭ 192 (-15.79%)
Mutual labels:  cmake
Frut
Building JUCE projects using CMake made easy
Stars: ✭ 228 (+0%)
Mutual labels:  cmake
Vcmi
Open-source engine for Heroes of Might and Magic III
Stars: ✭ 2,514 (+1002.63%)
Mutual labels:  cmake
Skui
Skia-based C++ UI framework
Stars: ✭ 218 (-4.39%)
Mutual labels:  cmake
Methanekit
🎲 Modern 3D graphics made simple with cross-platform C++17 meta-API on top of DirectX 12 & Metal (Vulkan is coming)
Stars: ✭ 197 (-13.6%)
Mutual labels:  cmake
Learning Cmake
learning cmake
Stars: ✭ 2,524 (+1007.02%)
Mutual labels:  cmake
Engine
A basic cross-platform 3D game engine
Stars: ✭ 208 (-8.77%)
Mutual labels:  cmake
Wiiuse
WiiUse "feature complete" cross-platform Wii Remote access library
Stars: ✭ 196 (-14.04%)
Mutual labels:  cmake
Ios Cmake
A blank iOS app build system written in CMake. Includes building a dynamically linked C++ framework and bundling it into the app.
Stars: ✭ 220 (-3.51%)
Mutual labels:  cmake
Diagon
Interactive ASCII art diagram generators. 🌟
Stars: ✭ 189 (-17.11%)
Mutual labels:  cmake
Cmake Scripts
A selection of useful scripts for use in CMake projects, include code coverage, sanitizers, and dependency graph generation.
Stars: ✭ 202 (-11.4%)
Mutual labels:  cmake
Gtest Demo
Unit test demo using Google Test.
Stars: ✭ 227 (-0.44%)
Mutual labels:  cmake
Lirios
🏠 General issue tracking and wiki for Liri
Stars: ✭ 228 (+0%)
Mutual labels:  cmake
Compiler
Pawn compiler for SA-MP with bug fixes and new features - runs on Windows, Linux, macOS
Stars: ✭ 209 (-8.33%)
Mutual labels:  cmake

📚 How to export C++ library

This repository provides an OS-agnostic C++ library template with plain CMake files with the following features:

Overview

💢 Complexities around C++ library

This project simplifies the process of taking a bunch of C++ classes/functions and exposing them as a CMake package so that third-party code can use it. However, the risk is that new users underestimate the actual complexity of maintaining a C++ library used by many external users!

A complete and proper training on the art and craft of C++ library maintenance is out of the scope of this project, but we feel that we should at least report some useful link to drive the curiosity and the attention of new users to topics relevant to a proper maintenence of a C++ library.

Problems typically overlooked by new C++ library developers:

🏅 CI and badges

Awesomness Github Actions
Awesome GitHub Actions status

Go to the top

🎛 Dependencies

There are no dependencies for this template. However, we make use of the following three files from the YCM project.

  1. AddInstallRPATHSupport
  2. AddUninstallTarget
  3. InstallBasicPackageFiles

These files can be found under ./cmake subdirectory and they are plain CMake code. Check them out, they make your life easier!

If you like the YCM project and it is not a problem to have it as a dependency, updating the template is as simple as follows.

  1. Install YCM
  2. Add find(YCM REQUIRED) in the main CMakeLists.txt, after the project() command.
  3. Delete/Empty the ./cmake folder.

You are now 100% good to go! 🎉

Go to the top

🔨 Build the libraries

If your shell environment supports mkdir, you can just execute the following commands:

git clone https://github.com/robotology/how-to-export-cpp-library.git
cd how-to-export-cpp-library
mkdir build && cd build
cmake ..
cmake --build .

You can also create platform specific input files for a native build system using CMake Generator.

For more detailed example, check the CGold section on Generate native tool files.

Go to the top

✂️ Copy and customize this template

For customizing the CMake/C++ code, check the comments in the main CMakeLists.txt.

To enable Continuous Integration (CI) using Travis (Linux and macOS) and AppVeyor (Windows) follow the documentation of these services to create an account and connect them to your repository.

Once you're done with that, you can easily modify the appveyor.yml and travis.yml to account changes for your project, such as the project name from how-to-export-cpp-library (the name of the git repository) and LibTemplateCMake (the name of the CMake Project/Package) to the one of your repository/project.

Go to the top

🔬 Add a test

This snippet from test/CMakeLists.txt shows the fundamental commands to add a test:

add_executable(test_name_exec test_name_exec_source.cpp)
target_link_libraries(test_name_exec lib-template-cmake)
add_test(NAME test_name COMMAND test_name_exec)

A single test is just a simple C++ executable with an int main() function that returns 0 on success and any value different from 0 upon failure.

For more info on this topic and related CMake commands, check add_test documentation and references therein.

Go to the top

🐛 Run the tests

If you want to run tests, compile the library enabling the BUILD_TESTING CMake option. Once you do that, test will be compiled along with the library and any other executable in the project.

To list the compiled/available tests, run ctest -N in the build directory. To run the tests, use ctest command in the build directory, while to run a single test, us ctest -R test_name. You can add -VV to get a full verbose output during tests.

For more info and options with ctest, check the ctest documentation.

Go to the top

📝 Generate documentation

If the Doxygen tool is installed on your machine, the Doxygen documentation for the project can be generated using the dox target, see doc/CMakeLists.txt for details on the process of documents generation. Once generated, the doxygen documentation can be browsed at build/doc/html/index.html. If the documentation is generated, it will be installed in ${CMAKE_INSTALL_PREFIX}/share/doc/${PROJECT_NAME}/html/. The build and installation directories for the doxygen documentation can be changed using the DOXYGEN_BUILD_DIR and DOXYGEN_INSTALL_DIR CMake variables.

If you are interested on how to host your documentation using gh-pages, robotology/how-to-document-modules contains a detailed (and maintained) example on how to produce and host Doxygen documentation using GitHub gh-pages.

Go to the top

📑 Licensing your library

The project as-is comes with two files:

  1. LICENSE
  2. LICENSE-template

The first file, LICENSE, is the one covering this very template. You have to modify/delete it. ⚠️ Don't use it straightforwardly as it includes our name, not yours!

The second file, LICENSE-template, is an MIT License template that you can use adding the year and copyright holder names in the heading. We provide template of the MIT License as it is the one used for this template, but you can choose one of the many available.

Should you not be sure what to do about it (licensing produces severe headhaces) you can use one of the following website to clear your mind:

Go to the top

💼 Other template and examples

The Awesome CMake repository contains an interesting list of template and examples similar to this one.

Go to the top


If you feel this CMake project template was useful, consider starring the project!
We also created the following shield to provide a nice-looking link to this project (feel free to modify its look-and-feel as you please).
Otherwise, not a big deal! 👍

how-to-export-cpp-library

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].