This CMake project contains the following directories and files:
my_header_lib
: C++ header-only librarymy_static_lib
: C++ static librarymy_shared_lib
: C++ shared librarymain
: Executabletest
: Test with Google Testcuda/cuda_main
: (option) CUDA executablecuda/my_cuda_lib
: (option) CUDA static library
The preconfigured linter and formatter settings based on the Google C++ Style Guide are included.
.clang-format
: ClangFormat.clang-tidy
: Clang-Tidy
The vcpkg is included as a submodule:
vcpkg.json
: List of dependencies
Using apt
For Ubuntu 22.04:
$ sudo apt install build-essential gdb g++-12 clang-14 cmake ninja-build pkg-config
Using homebrew
For those who want to use the latest version of the compiler:
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
$ brew install gcc llvm cmake ninja gdb
Using Apple Clang
$ xcode-select –install
Using homebrew
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
$ brew install gcc llvm cmake ninja gdb
Install Visual Studio (or Build Tools for Visual Studio for command line only) with C++ development workload.
To generate compile_commands.json
with header files, install compdb
$ python3 -m pip install compdb
Note
Currently, compdb does not seem to support Windows.
- Clone this repository with
--recursive
to include submodules.$ git clone --recursive https://github.com/yosh-matsuda/vscode-cpp-cuda-cmake-template.git
- Open the project in VSCode.
$ code vscode-cpp-cuda-cmake-template
- Install VSCode extensions
- Select compiler and build type in CMake Tools.
- Press
F7
to configure and build the project. - Press
F1
and runclangd: Restart language server
to loadcompile_commands.json
and clangd will restart. - Press
F5
to debug the target executable.(gdb) Launch
for Linux(Windows) Launch
for Windows(lldb) Launch
for MacOS- You may need to enable the Developer mode
$ sudo DevToolsSecurity -enable
- You may need to enable the Developer mode
- Untrack the
.vscode
directory and commit.$ git rm --cached -r .vscode $ git commit -m "Remove VSCode settings"
- Delete unnecessary directories and
add_subdirectory
inCMakeLists.txt
. - Change the project names and directories in
CMakeLists.txt
andvcpkg.json
. - Add your dependencies to
CMakeLists.txt
andvcpkg.json
.
- Update vcpkg submodule to the specified commit hash.
- Edit the
builtin-baseline
invcpkg.json
to put the same hash as above.