Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add conan package manager to amp-devcontainer-cpp #607

Merged
merged 8 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .devcontainer/cpp/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ubuntu:24.04@sha256:99c35190e22d294cdace2783ac55effc69d32896daaa265f0bbedbcde4fbe3e5

ARG BATS_VERSION=1.11.0
ARG BATS_VERSION=1.11.
ARG CCACHE_VERSION=4.10.1
ARG CLANG_VERSION=17
ARG CPM_VERSION=0.40.2
Expand Down Expand Up @@ -37,8 +37,12 @@
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
# Set up package managers CPM and Conan
# - Install CPM.cmake to the CMake module path
# - Configure a default profile for Conan and set the CMake generator to Ninja
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 \
Fixed Show fixed Hide fixed
&& conan profile detect \
&& echo -e "\n[conf]\ntools.cmake.cmaketoolchain:generator=Ninja" >> $(conan profile path default)

# Install clang toolchain
COPY .devcontainer/cpp/apt-requirements-clang.json /tmp/apt-requirements-clang.json
Expand Down
1 change: 1 addition & 0 deletions .devcontainer/cpp/requirements.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
cmake==3.30.5
conan==2.8.1
gcovr==8.2
220 changes: 212 additions & 8 deletions .devcontainer/cpp/requirements.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .devcontainer/cpp/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.24)
cmake_minimum_required(VERSION 3.30)
project(devcontainer-test LANGUAGES ASM C CXX)

include(CTest)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Seperate project as Conan is in the drivers seat

cmake_minimum_required(VERSION 3.30)
project(conan-test LANGUAGES CXX)

find_package(fmt REQUIRED)
add_executable(test-conan main.cpp)
target_link_libraries(test-conan PRIVATE fmt::fmt)
9 changes: 9 additions & 0 deletions .devcontainer/cpp/test/package-managers/conan/conanfile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[requires]
fmt/11.0.2

[generators]
CMakeDeps
CMakeToolchain

[layout]
cmake_layout
7 changes: 7 additions & 0 deletions .devcontainer/cpp/test/package-managers/conan/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;
}
13 changes: 12 additions & 1 deletion .devcontainer/cpp/test/testsuite.bats
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ setup() {
}

teardown() {
rm -rf build crash-*
rm -rf build crash-* /root/.conan2/p
}

@test "valid code input should result in working executable using host compiler" {
Expand Down Expand Up @@ -170,6 +170,17 @@ teardown() {
build_and_run_with_sanitizers clang
}

@test "using Conan as package manager should resolve external dependencies" {
pushd package-managers/conan

conan install . --output-folder=../../build --build=missing

cmake -G Ninja --preset conan-release
cmake --build --preset conan-release

popd
}

@test "using CPM as package manager should resolve external dependencies" {
cmake --preset cpm
cmake --build --preset cpm
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ test-results/
*.profdata
*.profraw
**/playwright/.auth/user.json
CMakeUserPresets.json
Loading