How to create a shared library with cmake?

I have written a library that I used to compile using a self-written Makefile, but now I want to switch to cmake. The tree looks like this (I removed all the irrelevant files): . ├── include │   ├── animation.h │   ├── buffers.h │   ├── … │   ├── vertex.h │   └── world.h └── src ├── animation.cpp … Read more

Automatically add all files in a folder to a target using CMake?

I am considering switching a cross platform project from separate build management systems in Visual C++, XCode and makefiles to CMake. One essential feature I need is to add automatically all files in a directory to a target. While this is easy to do with make, it is not easily doable with Visual C++ and … Read more

What is the difference between include_directories and target_include_directories in CMake?

I have a directory structure for my C++ code which goes like this : | |->include |->src I am writing a CMakeLists.txt file for my code. I want to understand the difference between include_directories and target_include_directories in CMake. What is the difference between their usage and in order to add my include file path which … Read more

CMake not able to find OpenSSL library

I am trying to install a software that uses cmake to install itself. When I run cmake .. on the command line, it gives me following error in the CMakeLists.txt on the line that says find_package(OpenSSL REQUIRED): — Could NOT find Git (missing: GIT_EXECUTABLE) ZLib include dirs: /usr/include ZLib libraries: /usr/lib/arm-linux-gnueabihf/libz.so Compiling with SSL support … Read more

What use is find_package() when you need to specify CMAKE_MODULE_PATH?

I’m trying to get a cross-plattform build system working using CMake. Now the software has a few dependencies. I compiled them myself and installed them on my system. Some example files which got installed: — Installing: /usr/local/share/SomeLib/SomeDir/somefile — Installing: /usr/local/share/SomeLib/SomeDir/someotherfile — Installing: /usr/local/lib/SomeLib/somesharedlibrary — Installing: /usr/local/lib/SomeLib/cmake/FindSomeLib.cmake — Installing: /usr/local/lib/SomeLib/cmake/HelperFile.cmake Now CMake has a find_package() which … Read more

How exactly does CMake work?

I’m not asking this for just myself. I hope this question will be a reference for the many newbies who like me, found it utterly perplexing about what exactly what was going on behind the scenes when for such a small CMakeLists.txt file cmake_minimum_required (VERSION 2.6) project(Tutorial) add_executable(Tutorial tutorial.cpp) and such a small tutorial.cpp int … Read more

CMake: Print out all accessible variables in a script

I’m wondering if there is a way to print out all accessible variables in CMake. I’m not interested in the CMake variables – as in the –help-variables option. I’m talking about my variables that I defined, or the variables defined by included scripts. I’m currently including: INCLUDE (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityCXX.cmake) And I was hoping that I could … Read more