-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into chris_async_networking
- Loading branch information
Showing
19 changed files
with
382 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
include_guard() | ||
|
||
# check build type | ||
if( | ||
"${CMAKE_CONFIGURATION_TYPES}" STREQUAL Debug | ||
OR "${CMAKE_BUILD_TYPE}" STREQUAL Debug | ||
OR "${CMAKE_CONFIGURATION_TYPES}" STREQUAL "RelWithDebInfo" | ||
OR "${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo" | ||
) | ||
set(ARCHIMEDES_DEBUG TRUE) | ||
set(ARCHIMEDES_RELEASE FALSE) | ||
|
||
set(ARCHIMEDES_BUILD_TYPE "Debug") | ||
|
||
add_compile_definitions(ARCHIMEDES_DEBUG=1) | ||
add_compile_definitions(ARCHIMEDES_RELEASE=0) | ||
else() | ||
set(ARCHIMEDES_DEBUG FALSE) | ||
set(ARCHIMEDES_RELEASE TRUE) | ||
|
||
set(ARCHIMEDES_BUILD_TYPE "Release") | ||
|
||
add_compile_definitions(ARCHIMEDES_DEBUG=0) | ||
add_compile_definitions(ARCHIMEDES_RELEASE=1) | ||
endif() | ||
|
||
message(STATUS "Build mode: ${ARCHIMEDES_BUILD_TYPE}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
include_guard() | ||
|
||
include("${PROJECT_SOURCE_DIR}/cmake/os.cmake") | ||
|
||
# check if conan is installed | ||
execute_process( | ||
COMMAND "conan" "--version" | ||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} | ||
OUTPUT_VARIABLE CONAN_CHECK_OUT | ||
) | ||
if(NOT CONAN_CHECK_OUT MATCHES ".?Conan.?") | ||
message(FATAL_ERROR "Conan not found") | ||
else() | ||
message(STATUS "Conan present") | ||
endif() | ||
|
||
# check for conan files | ||
if(ARCHIMEDES_FORCE_CONAN_INSTALL OR NOT EXISTS "${PROJECT_SOURCE_DIR}/cmake/conan_files/${ARCHIMEDES_BUILD_TYPE}/conan_toolchain.cmake") | ||
if(ARCHIMEDES_FORCE_CONAN_INSTALL) | ||
message(STATUS "Forced Conan configuration for ${ARCHIMEDES_BUILD_TYPE} mode") | ||
else() | ||
message(STATUS "Conan files not found for ${ARCHIMEDES_BUILD_TYPE} mode, configuring conan for ${ARCHIMEDES_BUILD_TYPE} mode") | ||
endif() | ||
|
||
file(MAKE_DIRECTORY "${PROJECT_SOURCE_DIR}/cmake/conan_files/${ARCHIMEDES_BUILD_TYPE}/") | ||
|
||
# option only for MSCV | ||
if(MSVC) | ||
set(ARCHIMEDES_CONAN_COMPILER_RUNTIME_TYPE "-s:b compiler.runtime_type=${ARCHIMEDES_BUILD_TYPE} -s:h compiler.runtime_type=${ARCHIMEDES_BUILD_TYPE}") | ||
endif() | ||
|
||
# install conan requirements | ||
execute_process( | ||
COMMAND conan install . -s:b build_type=${ARCHIMEDES_BUILD_TYPE} -s:b compiler.cppstd=20 -s:h build_type=${ARCHIMEDES_BUILD_TYPE} -s:h compiler.cppstd=20 ${ARCHIMEDES_CONAN_INSTALL_RUNTIME_TYPE} ${ARCHIMEDES_CONAN_PACKAGE_MANAGER} -of=cmake/conan_files/${ARCHIMEDES_BUILD_TYPE} --build=missing | ||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} | ||
OUTPUT_VARIABLE ARCHIMEDES_CONAN_INSTALL_OUTPUT | ||
RESULT_VARIABLE ARCHIMEDES_CONAN_INSTALL_RESULT | ||
) | ||
|
||
# check conan result | ||
if(NOT ${ARCHIMEDES_CONAN_INSTALL_RESULT} EQUAL 0) | ||
file(REMOVE_RECURSE "${PROJECT_SOURCE_DIR}/cmake/conan_files/${ARCHIMEDES_BUILD_TYPE}/") | ||
message(FATAL_ERROR "Conan installation failed") | ||
else() | ||
message(STATUS "Conan installation succeded") | ||
endif() | ||
else() | ||
message(STATUS "Conan files found for ${ARCHIMEDES_BUILD_TYPE} mode") | ||
endif() | ||
|
||
# manual include conan toolchain | ||
include("${PROJECT_SOURCE_DIR}/cmake/conan_files/${ARCHIMEDES_BUILD_TYPE}/conan_toolchain.cmake") | ||
list(PREPEND CMAKE_PREFIX_PATH ${CMAKE_CURRENT_LIST_DIR}/conan_files/${ARCHIMEDES_BUILD_TYPE}) | ||
|
||
# includes from conan | ||
include_directories(${CMAKE_INCLUDE_PATH}) | ||
|
||
# automatic find_package() | ||
include("${PROJECT_SOURCE_DIR}/cmake/conan_files/${ARCHIMEDES_BUILD_TYPE}/conandeps_legacy.cmake") | ||
list(APPEND ARCHIMEDES_LIBRARIES ${CONANDEPS_LEGACY}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include_guard() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
include_guard() | ||
|
||
include("${PROJECT_SOURCE_DIR}/cmake/conan.cmake") | ||
|
||
add_library(${PROJECT_NAME}) | ||
|
||
include_directories(include) | ||
|
||
# find source files | ||
file(GLOB_RECURSE ARCHIMEDES_SOURCE src/**.cpp) | ||
target_sources(${PROJECT_NAME} PUBLIC ${ARCHIMEDES_SOURCE}) | ||
|
||
# link conan libraries | ||
target_link_libraries(${PROJECT_NAME} PUBLIC ${ARCHIMEDES_LIBRARIES}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
include_guard() | ||
|
||
# msvc specific compile flags | ||
if(MSVC) | ||
add_compile_options("/Zc:__cplusplus") | ||
add_compile_options("/Zc:preprocessor") | ||
add_compile_options("/permissive-") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
include_guard() | ||
|
||
# check for OS | ||
if(WIN32) | ||
set(ARCHIMEDES_WINDOWS TRUE) | ||
set(ARCHIMEDES_LINUX FALSE) | ||
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") | ||
set(ARCHIMEDES_WINDOWS FALSE) | ||
set(ARCHIMEDES_LINUX TRUE) | ||
endif() | ||
|
||
# set user home directory | ||
if(ARCHIMEDES_WINDOWS) | ||
add_compile_definitions(ARCHIMEDES_WINDOWS=1) | ||
add_compile_definitions(ARCHIMEDES_LINUX=0) | ||
|
||
message(STATUS "OS: Windows") | ||
elseif(ARCHIMEDES_LINUX) | ||
add_compile_definitions(ARCHIMEDES_WINDOWS=0) | ||
add_compile_definitions(ARCHIMEDES_LINUX=1) | ||
|
||
message(STATUS "OS: Linux") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
include_guard() | ||
|
||
include("${PROJECT_SOURCE_DIR}/cmake/library.cmake") | ||
|
||
add_executable(${PROJECT_NAME}_bin archimedes_bin/main.cpp) | ||
target_link_libraries(${PROJECT_NAME}_bin PUBLIC ${PROJECT_NAME}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
include_guard() | ||
|
||
include("${PROJECT_SOURCE_DIR}/cmake/library.cmake") | ||
|
||
set(ARCHIMEDES_TEST "${PROJECT_NAME}_tests") | ||
add_executable(${ARCHIMEDES_TEST}) | ||
file(GLOB_RECURSE ARCHIMEDES_TEST_SOURCE tests/**.cpp) | ||
target_sources(${ARCHIMEDES_TEST} PUBLIC ${ARCHIMEDES_TEST_SOURCE}) | ||
target_link_libraries(${ARCHIMEDES_TEST} PUBLIC ${PROJECT_NAME}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#pragma once | ||
#include <spdlog/spdlog.h> | ||
|
||
#include <source_location> | ||
|
||
namespace arch { | ||
|
||
/// @brief Logging level for Logger to indicate how important the message is. | ||
/// | ||
enum class LogLevel | ||
{ | ||
none = -1, | ||
/// @brief Detailed trace information (). | ||
trace, | ||
/// @brief Debugging information. | ||
debug, | ||
/// @brief General information. | ||
info, | ||
/// @brief Information representing a minor problem that has occurred. | ||
warn, | ||
/// @brief Information representing a serious problem that has occurred. | ||
error, | ||
/// @brief Information representing a critical problem that has occurred.s | ||
critical, | ||
}; | ||
|
||
/// @brief Implementation details. | ||
namespace _details { | ||
|
||
template <typename... Args> | ||
struct UniversalLogger; | ||
|
||
template <LogLevel Level, typename... Args> | ||
struct LeveledLogger; | ||
|
||
} | ||
|
||
/// @brief Main static Logger class for logging messages. | ||
/// | ||
class Logger { | ||
template <typename... Args> | ||
friend struct _details::UniversalLogger; | ||
|
||
template <LogLevel Level, typename... Args> | ||
friend struct _details::LeveledLogger; | ||
public: | ||
|
||
/// @brief Initializes the logger. | ||
/// @param logLevel minimum level of log messages to be logged. (All messages with lower level will be ignored) | ||
/// @param name name of the logger. Used for identifying the logger. | ||
static void init(LogLevel logLevel, const std::string& name = "Logger"); | ||
|
||
/// @brief Universal logger for logging messages using runtime @enum LogLevel. | ||
template <typename... Args> | ||
using log = _details::UniversalLogger<Args...>; | ||
|
||
/// @brief Fast way of logging messages at @enum LogLevel::trace. | ||
template <typename... Args> | ||
using trace = _details::LeveledLogger<LogLevel::trace, Args...>; | ||
|
||
/// @brief Fast way of logging messages at @enum LogLevel::debug. | ||
template <typename... Args> | ||
using debug = _details::LeveledLogger<LogLevel::debug, Args...>; | ||
|
||
/// @brief Fast way of logging messages at @enum LogLevel::info. | ||
template<typename... Args> | ||
using info = _details::LeveledLogger<LogLevel::info, Args...>; | ||
|
||
/// @brief Fast way of logging messages at \enum LogLevel::warn. | ||
template<typename... Args> | ||
using warn = _details::LeveledLogger<LogLevel::warn, Args...>; | ||
|
||
/// @brief Fast way of logging messages at \enum LogLevel::error. | ||
template<typename... Args> | ||
using error = _details::LeveledLogger<LogLevel::error, Args...>; | ||
|
||
/// @brief Fast way of logging messages at \enum LogLevel::critical. | ||
template<typename... Args> | ||
using critical = _details::LeveledLogger<LogLevel::critical, Args...>; | ||
|
||
private: | ||
|
||
template <typename... Args> | ||
static void _log_impl(LogLevel level, std::source_location loc, spdlog::format_string_t<Args...> fmt, Args&&... args); | ||
|
||
static std::shared_ptr<spdlog::logger> s_logger; | ||
}; | ||
|
||
} | ||
|
||
#include "Logger.hpp" |
Oops, something went wrong.