Skip to content

Commit

Permalink
feat: add cpm package manager to amp-devcontainer-cpp (#609)
Browse files Browse the repository at this point in the history
* feat: add cpm package manager to amp-devcontainer-cpp

* test: add test for CPM package manager

* docs: add update hint to cron issue
  • Loading branch information
rjaegers authored Oct 21, 2024
1 parent 866a1c9 commit cccd4d0
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .devcontainer/cpp/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ FROM ubuntu:24.04@sha256:ab64a8382e935382638764d8719362bb50ee418d944c1f3d26e0c99
ARG BATS_VERSION=1.11.0
ARG CCACHE_VERSION=4.10.1
ARG CLANG_VERSION=17
ARG CPM_VERSION=0.40.2
ARG DOCKER_VERSION=27.3.1
ARG MULL_VERSION=0.22.0
ARG INCLUDE_WHAT_YOU_USE_VERSION=0.21
Expand Down Expand Up @@ -36,6 +37,9 @@ ENV CMAKE_GENERATOR="Ninja"
ENV CMAKE_EXPORT_COMPILE_COMMANDS="On"
ENV CCACHE_DIR=/root/.ccache

# Install CPM.cmake to the CMake module path
RUN wget -qP /usr/local/lib/python*/dist-packages/cmake/data/share/cmake-*/Modules/ https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_VERSION}/CPM.cmake

# Install clang toolchain
COPY .devcontainer/cpp/apt-requirements-clang.json /tmp/apt-requirements-clang.json
# hadolint ignore=SC1091
Expand Down
1 change: 1 addition & 0 deletions .devcontainer/cpp/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ add_subdirectory(clang-tools)
add_subdirectory(fuzzing)
add_subdirectory(gcc)
add_subdirectory(gcc-arm-none-eabi)
add_subdirectory(package-managers)
add_subdirectory(sanitizers)
add_subdirectory(test)
12 changes: 12 additions & 0 deletions .devcontainer/cpp/test/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@
"ENABLE_COVERAGE_TEST": "On"
}
},
{
"name": "cpm",
"inherits": "defaults",
"cacheVariables": {
"ENABLE_CPM_TEST": "On"
}
},
{
"name": "gcc",
"inherits": "defaults"
Expand Down Expand Up @@ -81,6 +88,11 @@
"configurePreset": "coverage",
"targets": ["test-coverage"]
},
{
"name": "cpm",
"configurePreset": "cpm",
"targets": ["cpm-test"]
},
{
"name": "fuzzing",
"configurePreset": "clang",
Expand Down
1 change: 1 addition & 0 deletions .devcontainer/cpp/test/package-managers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(cpm)
8 changes: 8 additions & 0 deletions .devcontainer/cpp/test/package-managers/cpm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
if (ENABLE_CPM_TEST)
include(CPM)

CPMAddPackage("gh:fmtlib/fmt#11.0.2")

add_executable(cpm-test EXCLUDE_FROM_ALL main.cpp)
target_link_libraries(cpm-test PRIVATE fmt::fmt)
endif()
7 changes: 7 additions & 0 deletions .devcontainer/cpp/test/package-managers/cpm/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <fmt/core.h>

int main()
{
fmt::print("Hello, world!\n");
return 0;
}
5 changes: 5 additions & 0 deletions .devcontainer/cpp/test/testsuite.bats
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ teardown() {
build_and_run_with_sanitizers clang
}

@test "using CPM as package manager should resolve external dependencies" {
cmake --preset cpm
cmake --build --preset cpm
}

function configure_and_build_with_ccache() {
local PRESET=${1:?}

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/issue-creation-tool-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ jobs:
- [ ] The [ARM GNU](https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads) toolchain is up to date and matches with the GCC version
- [ ] The [Clang toolchain](https://apt.llvm.org/) is up to date
- [ ] The [CPM](https://github.com/cpm-cmake/CPM.cmake) package manager is up to date
- [ ] The [Docker cli](https://download.docker.com/linux/static/stable/) is up to date
- [ ] [bats-core](https://github.com/bats-core/bats-core), [bats-support](https://github.com/bats-core/bats-support) and [bats-assert](https://github.com/bats-core/bats-assert) are up to date
- [ ] [Mull](https://github.com/mull-project/mull) is up to date and compatible with the currently installed Clang version
Expand Down

0 comments on commit cccd4d0

Please sign in to comment.