This repository contains examples and tutorials demonstrating how to link multiplaform libraries to C++ for Windows, Linux and macOS projects using CMake.
MIT License
This is a set of simple examples of how to use CMake to build C++ projects with different libraries.
All the examples are made to be compiled with CMake for Windows, Linux and macOS, except for some like PThreads that are only available on Linux.
Each directory contains a CMakeLists.txt file that is used to build the library, the complete explanation are in the README.md file of each directory.
According to your OS, the build setup is different. Check the appropriate indication according to the README.md file of each directory.
You will need cmake to build the project. You can download it here: https://cmake.org/download/
Note: If you are using an IDE, the project build selection is integrated in it. You do not need the command line to build the project.
Once you have set up your OS you can now build the project. You can either load it with your IDE (Visual Studio, Clion, etc...), or use the command line.
To use the command line build, type the following command at the project root folder.
cmake -B <build directory> -DCMAKE_BUILD_TYPE=<build optimization flag>
example:
cmake -B ./build -DCMAKE_BUILD_TYPE=Release
Then type
cmake --build <build directory> --config <build optimization flag>
example:
cmake --build ./build --config Release
To build a specific project, you can use the following command:
cmake -S . -B build -D PROJECT_TO_BUILD=<project name> -DCMAKE_BUILD_TYPE=<build optimization flag>
example:
cmake -S . -B ./build -D PROJECT_TO_BUILD=Lib_OpenMP -DCMAKE_BUILD_TYPE=Release
Then type
cmake --build <build directory> --config <build optimization flag>
example:
cmake --build ./build --config Release
Note You can build several projects at the same time by separating the project names with a semicolon. example:
cmake -S . -B ./build -D PROJECT_TO_BUILD="Lib_OpenMP;Lib_OpenCL" -DCMAKE_BUILD_TYPE=Release
EmScripten: https://emscripten.org/
OpenCL: https://www.khronos.org/opencl/
OpenCV: https://opencv.org/
OpenMP: https://www.openmp.org/
OpenMPI: https://www.open-mpi.org/
SDL2: https://www.libsdl.org/
SFML: https://www.sfml-dev.org/
GLFW: https://www.glfw.org/
GLAD: https://glad.dav1d.de/
ImGui: https://github.com/ocornut/imgui
OpenGL: https://www.opengl.org/
cliutils: https://cliutils.gitlab.io/modern-cmake/chapters/packages/OpenMP.html
The project is set with a set of different scripts:
This project is licensed under the MIT License - see the LICENSE file for details.
Quentin MOREL: