From b23ef3e4ed74c33df068a19d3a40b6174b22ec30 Mon Sep 17 00:00:00 2001 From: Gordon Smith Date: Tue, 19 Mar 2024 04:53:33 +0000 Subject: [PATCH] WIP --- documentation/CMakeLists.txt | 30 ------------------- documentation/Doxyfile | 31 -------------------- documentation/conf.py | 19 ------------ documentation/pages/about.dox | 5 ---- include/greeter/greeter.h | 31 -------------------- source/greeter.cpp | 20 ------------- standalone/CMakeLists.txt | 29 ------------------- standalone/source/main.cpp | 53 ---------------------------------- test/CMakeLists.txt | 2 +- test/{source => }/main.cpp | 0 test/{source => }/wasmtime.cpp | 0 11 files changed, 1 insertion(+), 219 deletions(-) delete mode 100644 documentation/CMakeLists.txt delete mode 100644 documentation/Doxyfile delete mode 100644 documentation/conf.py delete mode 100644 documentation/pages/about.dox delete mode 100644 include/greeter/greeter.h delete mode 100644 source/greeter.cpp delete mode 100644 standalone/CMakeLists.txt delete mode 100644 standalone/source/main.cpp rename test/{source => }/main.cpp (100%) rename test/{source => }/wasmtime.cpp (100%) diff --git a/documentation/CMakeLists.txt b/documentation/CMakeLists.txt deleted file mode 100644 index edc3f62..0000000 --- a/documentation/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ -cmake_minimum_required(VERSION 3.14...3.22) - -project(GreeterDocs) - -# ---- Dependencies ---- - -include(../cmake/CPM.cmake) - -CPMAddPackage("gh:mosra/m.css#a0d292ec311b97fefd21e93cdefb60f88d19ede6") -CPMAddPackage(NAME Greeter SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/..) - -# ---- Doxygen variables ---- - -# set Doxyfile variables -set(DOXYGEN_PROJECT_NAME Greeter) -set(DOXYGEN_PROJECT_VERSION ${Greeter_VERSION}) -set(DOXYGEN_PROJECT_ROOT "${CMAKE_CURRENT_LIST_DIR}/..") -set(DOXYGEN_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/doxygen") - -configure_file(${CMAKE_CURRENT_LIST_DIR}/Doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) - -configure_file(${CMAKE_CURRENT_LIST_DIR}/conf.py ${CMAKE_CURRENT_BINARY_DIR}/conf.py) - -add_custom_target( - GenerateDocs - ${CMAKE_COMMAND} -E make_directory "${DOXYGEN_OUTPUT_DIRECTORY}" - COMMAND "${m.css_SOURCE_DIR}/documentation/doxygen.py" "${CMAKE_CURRENT_BINARY_DIR}/conf.py" - COMMAND echo "Docs written to: ${DOXYGEN_OUTPUT_DIRECTORY}" - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" -) diff --git a/documentation/Doxyfile b/documentation/Doxyfile deleted file mode 100644 index 2c33e00..0000000 --- a/documentation/Doxyfile +++ /dev/null @@ -1,31 +0,0 @@ -# Configuration for Doxygen for use with CMake -# Only options that deviate from the default are included -# To create a new Doxyfile containing all available options, call `doxygen -g` - -# Get Project name and version from CMake -PROJECT_NAME = @DOXYGEN_PROJECT_NAME@ -PROJECT_NUMBER = @DOXYGEN_PROJECT_VERSION@ - -# Add sources -INPUT = @DOXYGEN_PROJECT_ROOT@/README.md @DOXYGEN_PROJECT_ROOT@/include @DOXYGEN_PROJECT_ROOT@/documentation/pages -EXTRACT_ALL = YES -RECURSIVE = YES -OUTPUT_DIRECTORY = @DOXYGEN_OUTPUT_DIRECTORY@ - -# Use the README as a main page -USE_MDFILE_AS_MAINPAGE = @DOXYGEN_PROJECT_ROOT@/README.md - -# set relative include paths -FULL_PATH_NAMES = YES -STRIP_FROM_PATH = @DOXYGEN_PROJECT_ROOT@/include @DOXYGEN_PROJECT_ROOT@ - -# We use m.css to generate the html documentation, so we only need XML output -GENERATE_XML = YES -GENERATE_HTML = NO -GENERATE_LATEX = NO -XML_PROGRAMLISTING = NO -CREATE_SUBDIRS = NO - -# Include all directories, files and namespaces in the documentation -# Disable to include only explicitly documented objects -M_SHOW_UNDOCUMENTED = YES diff --git a/documentation/conf.py b/documentation/conf.py deleted file mode 100644 index 6cc1a04..0000000 --- a/documentation/conf.py +++ /dev/null @@ -1,19 +0,0 @@ -DOXYFILE = 'Doxyfile' - -LINKS_NAVBAR1 = [ - (None, 'pages', [(None, 'about')]), - (None, 'namespaces', []), -] - -# Add your own navbar links using the code below. -# To find the valid link names, you can inspect the URL of a generated documentation site. - -# LINKS_NAVBAR1 = [ -# (None, 'pages', [(None, 'about')]), -# (None, 'namespaces', [(None, 'namespacegreeter')]), -# ] -# -# LINKS_NAVBAR2 = [ -# (None, 'annotated', [(None, 'classgreeter_1_1_greeter')]), -# (None, 'files', [(None, 'greeter_8h')]), -# ] diff --git a/documentation/pages/about.dox b/documentation/pages/about.dox deleted file mode 100644 index 59fc18f..0000000 --- a/documentation/pages/about.dox +++ /dev/null @@ -1,5 +0,0 @@ -/** @page about About - @section doc ModernCppStarter Documentation - This is the auto-generated documentation for the initial project of the ModernCppStarter. - It shows how we can use Doxygen to automatically build a browsable documentation for your projects. -*/ diff --git a/include/greeter/greeter.h b/include/greeter/greeter.h deleted file mode 100644 index 77dfe3b..0000000 --- a/include/greeter/greeter.h +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once - -#include - -namespace greeter { - - /** Language codes to be used with the Greeter class */ - enum class LanguageCode { EN, DE, ES, FR }; - - /** - * @brief A class for saying hello in multiple languages - */ - class Greeter { - std::string name; - - public: - /** - * @brief Creates a new greeter - * @param name the name to greet - */ - Greeter(std::string name); - - /** - * @brief Creates a localized string containing the greeting - * @param lang the language to greet in - * @return a string containing the greeting - */ - std::string greet(LanguageCode lang = LanguageCode::EN) const; - }; - -} // namespace greeter diff --git a/source/greeter.cpp b/source/greeter.cpp deleted file mode 100644 index 11fb416..0000000 --- a/source/greeter.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include - -using namespace greeter; - -Greeter::Greeter(std::string _name) : name(std::move(_name)) {} - -std::string Greeter::greet(LanguageCode lang) const { - switch (lang) { - default: - case LanguageCode::EN: - return fmt::format("Hello, {}!", name); - case LanguageCode::DE: - return fmt::format("Hallo {}!", name); - case LanguageCode::ES: - return fmt::format("¡Hola {}!", name); - case LanguageCode::FR: - return fmt::format("Bonjour {}!", name); - } -} diff --git a/standalone/CMakeLists.txt b/standalone/CMakeLists.txt deleted file mode 100644 index a932149..0000000 --- a/standalone/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -cmake_minimum_required(VERSION 3.14...3.22) - -project(GreeterStandalone LANGUAGES CXX) - -# --- Import tools ---- - -include(../cmake/tools.cmake) - -# ---- Dependencies ---- - -include(../cmake/CPM.cmake) - -CPMAddPackage( - GITHUB_REPOSITORY jarro2783/cxxopts - VERSION 3.0.0 - OPTIONS "CXXOPTS_BUILD_EXAMPLES NO" "CXXOPTS_BUILD_TESTS NO" "CXXOPTS_ENABLE_INSTALL YES" -) - -CPMAddPackage(NAME Greeter SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/..) - -# ---- Create standalone executable ---- - -file(GLOB sources CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp) - -add_executable(${PROJECT_NAME} ${sources}) - -set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17 OUTPUT_NAME "Greeter") - -target_link_libraries(${PROJECT_NAME} Greeter::Greeter cxxopts) diff --git a/standalone/source/main.cpp b/standalone/source/main.cpp deleted file mode 100644 index 938a386..0000000 --- a/standalone/source/main.cpp +++ /dev/null @@ -1,53 +0,0 @@ -#include -#include - -#include -#include -#include -#include - -auto main(int argc, char** argv) -> int { - const std::unordered_map languages{ - {"en", greeter::LanguageCode::EN}, - {"de", greeter::LanguageCode::DE}, - {"es", greeter::LanguageCode::ES}, - {"fr", greeter::LanguageCode::FR}, - }; - - cxxopts::Options options(*argv, "A program to welcome the world!"); - - std::string language; - std::string name; - - // clang-format off - options.add_options() - ("h,help", "Show help") - ("v,version", "Print the current version number") - ("n,name", "Name to greet", cxxopts::value(name)->default_value("World")) - ("l,lang", "Language code to use", cxxopts::value(language)->default_value("en")) - ; - // clang-format on - - auto result = options.parse(argc, argv); - - if (result["help"].as()) { - std::cout << options.help() << std::endl; - return 0; - } - - if (result["version"].as()) { - std::cout << "Greeter, version " << GREETER_VERSION << std::endl; - return 0; - } - - auto langIt = languages.find(language); - if (langIt == languages.end()) { - std::cerr << "unknown language code: " << language << std::endl; - return 1; - } - - greeter::Greeter greeter(name); - std::cout << greeter.greet(langIt->second) << std::endl; - - return 0; -} diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 62b235a..227ca45 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -10,7 +10,7 @@ find_package(doctest CONFIG REQUIRED) # ---- Create binary ---- include_directories(../src) -file(GLOB sources CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp) +file(GLOB sources CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) add_executable(${PROJECT_NAME} ${sources}) target_link_libraries(${PROJECT_NAME} doctest::doctest component-model-cpp) set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 20) diff --git a/test/source/main.cpp b/test/main.cpp similarity index 100% rename from test/source/main.cpp rename to test/main.cpp diff --git a/test/source/wasmtime.cpp b/test/wasmtime.cpp similarity index 100% rename from test/source/wasmtime.cpp rename to test/wasmtime.cpp