From 7864784d6536551970af4376b535b3b0f5afc36a Mon Sep 17 00:00:00 2001 From: Ravin Perera <33562092+ravinsp@users.noreply.github.com> Date: Tue, 8 Oct 2019 19:00:37 +0530 Subject: [PATCH] Added cmake for builds. --- .gitignore | 6 +++++- CMakeLists.txt | 21 +++++++++++++++++++++ README.md | 15 ++++++++++----- makefile | 4 ---- 4 files changed, 36 insertions(+), 10 deletions(-) create mode 100644 CMakeLists.txt delete mode 100644 makefile diff --git a/.gitignore b/.gitignore index 52c11c2e..15930d4c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,8 @@ .*.sw? .DS_Store build/** -.vscode/** \ No newline at end of file +.vscode/** +Makefile +CMakeCache.txt +cmake_install.cmake +CMakeFiles/** \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..3903752c --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.2) + +add_definitions("-std=c++17") + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY build) + +add_executable(hpcore + src/main.cpp + src/conf.cpp + src/crypto.cpp + src/proc.cpp + src/shared.cpp + src/usr/usr.cpp + src/shared.cpp +) + +target_link_libraries(hpcore + libsodium.a + libboost_system.a + libboost_filesystem.a +) \ No newline at end of file diff --git a/README.md b/README.md index ebf6f84d..63dd6f88 100644 --- a/README.md +++ b/README.md @@ -40,13 +40,18 @@ Following Instructions are based on Boost [getting started](https://www.boost.or This will update your library cache and avoid potential issues when running your compiled C++ program which links to newly installed libraries. +#### Install CMAKE +If you use apt, run `sudo apt install cmake` +Or follow [this](https://cmake.org/install/) + #### Build and run Hot Pocket 1. navigate to hotpocket repo root. -2. Run `make` -3. Run `./build/hpcore new ~/mycontract`. This will initialize a new contract directory `mycontract` in your home directory. -4. Take a look at `~/mycontract/cfg/hp.cfg`. This is your new contract config file. You can modify it according to your contract hosting requirements. -5. Optional: Run `./build/hpcore rekey ~/mycontract` to generate new public/private key pair. -6. Run `./build/hpcore run ~/mycontract` to run your smart contract (to do). +1. Run `cmake .` (You only have to do this once) +1. Run `make` +1. Run `./build/hpcore new ~/mycontract`. This will initialize a new contract directory `mycontract` in your home directory. +1. Take a look at `~/mycontract/cfg/hp.cfg`. This is your new contract config file. You can modify it according to your contract hosting requirements. +1. Optional: Run `./build/hpcore rekey ~/mycontract` to generate new public/private key pair. +1. Run `./build/hpcore run ~/mycontract` to run your smart contract (to do). ## Code structure Code is divided into subsystems via namespaces. Some subsystems mentioned here are yet to be introduced. diff --git a/makefile b/makefile deleted file mode 100644 index 844d6224..00000000 --- a/makefile +++ /dev/null @@ -1,4 +0,0 @@ -all: - mkdir -p build - g++ src/*.cpp src/usr/*.cpp -lsodium -lboost_system -lboost_filesystem -std=c++17 -o build/hpcore - echo 'build successful, binary in '`pwd`'/build/hpcore'