*cmake.txt* CMake Integration for Vim *cmake* CONTENTS ~ *cmake-contents* =========================================================================== 1. About |cmake-about| 2. Quick start |cmake-quickstart| 2.1. Discovering CMake |cmake-quickstart-discover| 2.2. Installing the Plugin |cmake-quickstart-install| 3. Options |cmake-options| 4. Methods |cmake-methods| 4.1 Creating a Project |:CMakeCreateBuild| 4.2 Building |:CMakeBuild| 4.3 Cleaning |:CMakeClean| 4.4 Testing |:CMakeTest| 4.5 Installing |:CMakeInstall| 4.6 Get Cache Variable's Value |:CMakeGetVar| 4.7 Invoking Targets |:CMakeTarget| 4.8 Cleaning & Building At Once |:CMakeCleanBuild| 5. Integrations |cmake-integrations| 5.1 Syntastic |cmake-integrations-syntastic| 5.2 YouCompleteMe |cmake-integrations-ycm| =========================================================================== ABOUT *cmake-about* CMake is a "Cross-Platform Makefile generator". However, CMake can generate more than Makefiles; including files for Eclipse and KDevelop build systems as well as Ninja build files (from the Chromium project), making it quite diverse in its output. The act of integrating CMake with Vim allows for developers to use the facilities of CMake without having to constantly switch back and forth. This plugin goes a step further and automatically sets 'makeprg' for you to help other tools related to Java, C++, C, Objective C or Fortan-based programming easily invoke CMake's version of the build system. It can also incorporate support with other plugins like 'dispatch', YouCompleteMe, and 'syntastic'. 2. QUICK START ~ *cmake-quickstart* Ensure that you have a working (discoverable in '$PATH' by Vim) version of CMake. You can check that CMake is invokable by Vim by running the following command: > !cmake --version You should get output similar to the following: > cmake version 2.8.10.1 At the time of writing, CMake version 2.6+ or greater would work with 'cmake', but feel free to send a report if older versions don't work. 3. OPTIONS |cmake-options| The options described are reflected with their default values. 3.1. C++ COMPILER ~ *cmake-options-cxx-compiler* *cmake-options-cpp-compiler* > let g:cmake_cxx_compiler = 'clang++' Defines the default C++ compiler that CMake will use. 3.2. C COMPILER ~ *cmake-options-c-compiler* > let g:cmake_c_compiler = 'clang' Defines the default C compiler that CMake will use. 3.3. BUILD DIRECTORIES ~ *cmake-options-build-dirs* > let g:cmake_build_dirs = [ "build" ] Defines a list of the names of directories to search for 'CMakeCache.txt'. 3.4. BUILD CONFIGURATION TYPE ~ *cmake-options-build-type* > let g:cmake_build_type = "Debug" Defines the build configuration type to invoke CMake with. Some typical values for this is DEBUG, RELEASE, and RELWITHDEBINFO. 3.5. INSTALLATION PREFIX ~ *cmake-options-install-prefix* > let g:cmake_install_prefix = "$HOME/.local" Defines the installation prefix at which the project will be installed at. 3.6. BUILD SHARED LIBRARIES ~ *cmake-options-build-shared-libs* > let g:cmake_build_shared_libs = 1 Determines whether or not libraries will be built as shared libraries by default. 3.7. SET MAKEPRG ~ *cmake-options-set-makeprg* > let g:cmake_set_makeprg = 1 Determines whether or not the 'makeprg' value in Vim will be set to a tweaked 'make' where it builds using the files in your specified build directory. 3.8. INTEGRATIONS ~ *cmake-options-inject-flags* Determines which known integrations are to be enabled like Syntastic or YouCompleteMe. By default, `cmake.vim` checks if each plug-in exists and enables if they are present. To disable, set the value to 0. 4. METHODS ~ *cmake-methods* There's a few methods binded to the editor for use of the developer. In the future, some of these methods might be automatically mapped to the keyboard within CMake files for easy use. 4.1 CREATING A BUILD ~ *:CMakeCreateBuild* `:CMakeCreateBuild` takes only one argument, the name of the directory that the build directory will be. It'll fail if the name isn't one of the values provided in `g:cmake_build_directories` so take care to use one of those. It'll make the directory if it doesn't exist, remove `CMakeCache.txt` if it exists (with confirmation) and invoke CMake within that directory. 4.2 BUILDING ~ *:CMakeBuild* Invokes `cmake --build $CMAKE_BINARY_DIR --target all`, building all CMake targets at once. 4.3 CLEANING ~ *:CMakeClean* Invokes `cmake --build $CMAKE_BINARY_DIR --target clean`, cleaning the project of build artificats. 4.4 TESTING ~ *:CMakeTest* Invokes `make -C $CMAKE_BINARY_DIR test`, running whatever you got for that target. 4.5 INSTALLING ~ *:CMakeInstall* Invokes `make -C $CMAKE_BINARY_DIR install`, installs all of the things! Doesn't take into consideration file permissions or access, silly ol' make. 4.6 GET CACHE VARIABLE'S VALUE ~ *:CMakeGetVar* Obtains the specified variable's value from CMake's cache. Note that fact, it has to be set into the cache for it to be retrieved. 4.7 INVOKING TARGETS ~ *:CMakeTarget* Invokes `cmake --build $CMAKE_BINARY_DIR --target `, being the target you'd choose to invoke. 4.8 CLEANING & BUILDING AT ONCE ~ *:CMakeCleanBuild* Invokes `:CMakeClean` and then `:CMakeBuild`. 5. INTEGRATIONS ~ *cmake-integrations* Life isn't fun if a plug-in doesn't integrate to another. `cmake.vim`, with a bit of lost sleep, can work with syntastic and You Complete Me with with the enabling of an option. 5.1. SYNTASTIC ~ *cmake-integrations-syntastic* No extra work is required. `cmake.vim` adds the necessary flags to all of the C and C++ checkers. Work is planned to refactor this logic and allow explicit checker parameters (since it's targeted for the gcc/ycm checkers and not cpplint). 5.2. YOU COMPLETE ME ~ *cmake-integrations-ycm* YouCompleteMe provides a means of extending its configuration for the use of autocompletion. To do so, you'd need to get the "b:cmake_flags" variables from your "client_data" dictionary. From there, you'd add it to the list of flags that are to be passed into YCM. cmake_flags = kwargs['client_data'] final_flags += cmake_flags This can be disabled by setting `g:cmake_injects_flags.ycm` to 0. vim:tw=78:ts=8:ft=help:norl: