programming:buildsystems:cmake:notes
Table of Contents
Programming - Build Systems - cmake - Notes
Using
If you see a CMakeLists.txt in the source tree, and there is no documentation on how to compile, the following ususally works relative to the directory with the CMakeLists.txt:
mkdir build cd build cmake ../
Adding include dirs when calling cmake
If cmake does not find certain include dirs on it's own, and you don't want to start editing cmake config files, you can expand the list of directories to search for include files when running cmake.
cmake -DCMAKE_CXX_FLAGS=-isystem\ /path/to/my/include <path to my sources>
Source:stack overflow - Adding include directories to CMake when calling it from the command line
Adding linker flags when calling cmake
cmake -DCMAKE_SHARED_LINKER_FLAGS="-fstack-protector" /path/to/source
Source: stack overlfow - How can I add linker flag for libraries with CMake?
Adding compiler flags when calling cmake
cmake -DCMAKE_C_FLAGS="-lm"
When compiling C++:
cmake -DCMAKE_CXX_FLAGS="-lm"
Source:stack overflow - How do I add a linker or compile flag in a CMake file?
programming/buildsystems/cmake/notes.txt · Last modified: 2022/08/13 10:02 by bas