Skip to content

Instantly share code, notes, and snippets.

@mortymacs
Last active November 30, 2024 20:08

Revisions

  1. mortymacs revised this gist Nov 30, 2024. 1 changed file with 14 additions and 0 deletions.
    14 changes: 14 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    if(NOT EXISTS "${VENDOR_DIR}/argparse")
    file(
    DOWNLOAD "https://github.com/p-ranav/argparse/archive/refs/tags/v3.0.tar.gz"
    "${VENDOR_DIR}/argparser.tgz"
    TIMEOUT 5
    TLS_VERIFY ON)
    execute_process(
    COMMAND "${CMAKE_COMMAND}" -E tar xzf "${VENDOR_DIR}/argparser.tgz"
    WORKING_DIRECTORY "${VENDOR_DIR}")
    execute_process(COMMAND "${CMAKE_COMMAND}" -E rename
    "${VENDOR_DIR}/argparse-3.0" "${VENDOR_DIR}/argparse")
    execute_process(COMMAND "${CMAKE_COMMAND}" -E remove
    "${VENDOR_DIR}/argparser.tgz")
    endif()
  2. mortymacs created this gist Dec 5, 2023.
    20 changes: 20 additions & 0 deletions CMakeLists.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    cmake_minimum_required(VERSION 3.25.0)
    project(HelloWorld)

    # Enable for IDE
    set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

    # Download thirdparty
    include(FetchContent)
    FetchContent_Declare(
    tomlplusplus
    GIT_REPOSITORY https://github.com/marzer/tomlplusplus.git
    GIT_TAG v3.4.0
    )
    FetchContent_MakeAvailable(tomlplusplus)

    # Include thirdparty headers
    include_directories(${tomlplusplus_SOURCE_DIR})

    # Compile
    add_executable(HelloWorld main.cc)
    2 changes: 2 additions & 0 deletions build.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    cmake .
    make -j8
    17 changes: 17 additions & 0 deletions sample.cc
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    #include <iostream>
    #include <toml.hpp>

    int main() {
    std::cout << "Hello World!" << std::endl;

    toml::table tbl;
    try {
    tbl = toml::parse_file("a.toml");
    std::cout << tbl << std::endl;
    } catch (const toml::parse_error &err) {
    std::cout << err << std::endl;
    return 1;
    }

    return 0;
    }