|
EnigmaMachineCore 0.1.0
A modular Enigma Machine simulation in C++20
|
This document outlines the build system architecture, prerequisites, and instructions for building and testing the EnigmaMachineCore project. For specific details on unit testing, see the Testing Guide.
To build and run this project, you will need the following tools and libraries:
clang and llvm (for llvm-symbolizer).Note: These are included as git submodules in the external/ directory.
ENIGMA_BUILD_PROPERTY_TESTS=ON.Note: You do NOT need to install these libraries on your machine. The build system (CMake) automatically downloads and configures them during the first build (requires internet connection for the initial configuration).
/docs folder.To support robust testing and modularity, the project uses a "Library + Runner" architecture.
ENIGMACORE_EXPORT are visible.BUILD_SHARED_LIBS).app/main.cpp.EnigmaCore to do the actual work.${PROJECT_NAME}gtest_main) and all unit test files.EnigmaCore_OBJ to test the logic directly.The project uses CMake options to control the build process. By default, only the core library and CLI application are built to ensure maximum build speed.
BUILD_SHARED_LIBS**: If ON, builds EnigmaCore as a shared library (.so, .dll). If OFF (default), builds it as a static library.ENIGMA_BUILD_CLI**: Build the main Enigma machine command-line tool. Default is ON.ENIGMA_BUILD_TESTS**: Build the GoogleTest-based unit test suite. Default is OFF.ENIGMA_BUILD_BENCHMARKS**: Build the Google Benchmark-based performance suite. Default is OFF.ENIGMA_BUILD_DOCS**: Build the Doxygen documentation targets. Default is OFF.ENIGMA_BUILD_PROPERTY_TESTS**: Build the RapidCheck-based property-based test suite. Default is OFF.ENIGMA_ENABLE_CLANG_TIDY**: Enable static analysis during the build process. Default is OFF.ENIGMA_ENABLE_COVERAGE**: Enable code coverage instrumentation (gcov/lcov). Default is OFF.ENIGMA_ENABLE_CPPCHECK**: Run cppcheck static analysis. Default is OFF.${PROJECT_NAME}**: The name of the main project (EnigmaMachineCore).${CORE_SOURCES}**: The list of .cpp files compiled into the EnigmaCore library.${INCLUDE_DIRS}**: Directory paths added to EnigmaCore with PUBLIC visibility.The project supports different build types. It is recommended to use separate directories for Debug and Release builds.
To run the GoogleTest suite (works with either build type, provided it was configured):
Note: The application first looks for assets in a local assets/ directory. If it doesn't find them, it automatically falls back to the system's installation path (e.g., /usr/local/share/EnigmaMachineCore/assets/).
To install the project globally on your system:
Once installed, your own C++ projects can easily integrate the library:
To ensure a consistent style, the project uses clang-format (version 21 or higher) based on the Google C++ style guide. Using different versions of clang-format may result in slight formatting discrepancies that could fail CI checks.
This will automatically format all source and header files in the project.
Static analysis is performed using clang-tidy and cppcheck, both of which are integrated into the CMake build system.
ENIGMA_ENABLE_CLANG_TIDY flag during configuration: bash cmake -DENIGMA_ENABLE_CLANG_TIDY=ON -S . -B build make).[modernize-use-auto]). Standard compiler warnings typically start with -W.CMakeLists.txt.ENIGMA_ENABLE_CPPCHECK flag during configuration: bash cmake -DENIGMA_ENABLE_CPPCHECK=ON -S . -B build bash cmake --build build --target enigma_cppcheck enigma_cppcheck is run on every push/PR within the Code Analysis workflow.The project supports LLVM/Clang Sanitizers to detect memory errors, uninitialized reads, and undefined behavior at runtime.
clang / clang++.llvm (specifically llvm-symbolizer) is recommended for descriptive backtraces.| Option | Sanitizer |
|---|---|
ENIGMA_USE_ASAN | AddressSanitizer (ASan) |
ENIGMA_USE_UBSAN | UndefinedBehaviorSanitizer (UBSan) |
ENIGMA_USE_MSAN | MemorySanitizer (MSan) |
bash cmake -DCMAKE_CXX_COMPILER=clang++ -DENIGMA_USE_ASAN=ON -S . -B build bash cmake --build build ./scripts/run_sanitizers.sh build Note: Sanitizers are automatically excluded from the Unit Test suite to maintain performance. They are applied to the core engine and CLI application. In CI, these checks are centralized in the code-analysis.yml workflow.
If you have Doxygen and PlantUML installed, you can generate the project's API documentation and architectural diagrams locally.
This command will:
.puml files in docs/diagrams/ and output SVG images to docs/diagrams/output/.The generated HTML documentation can be found at: docs/doxygen-gen-files/html/index.html
Open this file in any web browser to view the interactive documentation.
The project includes pre-configured settings for Visual Studio Code to streamline development and testing:
Ctrl+Shift+B to trigger the default build (Debug).F5 while the **(gdb) Launch (Debug)** configuration is selected in the Run sidebar.Terminal > Run Task... for specific commands like Build (Release) or CMake: Configure.Terminal > Run Task... and select Run Tests. This executes ctest and displays output in the terminal.F5. This allows you to set breakpoints in your test files.This project is designed to be easily embedded as a submodule in other CMake projects.
add_subdirectory(), the build system automatically detects it is not the top-level project and disables the CLI executable, tests, and documentation targets to keep your build clean.Configuration Options: You can override this behavior by setting these variables before adding the subdirectory:
cmake set(ENIGMA_BUILD_CLI ON) # Build the CLI executable set(ENIGMA_BUILD_TESTS ON) # Build the test suite set(ENIGMA_BUILD_DOCS ON) # Build documentation targets add_subdirectory(external/EnigmaMachineCore)
EnigmaCore library and include the public header: cmake target_link_libraries(MyTarget PRIVATE EnigmaMachineCore::EnigmaCore) cpp #include <EnigmaMachineCore/EnigmaCore.hpp>