CMake functions: some explanation
make_minimum_required(VERSION 3.10)
cmake_minimum_required() : the minimum version that CMake needs to be so that the CMakeLists.txt can be read. Check version of CMake in the system by cmake --version
project(Tutorial VERSION 1.0)
project() : giving the name to the project, version of a project can be modified here
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED True)
set(): some kind of configuration or setting a variable, with CMake
option(USE_MYMATH "use tutorial provided math implementataion" ON)
option(): declare options for Dev/User to be able to change build options quickly, for example, different os or use different APIs depending on the environment
configure_file([TutorialConfig.h.in](http://tutorialconfig.h.in/) TutorialConfig.h)
configure_file() : pass environment variables from outside the code into the code, for example, VERSION 1.0 from project(), passed as @Tutorial_VERSION_MAJOR@ → via macro and header pass the value to Tutorial_VERSION_MAJOR inside the code, after build and run, you will see the Version magically appear
add_subdirectory() : this command to add a folder during the build process to find a library
list(APPEND a_variable): append a variable to a list, useful when adding a bundle of sourcecode to build a targer
add_executable(Tutorial tutorial.cxx)
add_executable() : Simply understand it as a way to declare the relationship between the binary named Tutorial and the related source files
target_link_libraries(Tutorial PUBLIC ${EXTRA_LIBS})
target_link_libraries(): declare the target that is called this Tutorial that needs the libs in list of libs in EXTRA_LIBS.
target_include_directories(Tutorial PUBLIC "${PROJECT_BINARY_DIR}" ${EXTRA_INCLUDES} )
target_include_directories() : Similar to the above, this command to declare which directories are relevant (containing some libs).