feat: setup initial C++ projects and directory structure

This commit is contained in:
light7734 2024-07-09 15:49:01 +03:30
parent 19a9749d9a
commit c713c9fedd
No known key found for this signature in database
11 changed files with 168 additions and 0 deletions

20
CMakeLists.txt Normal file
View File

@ -0,0 +1,20 @@
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
project("light" LANGUAGES CXX)
include(tools/cmake/preliminary.cmake)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_option(ENABLE_SANITIZERS "Enables fsan sanitizers")
add_option(ENABLE_STATIC_ANALYSIS "Enables clang-tidy static analysis")
find_package(benchmark REQUIRED)
find_package(GTest REQUIRED)
if(ENABLE_STATIC_ANALYSIS)
find_program(CLANG_TIDY_EXE NAMES "clang-tidy" REQUIRED)
endif()
add_subdirectory(docs)
add_subdirectory(modules)

36
conanfile.py Normal file
View File

@ -0,0 +1,36 @@
from conan import ConanFile
from conan.tools.cmake import CMakeToolchain
class LightRecipe(ConanFile):
name = "light"
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeDeps"
requires = [
"benchmark/1.8.4",
"gtest/1.14.0",
]
tool_requires = [
"cmake/3.30.0"
]
options = {
"enable_static_analysis": [True, False],
"enable_sanitizers": [True, False],
}
default_options = {
"enable_static_analysis": True,
"enable_sanitizers": False,
}
def generate(self):
tc = CMakeToolchain(self)
tc.cache_variables["CMAKE_EXPORT_COMPILE_COMMANDS"] = True
tc.cache_variables["ENABLE_SANITIZERS"] = self.options.enable_sanitizers
tc.cache_variables["ENABLE_STATIC_ANALYSIS"] = self.options.enable_static_analysis
tc.generate()

1
docs/CMakeLists.txt Normal file
View File

@ -0,0 +1 @@
message("TODO: implement doc generation")

2
modules/CMakeLists.txt Normal file
View File

@ -0,0 +1,2 @@
add_subdirectory(utilities/preliminary)
add_subdirectory(light)

0
modules/light/.gitkeep Normal file
View File

View File

@ -0,0 +1,3 @@
add_executable(light ${CMAKE_CURRENT_SOURCE_DIR}/src/entrypoint.cpp)
target_link_libraries(light PRIVATE preliminary)

View File

@ -0,0 +1,6 @@
auto main() -> lt::i32
{
std::cout << "Light built and ran fine...";
return 0;
}

View File

@ -0,0 +1,3 @@
add_library(preliminary INTERFACE)
target_precompile_headers(preliminary INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/src/pch.hpp)
target_include_directories(preliminary INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include/)

View File

@ -0,0 +1,21 @@
#pragma once
#include <stdint.h>
#include <vector>
namespace lt {
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;
using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
template<typename T>
using vec = std::vector<T>;
} // namespace lt

View File

@ -0,0 +1,66 @@
#pragma once
#include <preliminary/types.hpp>
/* utilities */
#include <any>
#include <chrono>
#include <cinttypes>
#include <csignal>
#include <cstdint>
#include <ctime>
#include <exception>
#include <functional>
#include <limits>
#include <memory>
#include <numbers>
#include <optional>
#include <source_location>
#include <tuple>
#include <type_traits>
#include <utility>
#include <variant>
/* numerics */
#include <bit>
#include <cmath>
#include <random>
#include <ratio>
/* containers */
#include <array>
#include <bitset>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <span>
#include <unordered_map>
#include <unordered_set>
#include <vector>
/* algorithms */
#include <algorithm>
/* input/output */
#include <fstream>
#include <iostream>
#include <sstream>
/* regular expression */
#include <regex>
/* thread support */
#include <atomic>
#include <condition_variable>
#include <execution>
#include <mutex>
#include <thread>
/* string */
#include <cstring>
#include <string>
#include <string_view>
/* filesystem */
#include <filesystem>

View File

@ -0,0 +1,10 @@
macro(add_option option help)
option(${option} ${help})
if(${option})
message(STATUS "${option}: ON")
add_compile_definitions(${option}=1)
else()
message(STATUS "${option}: OFF")
endif()
endmacro()