Skip to content

Commit

Permalink
cmakelist.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
josefkedwards authored Feb 2, 2025
1 parent 2037450 commit 855d3ee
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 289 deletions.
344 changes: 57 additions & 287 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,286 +1,59 @@
# Use the base image for C++ development
FROM mcr.microsoft.com/devcontainers/cpp:1-debian-12

# Set the CMake version to reinstall if needed
#########################################################
# Stage 1: Debian-Based C++ Development Environment
#########################################################
FROM mcr.microsoft.com/devcontainers/cpp:1-debian-12 AS debian
ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="none"

# Copy the script to reinstall CMake from source
# Copy and (conditionally) run the CMake reinstall script
COPY ./reinstall-cmake.sh /tmp/

# Run the script to reinstall CMake if specified
RUN if [ "${REINSTALL_CMAKE_VERSION_FROM_SOURCE}" != "none" ]; then \
chmod +x /tmp/reinstall-cmake.sh && /tmp/reinstall-cmake.sh ${REINSTALL_CMAKE_VERSION_FROM_SOURCE}; \
fi \
&& rm -f /tmp/reinstall-cmake.sh

# [Optional] Install additional vcpkg ports
# RUN su vscode -c "${VCPKG_ROOT}/vcpkg install <your-port-name-here>"
fi && rm -f /tmp/reinstall-cmake.sh

# [Optional] Install additional packages
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>
# Set environment variables
ENV VCPKG_INSTALLATION_ROOT=/usr/local/vcpkg
ENV JAVA_HOME_17_X64=/usr/lib/jvm/java-17-openjdk-amd64

# Set environment variables for your project
ENV VCPKG_INSTALLATION_ROOT /usr/local/vcpkg
ENV JAVA_HOME_17_X64 /usr/lib/jvm/java-17-openjdk-amd64
# Add more environment variables as needed

# Install necessary software
# Note: Since this is a Debian-based image, we'll use apt for package management
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends \
# Install required packages
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive && \
apt-get install -y --no-install-recommends \
python3-pip \
nodejs \
npm \
openjdk-17-jdk \
git \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
git && \
apt-get clean && rm -rf /var/lib/apt/lists/*

# Python setup
RUN python3 -m pip install --upgrade pip
# Set up Python and Node.js
RUN python3 -m pip install --upgrade pip && npm install -g yarn

# Node.js setup
RUN npm install -g yarn
# Install vcpkg from source
RUN git clone https://github.com/microsoft/vcpkg.git ${VCPKG_INSTALLATION_ROOT} && \
cd ${VCPKG_INSTALLATION_ROOT} && \
./bootstrap-vcpkg.sh

# Install vcpkg if not already present (assuming it's not in the base image)
RUN git clone https://github.com/microsoft/vcpkg.git $VCPKG_INSTALLATION_ROOT \
&& cd $VCPKG_INSTALLATION_ROOT \
&& ./bootstrap-vcpkg.sh

# Copy project files into the container
# Copy project files and set working directory
COPY . /workspace

# Set the working directory in the container
WORKDIR /workspace

# Default command when container starts
# Default command for the Debian-based container
CMD ["bash"]
# Use base images for C++ development
FROM mcr.microsoft.com/devcontainers/cpp:1-ubuntu-24.04 AS ubuntu-base
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2022 AS windows-base

# Ubuntu Environment Setup
FROM ubuntu-base AS ubuntu-setup
#########################################################
# Stage 2: Ubuntu-Based C++ Development Environment
#########################################################
FROM mcr.microsoft.com/devcontainers/cpp:1-ubuntu-24.04 AS ubuntu
ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="none"
COPY ./reinstall-cmake.sh /tmp/
RUN if [ "${REINSTALL_CMAKE_VERSION_FROM_SOURCE}" != "none" ]; then \
chmod +x /tmp/reinstall-cmake.sh && /tmp/reinstall-cmake.sh ${REINSTALL_CMAKE_VERSION_FROM_SOURCE}; \
fi \
&& rm -f /tmp/reinstall-cmake.sh \
&& apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends \
python3-pip \
nodejs \
npm \
openjdk-17-jdk \
gdb \
valgrind \
lsof \
git \
clang-18 \
libstdc++-12-dev \
glibc-source \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

# Python setup
RUN python3 -m pip install --upgrade pip

# Node.js setup
RUN npm install -g yarn

# Install vcpkg if not already present
ENV VCPKG_INSTALLATION_ROOT=/vcpkg
RUN git clone https://github.com/microsoft/vcpkg.git $VCPKG_INSTALLATION_ROOT \
&& cd $VCPKG_INSTALLATION_ROOT \
&& ./bootstrap-vcpkg.sh

# Copy project files into the container
COPY . /workspace
WORKDIR /workspace
CMD ["bash"]

# Windows Environment Setup
FROM windows-base AS windows-setup
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')); \
choco install -y \
msys2 \
cmake \
clang \
python \
nodejs \
git \
jdk17 \
visualstudio2022buildtools --package-parameters "--add Microsoft.VisualStudio.Workload.VCTools --includeRecommended"

# Setup environment variables
ENV PATH="${PATH};C:\msys64\usr\bin;C:\Program Files\Git\cmd"

# Install vcpkg for Windows
RUN git clone https://github.com/microsoft/vcpkg.git C:\vcpkg \
&& cd C:\vcpkg \
&& .\bootstrap-vcpkg.bat

# Copy project files into the container
COPY . C:\workspace
WORKDIR C:\workspace
CMD ["powershell"]
cmake_minimum_required(VERSION 3.10)

# -----------------------------------------------------------------------------
# Project name and version
# -----------------------------------------------------------------------------
project(PMLL_Blockchain VERSION 1.0)

# -----------------------------------------------------------------------------
# C++ standard requirements
# -----------------------------------------------------------------------------
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# -----------------------------------------------------------------------------
# Options (optional)
# -----------------------------------------------------------------------------
option(PMLL_BUILD_TESTS "Build tests" ON) # Toggle test builds
option(PMLL_BUILD_EXAMPLES "Build examples" OFF) # Toggle example builds

# -----------------------------------------------------------------------------
# Source files
# -----------------------------------------------------------------------------
set(SRC_FILES
src/main.cpp
src/blockchain.cpp
src/transaction.cpp
# Add more source files as needed...
)

# -----------------------------------------------------------------------------
# Include directories
# -----------------------------------------------------------------------------
# If you keep all headers in an `include/` folder, for example:
# include_directories(${CMAKE_SOURCE_DIR}/include)

# -----------------------------------------------------------------------------
# Create the executable
# -----------------------------------------------------------------------------
add_executable(pmll_blockchain ${SRC_FILES})

# -----------------------------------------------------------------------------
# Link libraries (if needed)
# -----------------------------------------------------------------------------
# For example, if you use OpenSSL for cryptography:
# find_package(OpenSSL REQUIRED)
# if(OPENSSL_FOUND)
# target_include_directories(pmll_blockchain PRIVATE ${OPENSSL_INCLUDE_DIR})
# target_link_libraries(pmll_blockchain PRIVATE OpenSSL::SSL OpenSSL::Crypto)
# endif()

# -----------------------------------------------------------------------------
# Add compiler warnings (optional)
# -----------------------------------------------------------------------------
if(MSVC)
target_compile_options(pmll_blockchain PRIVATE /W4 /permissive-)
else()
target_compile_options(pmll_blockchain PRIVATE -Wall -Wextra -pedantic)
endif()

# -----------------------------------------------------------------------------
# Tests (optional)
# -----------------------------------------------------------------------------
if(PMLL_BUILD_TESTS)
enable_testing()
# If using Google Test, for instance:
# add_subdirectory(tests)
endif()

# -----------------------------------------------------------------------------
# Install targets (optional)
# -----------------------------------------------------------------------------
# install(TARGETS pmll_blockchain
# RUNTIME DESTINATION bin
# )

# -----------------------------------------------------------------------------
# Summary
# -----------------------------------------------------------------------------
message(STATUS "--------------------------------------------------")
message(STATUS "Project: ${PROJECT_NAME} v${PROJECT_VERSION}")
message(STATUS "C++ Standard: C++${CMAKE_CXX_STANDARD}")
message(STATUS "Build Tests: ${PMLL_BUILD_TESTS}")
message(STATUS "Build Examples: ${PMLL_BUILD_EXAMPLES}")
message(STATUS "--------------------------------------------------")

# Use the base image for C++ development
FROM mcr.microsoft.com/devcontainers/cpp:1-debian-12

# Set the CMake version to reinstall if needed
ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="none"

# Copy the script to reinstall CMake from source
# Copy and (conditionally) run the CMake reinstall script
COPY ./reinstall-cmake.sh /tmp/

# Run the script to reinstall CMake if specified
RUN if [ "${REINSTALL_CMAKE_VERSION_FROM_SOURCE}" != "none" ]; then \
chmod +x /tmp/reinstall-cmake.sh && /tmp/reinstall-cmake.sh ${REINSTALL_CMAKE_VERSION_FROM_SOURCE}; \
fi \
&& rm -f /tmp/reinstall-cmake.sh

# [Optional] Install additional vcpkg ports
# RUN su vscode -c "${VCPKG_ROOT}/vcpkg install <your-port-name-here>"

# [Optional] Install additional packages
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>
fi && rm -f /tmp/reinstall-cmake.sh

# Set environment variables for your project
ENV VCPKG_INSTALLATION_ROOT /usr/local/vcpkg
ENV JAVA_HOME_17_X64 /usr/lib/jvm/java-17-openjdk-amd64
# Add more environment variables as needed

# Install necessary software
# Note: Since this is a Debian-based image, we'll use apt for package management
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends \
python3-pip \
nodejs \
npm \
openjdk-17-jdk \
git \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

# Python setup
RUN python3 -m pip install --upgrade pip

# Node.js setup
RUN npm install -g yarn

# Install vcpkg if not already present (assuming it's not in the base image)
RUN git clone https://github.com/microsoft/vcpkg.git $VCPKG_INSTALLATION_ROOT \
&& cd $VCPKG_INSTALLATION_ROOT \
&& ./bootstrap-vcpkg.sh

# Copy project files into the container
COPY . /workspace

# Set the working directory in the container
WORKDIR /workspace

# Default command when container starts
CMD ["bash"]
# Use base images for C++ development
FROM mcr.microsoft.com/devcontainers/cpp:1-ubuntu-24.04 AS ubuntu-base
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2022 AS windows-base

# Ubuntu Environment Setup
FROM ubuntu-base AS ubuntu-setup
ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="none"
COPY ./reinstall-cmake.sh /tmp/
RUN if [ "${REINSTALL_CMAKE_VERSION_FROM_SOURCE}" != "none" ]; then \
chmod +x /tmp/reinstall-cmake.sh && /tmp/reinstall-cmake.sh ${REINSTALL_CMAKE_VERSION_FROM_SOURCE}; \
fi \
&& rm -f /tmp/reinstall-cmake.sh \
&& apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends \
# Install additional packages for Ubuntu
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive && \
apt-get install -y --no-install-recommends \
python3-pip \
nodejs \
npm \
Expand All @@ -291,49 +64,46 @@ RUN if [ "${REINSTALL_CMAKE_VERSION_FROM_SOURCE}" != "none" ]; then \
git \
clang-18 \
libstdc++-12-dev \
glibc-source \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
glibc-source && \
apt-get clean && rm -rf /var/lib/apt/lists/*

# Python setup
RUN python3 -m pip install --upgrade pip
# Set up Python and Node.js
RUN python3 -m pip install --upgrade pip && npm install -g yarn

# Node.js setup
RUN npm install -g yarn

# Install vcpkg if not already present
# Install vcpkg for Ubuntu
ENV VCPKG_INSTALLATION_ROOT=/vcpkg
RUN git clone https://github.com/microsoft/vcpkg.git $VCPKG_INSTALLATION_ROOT \
&& cd $VCPKG_INSTALLATION_ROOT \
&& ./bootstrap-vcpkg.sh
RUN git clone https://github.com/microsoft/vcpkg.git ${VCPKG_INSTALLATION_ROOT} && \
cd ${VCPKG_INSTALLATION_ROOT} && \
./bootstrap-vcpkg.sh

# Copy project files into the container
# Copy project files and set working directory
COPY . /workspace
WORKDIR /workspace

# Default command for the Ubuntu-based container
CMD ["bash"]

# Windows Environment Setup
FROM windows-base AS windows-setup
#########################################################
# Stage 3: Windows-Based C++ Development Environment
#########################################################
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2022 AS windows
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

# Install Chocolatey and required Windows packages
RUN iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')); \
choco install -y \
msys2 \
cmake \
clang \
python \
nodejs \
git \
jdk17 \
visualstudio2022buildtools --package-parameters "--add Microsoft.VisualStudio.Workload.VCTools --includeRecommended"
choco install -y msys2 cmake clang python nodejs git jdk17 visualstudio2022buildtools --package-parameters "--add Microsoft.VisualStudio.Workload.VCTools --includeRecommended"

# Setup environment variables
# Update PATH for tools installed by Chocolatey
ENV PATH="${PATH};C:\msys64\usr\bin;C:\Program Files\Git\cmd"

# Install vcpkg for Windows
RUN git clone https://github.com/microsoft/vcpkg.git C:\vcpkg \
&& cd C:\vcpkg \
&& .\bootstrap-vcpkg.bat
# Install vcpkg on Windows
RUN git clone https://github.com/microsoft/vcpkg.git C:\vcpkg; \
cd C:\vcpkg; \
.\bootstrap-vcpkg.bat

# Copy project files into the container
# Copy project files and set working directory
COPY . C:\workspace
WORKDIR C:\workspace

# Default command for the Windows-based container
CMD ["powershell"]
Loading

0 comments on commit 855d3ee

Please sign in to comment.