Tutorial by Examples

To create a build target producing an executable, one should use the add_executable command: add_executable(my_exe main.cpp utilities.cpp) This creates a build target, e.g. make my_exe for GNU make, with the appropriate invocations of the configured compiler to pr...
To create an build target that creates an library, use the add_library command: add_library(my_lib lib.cpp) The CMake variable BUILD_SHARED_LIBS controls whenever to build an static (OFF) or an shared (ON) library, using for example cmake .. -DBUILD_SHARED_LIBS=ON. However, you can explicitly se...

Page 1 of 1