Skip to content
This repository was archived by the owner on Apr 19, 2023. It is now read-only.

Commit 1e56cae

Browse files
authored
Merge pull request #175 from Jason5480/feature/cross_ide_cmake_presets
Feature/cross ide cmake presets
2 parents 26a39b1 + cc7c6e2 commit 1e56cae

7 files changed

Lines changed: 420 additions & 46 deletions

File tree

.devcontainer/.dockerignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Build directories and binary files
2+
build/
3+
out/
4+
cmake-build-*/
5+
6+
# User spesific settings
7+
CMakeUserPresets.json
8+
9+
# IDE files
10+
.vs/
11+
.idea/
12+
.vscode/
13+
!.vscode/settings.json
14+
!.vscode/tasks.json
15+
!.vscode/launch.json
16+
!.vscode/extensions.json
17+
*.swp
18+
*~
19+
_ReSharper*
20+
*.log
21+
22+
# OS Generated Files
23+
.DS_Store
24+
.AppleDouble
25+
.LSOverride
26+
._*
27+
.Spotlight-V100
28+
.Trashes
29+
.Trash-*
30+
$RECYCLE.BIN/
31+
.TemporaryItems
32+
ehthumbs.db
33+
Thumbs.db
34+
Dockerfile
Lines changed: 59 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,82 @@
1-
FROM ubuntu:bionic
1+
# [Choice] bionic (18.04), focal (20.04)
2+
ARG VARIANT="focal"
3+
FROM ubuntu:${VARIANT}
24

3-
# Install packages available from standard repos
4-
RUN apt-get update -qq && \
5+
# Restate the variant to use it later on in the llvm and cmake installations
6+
ARG VARIANT
7+
8+
# Install necessary packages available from standard repos
9+
RUN apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \
510
apt-get install -y --no-install-recommends \
6-
software-properties-common wget git gpg-agent file \
7-
python3 python3-pip doxygen graphviz ccache cppcheck build-essential \
8-
neovim emacs nano
11+
software-properties-common wget apt-utils file zip \
12+
openssh-client gpg-agent socat rsync \
13+
make ninja-build git \
14+
python3 python3-pip
915

1016
# Install conan
1117
RUN python3 -m pip install --upgrade pip setuptools && \
1218
python3 -m pip install conan && \
1319
conan --version
1420

21+
# By default, anything you run in Docker is done as superuser.
22+
# Conan runs some install commands as superuser, and will prepend `sudo` to
23+
# these commands, unless `CONAN_SYSREQUIRES_SUDO=0` is in your env variables.
24+
ENV CONAN_SYSREQUIRES_SUDO 0
25+
# Some packages request that Conan use the system package manager to install
26+
# a few dependencies. This flag allows Conan to proceed with these installations;
27+
# leaving this flag undefined can cause some installation failures.
28+
ENV CONAN_SYSREQUIRES_MODE enabled
29+
1530
# User-settable versions:
16-
# This Dockerfile should support gcc-[7, 8, 9, 10] and clang-[10, 11]
31+
# This Dockerfile should support gcc-[7, 8, 9, 10, 11] and clang-[10, 11, 12, 13]
1732
# Earlier versions of clang will require significant modifications to the IWYU section
18-
ARG GCC_VER="10"
19-
ARG LLVM_VER="11"
20-
33+
ARG GCC_VER="11"
2134
# Add gcc-${GCC_VER}
2235
RUN add-apt-repository -y ppa:ubuntu-toolchain-r/test && \
23-
apt-get update -qq && \
24-
apt-get install -y --no-install-recommends gcc-${GCC_VER} g++-${GCC_VER}
36+
apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \
37+
apt-get install -y --no-install-recommends \
38+
gcc-${GCC_VER} g++-${GCC_VER} gdb
39+
40+
# Set gcc-${GCC_VER} as default gcc
41+
RUN update-alternatives --install /usr/bin/gcc gcc $(which gcc-${GCC_VER}) 100
42+
RUN update-alternatives --install /usr/bin/g++ g++ $(which g++-${GCC_VER}) 100
2543

44+
ARG LLVM_VER="13"
2645
# Add clang-${LLVM_VER}
46+
ARG LLVM_URL="http://apt.llvm.org/${VARIANT}/"
47+
ARG LLVM_PKG="llvm-toolchain-${VARIANT}-${LLVM_VER}"
2748
RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - 2>/dev/null && \
28-
add-apt-repository -y "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-${LLVM_VER} main" && \
29-
apt-get update -qq && \
49+
add-apt-repository -y "deb ${LLVM_URL} ${LLVM_PKG} main" && \
50+
apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \
3051
apt-get install -y --no-install-recommends \
3152
clang-${LLVM_VER} lldb-${LLVM_VER} lld-${LLVM_VER} clangd-${LLVM_VER} \
3253
llvm-${LLVM_VER}-dev libclang-${LLVM_VER}-dev clang-tidy-${LLVM_VER}
3354

55+
# Set the default clang-tidy, so CMake can find it
56+
RUN update-alternatives --install /usr/bin/clang-tidy clang-tidy $(which clang-tidy-${LLVM_VER}) 1
57+
58+
# Set clang-${LLVM_VER} as default clang
59+
RUN update-alternatives --install /usr/bin/clang clang $(which clang-${LLVM_VER}) 100
60+
RUN update-alternatives --install /usr/bin/clang++ clang++ $(which clang++-${LLVM_VER}) 100
61+
3462
# Add current cmake/ccmake, from Kitware
63+
ARG CMAKE_URL="https://apt.kitware.com/ubuntu/"
64+
ARG CMAKE_PKG=${VARIANT}
3565
RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null \
3666
| gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null && \
37-
apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' && \
38-
apt-get update -qq && \
67+
apt-add-repository -y "deb ${CMAKE_URL} ${CMAKE_PKG} main" && \
68+
apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \
3969
apt-get install -y --no-install-recommends cmake cmake-curses-gui
4070

41-
# Set the default clang-tidy, so CMake can find it
42-
RUN update-alternatives --install /usr/bin/clang-tidy clang-tidy $(which clang-tidy-${LLVM_VER}) 1
71+
# Install editors
72+
RUN apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \
73+
apt-get install -y --no-install-recommends \
74+
neovim emacs nano
75+
76+
# Install optional dependecies
77+
RUN apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \
78+
apt-get install -y --no-install-recommends \
79+
doxygen graphviz ccache cppcheck
4380

4481
# Install include-what-you-use
4582
ENV IWYU /home/iwyu
@@ -64,16 +101,8 @@ RUN ln -s $(readlink -f /usr/lib/clang/${LLVM_VER}/include) \
64101
$(include-what-you-use -print-resource-dir 2>/dev/null)/include
65102

66103
## Cleanup cached apt data we don't need anymore
67-
#RUN apt-get clean && \
68-
# rm -rf /var/lib/apt/lists/*
69-
70-
# Set gcc-${GCC_VER} as default gcc
71-
RUN update-alternatives --install /usr/bin/gcc gcc $(which gcc-${GCC_VER}) 100
72-
RUN update-alternatives --install /usr/bin/g++ g++ $(which g++-${GCC_VER}) 100
73-
74-
# Set clang-${LLVM_VER} as default clang
75-
RUN update-alternatives --install /usr/bin/clang clang $(which clang-${LLVM_VER}) 100
76-
RUN update-alternatives --install /usr/bin/clang++ clang++ $(which clang++-${LLVM_VER}) 100
104+
RUN apt-get autoremove -y && apt-get clean && \
105+
rm -rf /var/lib/apt/lists/*
77106

78107
# Allow the user to set compiler defaults
79108
ARG USE_CLANG
@@ -84,17 +113,8 @@ ENV CXX=${USE_CLANG:+"clang++"}
84113
ENV CC=${CC:-"gcc"}
85114
ENV CXX=${CXX:-"g++"}
86115

87-
# By default, anything you run in Docker is done as superuser.
88-
# Conan runs some install commands as superuser, and will prepend `sudo` to
89-
# these commands, unless `CONAN_SYSREQUIRES_SUDO=0` is in your env variables.
90-
ENV CONAN_SYSREQUIRES_SUDO 0
91-
# Some packages request that Conan use the system package manager to install
92-
# a few dependencies. This flag allows Conan to proceed with these installations;
93-
# leaving this flag undefined can cause some installation failures.
94-
ENV CONAN_SYSREQUIRES_MODE enabled
95-
96116
# Include project
97-
ADD . /starter_project
98-
WORKDIR /starter_project
117+
#ADD . /workspaces/cpp_starter_project
118+
#WORKDIR /workspaces/cpp_starter_project
99119

100120
CMD ["/bin/bash"]

.devcontainer/devcontainer.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.205.2/containers/cpp
3+
{
4+
"name": "C++",
5+
"build": {
6+
"dockerfile": "Dockerfile",
7+
// Update 'VARIANT' to pick an Ubuntu OS version. Options: [bionic, focal]. Default: focal
8+
// Update 'GCC_VER' to pick a gcc and g++ version. Options: [7, 8, 9, 10, 11]. Default: 11
9+
// Update 'LLVM_VER' to pick clang version. Options: [10, 11, 12, 13]. Default: 13
10+
// Update 'USE_CLANG' to set clang as the default C and C++ compiler. Options: [1, null]. Default null
11+
// "args": {
12+
// "VARIANT": "focal",
13+
// "GCC_VER": "11",
14+
// "LLVM_VER": "13"
15+
// }
16+
},
17+
"runArgs": [
18+
"--cap-add=SYS_PTRACE",
19+
"--security-opt",
20+
"seccomp=unconfined"
21+
],
22+
// Set *default* container specific settings.json values on container create.
23+
"settings": {
24+
"cmake.configureOnOpen": true,
25+
"editor.formatOnSave": true
26+
},
27+
// Add the IDs of extensions you want installed when the container is created.
28+
"extensions": [
29+
"ms-vscode.cpptools",
30+
"ms-vscode.cmake-tools",
31+
"twxs.cmake",
32+
"ms-vscode.cpptools-themes",
33+
"cschlosser.doxdocgen",
34+
"eamodio.gitlens",
35+
"ms-python.python",
36+
"ms-python.vscode-pylance",
37+
"mutantdino.resourcemonitor"
38+
],
39+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
40+
// "forwardPorts": [],
41+
// Use 'postCreateCommand' to run commands after the container is created.
42+
//"postCreateCommand": "uname -a",
43+
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
44+
//"remoteUser": "vscode",
45+
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/${localWorkspaceFolderBasename},type=bind,consistency=delegated",
46+
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
47+
"features": {
48+
"git": "latest",
49+
"git-lfs": "latest",
50+
"powershell": "latest"
51+
}
52+
}

.gitattributes

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
###############################
2+
# Git Line Endings #
3+
###############################
4+
5+
* text=auto eol=lf
6+
*.{cmd,[cC][mM][dD]} text eol=crlf
7+
*.{bat,[bB][aA][tT]} text eol=crlf
8+
*.{vcxproj,vcxproj.filters} text eol=crlf
9+
10+
###############################
11+
# Git Large File System (LFS) #
12+
###############################
13+
14+
# Archives
15+
#*.7z filter=lfs diff=lfs merge=lfs -text
16+
#*.br filter=lfs diff=lfs merge=lfs -text
17+
#*.gz filter=lfs diff=lfs merge=lfs -text
18+
#*.tar filter=lfs diff=lfs merge=lfs -text
19+
#*.zip filter=lfs diff=lfs merge=lfs -text
20+
21+
# Documents
22+
#*.pdf filter=lfs diff=lfs merge=lfs -text
23+
24+
# Images
25+
#*.gif filter=lfs diff=lfs merge=lfs -text
26+
#*.ico filter=lfs diff=lfs merge=lfs -text
27+
#*.jpg filter=lfs diff=lfs merge=lfs -text
28+
#*.pdf filter=lfs diff=lfs merge=lfs -text
29+
#*.png filter=lfs diff=lfs merge=lfs -text
30+
#*.psd filter=lfs diff=lfs merge=lfs -text
31+
#*.webp filter=lfs diff=lfs merge=lfs -text
32+
33+
# Fonts
34+
#*.woff2 filter=lfs diff=lfs merge=lfs -text
35+
36+
# Other
37+
#*.exe filter=lfs diff=lfs merge=lfs -text

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ build/
33
out/
44
cmake-build-*/
55

6+
# User spesific settings
7+
CMakeUserPresets.json
8+
69
# IDE files
710
.vs/
811
.idea/
@@ -13,6 +16,8 @@ cmake-build-*/
1316
!.vscode/extensions.json
1417
*.swp
1518
*~
19+
_ReSharper*
20+
*.log
1621

1722
# OS Generated Files
1823
.DS_Store

0 commit comments

Comments
 (0)