-
-
Notifications
You must be signed in to change notification settings - Fork 38
CMake build automation utility
Zeioth edited this page Nov 13, 2023
·
7 revisions
When compiler.nvim detects a CMakeLists.txt
file in the current working directory, Telescope will be populated with all its add_executable
and add_custom_target
entries.
Create a CMakeLists.txt file in your working directory and copy/paste this:
cmake_minimum_required(VERSION 3.5)
# Example of a target
project(HelloWorld)
add_executable(hello_world main.cpp)
# Example of custom target to run all tasks
add_custom_target(build_all)
add_dependencies(build_all hello_world)
Now let's create the file we are building on the example above: Create main.cpp
in the same directory.
#include <iostream>
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
}
When you open the compiler you will see the option to run it
And this is the result
In the same way you can run hello world, you can execute any command necessary to build your program.
(optionally) You can define the next globals
global | defaut value |
---|---|
CMAKE_CLEAN_FIRST |
false |
CMAKE_BUILD_DIR |
./build |
CMAKE_BUILD_TYPE |
"" |
Example:
let g:CMAKE_BUILD_TYPE='Release'
Globals persist between Neovim sessions.