Skip to content

Instantly share code, notes, and snippets.

@mortymacs
Created December 5, 2023 00:30
Show Gist options
  • Save mortymacs/d693744b5eaf67797cdc3c0b58909cc3 to your computer and use it in GitHub Desktop.
Save mortymacs/d693744b5eaf67797cdc3c0b58909cc3 to your computer and use it in GitHub Desktop.
Sample cmake thirdparty + ide for a C++ project
cmake .
make -j8
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)
#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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment