Simpler way of declaring libraries used in CMake using the virtual libraries notation. This notation allows to express include and librarie dependencies at once. Provided with packages for applications dealing with OpenGL, Computer Vision and Media
Make the cmakego.cmake accessible to the cmake using CMAKE_MODULE_PATH and then first include it, then use the command usepackage:
cmake -DCMAKE_MODULE_PATH=~/Dropbox/repos/cmakego .
First method is based on find_package much like catkin
find_package(cmagego REQUIRED COMPONENTS ... [REQUIRED])
The second requires inclusion of the script and then the usepackage macro:
usepackage(packagename1 ... [GLOBAL] [REQUIRED])
The library name is the name of the packagename1 such as eigen, opengl or others. When found it will create the special target p::packagename.
Then the p::packagename can be used in the target_link_libraries of a target to satisfy at once both includes and libraries.
add_executable(go1 go1.cpp) target_link_libraries(go1 p::glew p::glfw p::glm p::boost p::assimp)
When REQUIRED is present then the package is enforced otherwise the cmake will terminate.
When GLOBAL is used then the virtual target is added to the global list via link_libraries and include_directories. In this way it is available to all the other targets.
In addition ALL the dependencies included by cmakego are included in the variable CMAKEGO_PACKAGES
The following example uses OpeNGL, GLEW, GLFW, GLM and AssImp. Note that dependences have been created between glew/glfw and opengl so the latter is automatically pulled and added.
cmake_minimum_required(VERSION 3.0) add_definitions(--std=c++11 -DGLM_FORCE_RADIANS) find_package(cmakego COMPONENTS glfw glew glm boost assimp) add_executable(go1 go1.cpp) target_link_libraries(go1 p::glew p::glfw p::glm p::boost p::assimp)
The supported libraries come from the domain of 3D OpenGL/AR/vision being related to the things we typically work with:
- aruco: opencv
- display (virtual)
- ffmpeg (and submodules)
- glew: opengl
- glfw: opengl, display
- gstreamer: glib2
- libusb (1.0)
- ois (for ogre)
- ovr (Oculus)
- display: this is a library for accessing the native system (X11 under Linux, CoCoa under OSX)
Provide another repository with simple examples for testing the libraries in a simple way. We are interested in coverin all the libraries above.
Start decomposing the cmakego in functional pieces, now all the libraries are selected in the main script