@Gitter: gitter.im/cnruby
@Github: github.com/cnruby
@Twitter: twitter.com/cnruby
@Blogspot: cnruby.blogspot.com
- Requirements
- How to Disable Auto Formatting of the Code
- Install The VS Code Extension '
cmake-format
' - Why do we need the Tool '
cmake_format
'? - Get the Project
- How to Use the Tool
'cmake_format'
- How to Use the Extension
'cmake-format'
- References
- Example Codes: Format All
CMake's
Files
- VS Code
- CMake
- VS Code Extension "CMake Tool"
- VS Code Extension "CMake"
- Python 3.7+
- Tool 'cmake_format'
- VS Code Extension "cmake-format"
- Disable auto formatting of the code
# sudo apt install python-pip
pip install cmake_format
#pip install --user cmake_format
echo "# cmake-format" >> ~/.bash_profile
echo "export PATH="$HOME/Library/Python/3.7/bin:$PATH" >> ~/.bash_profile
. ~/.bash_profile
- keep the code base manageable
- allow coders to use C++ language features productively
git clone https://github.com/cnruby/w3h1_cmake.git basic_107
cd basic_107
git checkout basic_106
code .
cmake -GNinja -Bbuild/
cmake --build build/
#cmake-format --help
cmake-format --version
#
cmake-format CMakeLists.txt | more
#cmake-format --in-place CMakeLists.txt
cmake-format -i CMakeLists.txt
#
cmake-format --command-case upper CMakeLists.txt | more
cmake-format --tab-size 4 CMakeLists.txt | more
cmake-format --dump-config | more
# language yaml
cmake-format --dump-config --no-help > .cmake-format.yml
# or language json
cmake-format --dump-config json > .cmake-format.json
# or language python
cmake-format --dump-config python > .cmake-format.py
# ????
cmake-format --dump-config yaml > .cmake-format.yml
#cmake-format -i CMakeLists.txt --config-file .cmake-format.yml
cmake-format -i CMakeLists.txt -c .cmake-format.yml
cmake-format -i $(find . -name "CMakeLists.txt")
cmake-format -i $(find . -name "*.cmake")
- cmakeFormat.args: Additional command line arguments to be specified.
- like "--config-file ./.cmake-format.yaml", to specify a custom configuration
--config-file ./.cmake-format.yaml
- SHIFT+CMD+P
- Enter: "Format Document"
- OR
- SHIFT+ALT+F
- https://gitlab.kitware.com/cmake/community/-/wikis/home
- https://marketplace.visualstudio.com/items?itemName=cheshirekow.cmake-format
- https://github.com/cheshirekow/cmake_format
- https://github.com/cheshirekow/cmake_format/issues/165
- https://dev.to/10xlearner/formatting-cmake-4dle
- https://google.github.io/styleguide/cppguide.html
- https://github.com/Komet/MediaElch/blob/master/.travis.yml
- https://github.com/StableCoder/cmake-scripts/blob/master/.gitlab-ci.yml
- https://marketplace.visualstudio.com/items?itemName=mynkow.FormatdocumentonSave
- https://code.visualstudio.com/docs/editor/codebasics
- https://cnruby.blogspot.com/2020/04/how-to-install-tool-cmaketool-on-ubuntu.html
- https://preshing.com/20170511/how-to-build-a-cmake-based-project/#running-cmake-gui
- https://tuannguyen68.gitbooks.io/learning-cmake-a-beginner-s-guide/
- https://www.dealii.org/9.1.1/users/cmakelists.html
find . \( -name '*.cmake' -o -name 'CMakeLists.txt' \) \
-exec cmake-format -i {} \;
# https://github.com/googleapis/google-cloud-cpp/pull/807
find . \( -path ./.git \
-o -path ./third_party \
-o -path './cmake-build-*' \
-o -path ./build-output \
\) -prune \
-o \( -name 'CMakeLists.txt' \
-o -name '*.cmake' \
\) -print0 \
| xargs -0 cmake-format -i