<still under construction>
Install CMake
In a folder, create 2 files:
Main.cpp |
---|
#include <iostream>
int main()
{
std::cout << "This is a CMake test X" << std::endl;
return 0;
}
CMakeLists.txt |
---|
cmake_minimum_required(VERSION "3.21.2")
# set version according to your installed CMake's version
project("CMakeTest")
# set project name
add_executable("${PROJECT_NAME}" "Main.cpp")
# creates exe based on the *.cpp with name as previously set project name
set(some_var "a" "b" "c")
message("${some_var}")
# some_var is variable and a;b;c its values
# message() will print a;b;c accessed through ${}
Build by creating a new folder in CMakeLists.txt’s directory, cd to it and run code below
cmake ..
Make the executable (*.exe) (can run the executable in Shell/Terminal after making)
cmake --build <dir>
CMAKE_CURRENT_SOURCE_DIR | Root directory of the CMakeLists.txt |