diff --git a/.clang-format b/.clang-format index 4df6476..d5c43b5 100755 --- a/.clang-format +++ b/.clang-format @@ -3,4 +3,4 @@ Language: Cpp BasedOnStyle: Google ColumnLimit: 80 IndentWidth: 2 -Standard: Cpp11 \ No newline at end of file +Standard: c++17 \ No newline at end of file diff --git a/.dev/Dockerfile b/.dev/Dockerfile new file mode 100644 index 0000000..db36019 --- /dev/null +++ b/.dev/Dockerfile @@ -0,0 +1,47 @@ +FROM ubuntu:24.04 + +# Define Conan and CMake versions +ARG CONAN_VERSION=2.6.0 +ARG CMAKE_VERSION=3.30.1 + +# Define User ID and Group ID +ARG USER_ID=1000 +ARG GROUP_ID=1000 + +WORKDIR /project + +# Define Labels +LABEL maintainer="Michele Adduci " \ + description="Docker image for C++ development with Conan and CMake" \ + cmake.version="${CMAKE_VERSION}" \ + conan.version="${CONAN_VERSION}" + +# Install basic tooling +RUN apt-get update && \ + apt-get install -y \ + build-essential \ + curl \ + gcc \ + cppcheck \ + clang-format && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# Install Conan and CMake from GitHub Releases +RUN curl -fsSL https://github.com/conan-io/conan/releases/download/${CONAN_VERSION}/conan-${CONAN_VERSION}-amd64.deb -o /tmp/conan.deb && \ + dpkg -i /tmp/conan.deb && \ + curl -fsSL https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz -o /tmp/cmake.tar.gz && \ + mkdir -p /opt/cmake && \ + tar -xzf /tmp/cmake.tar.gz -C /opt/cmake/ --strip-components=1 && \ + chmod +x /opt/cmake/bin/* && \ + ln -sf /opt/cmake/bin/cmake /usr/bin/cmake && \ + ln -sf /opt/cmake/bin/ctest /usr/bin/ctest && \ + ln -sf /opt/cmake/bin/cpack /usr/bin/cpack && \ + ln -sf /opt/cmake/bin/ccmake /usr/bin/ccmake && \ + rm -rf /tmp/* + +# Create non-root user to run container with less privileges +USER ${USER_ID} + +# Run Conan profile detection as non-root user +RUN conan profile detect diff --git a/CMakeLists.txt b/CMakeLists.txt index fe1a2b3..2b6d44f 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,8 +17,8 @@ project(moderncpp-project LANGUAGES CXX DESCRIPTION "moderncpp-project is a star # Set Project version (used for library versioning and for CPack) set(CMAKE_PROJECT_VERSION_MAJOR 1) -set(CMAKE_PROJECT_VERSION_MINOR 0) -set(CMAKE_PROJECT_VERSION_PATCH 0) +set(CMAKE_PROJECT_VERSION_MINOR 1) +set(CMAKE_PROJECT_VERSION_PATCH 2) set(CMAKE_PROJECT_VERSION ${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}.${CMAKE_PROJECT_VERSION_PATCH}) # Set required C++ Standard diff --git a/conanfile.txt b/conanfile.txt index 1a4c972..d6f8a8c 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -1,5 +1,5 @@ [requires] -openssl/3.2.1 +openssl/3.2.2 doctest/2.4.11 [generators] diff --git a/project/hellolib/src/hellolib.cpp b/project/hellolib/src/hellolib.cpp index 2ecc2ea..b93c2b2 100644 --- a/project/hellolib/src/hellolib.cpp +++ b/project/hellolib/src/hellolib.cpp @@ -30,24 +30,25 @@ int32_t hellolib::saySomethingHashed( return 1; } - EVP_MD_CTX *context = EVP_MD_CTX_new(); - if(context == NULL) { + EVP_MD_CTX *context = EVP_MD_CTX_new(); + if (context == NULL) { std::cerr << "Failed to create context\n"; return 2; } - if(1 != EVP_DigestInit_ex(context, EVP_sha256(), NULL)) { + if (1 != EVP_DigestInit_ex(context, EVP_sha256(), NULL)) { std::cerr << "Failed to initialize context\n"; return 3; } - if(1 != EVP_DigestUpdate(context, (unsigned char *)something.c_str(), something.size())) { + if (1 != EVP_DigestUpdate(context, (unsigned char *)something.c_str(), + something.size())) { std::cerr << "Failed to create hash value\n"; return 4; } std::array buffer{}; - if(1 != EVP_DigestFinal_ex(context, buffer.data(), NULL)) { + if (1 != EVP_DigestFinal_ex(context, buffer.data(), NULL)) { std::cerr << "Failed to finalize hash result\n"; return 5; }