From 51de990690d2882db3460aa6d729849c5a85dac7 Mon Sep 17 00:00:00 2001 From: lejulien Date: Tue, 19 May 2026 19:11:53 +0200 Subject: [PATCH] Switch to cmake and fetch nlohmann::json This will be used to dynamically set a label table --- .gitignore | 1 + CMakeLists.txt | 26 ++++++++++++++++++++++++++ README.md | 9 ++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 CMakeLists.txt diff --git a/.gitignore b/.gitignore index b2a14e1..7480a1a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ out hack-assembler +build diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..141fe58 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.18) +set(NAME "hack-assembly") +project(${NAME} CXX) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +include(FetchContent) + +# nlohmann::json +FetchContent_Declare( + json + GIT_REPOSITORY https://github.com/nlohmann/json.git + GIT_TAG v3.11.3 +) +FetchContent_MakeAvailable(json) + + +set(SRC_CXX_FILES "./main.cpp") + +add_executable(${NAME} ${SRC_CXX_FILES}) + +target_link_libraries(${NAME} PUBLIC nlohmann_json::nlohmann_json) + diff --git a/README.md b/README.md index cfc48e3..1706ddc 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,18 @@ An implementation of a hack assembler in C++. +## Compilation + +```bash +cmake -S . -B build +cmake --build build +``` + ## Usage ```bash g++ -o hack-assembler main.cpp -cat | ./hack-assembler > +cat | ./hack-assembler > ./out/ ``` ## License