diff --git a/CMake/FindDeps.cmake b/CMake/FindDeps.cmake index 4d622e4..88ebb01 100644 --- a/CMake/FindDeps.cmake +++ b/CMake/FindDeps.cmake @@ -112,6 +112,8 @@ set(MI_OVERRIDE ON CACHE BOOL "" FORCE) set(MI_BUILD_STATIC ON CACHE BOOL "" FORCE) set(MI_BUILD_TESTS OFF CACHE BOOL "" FORCE) set(MI_BUILD_SHARED OFF CACHE BOOL "" FORCE) +set(MI_DEBUG OFF CACHE BOOL "" FORCE) +set(MI_SHOW_ERRORS OFF CACHE BOOL "" FORCE) set(EXPECTED_BUILD_TESTS OFF CACHE BOOL "" FORCE) diff --git a/CMake/PatchMimalloc.cmake b/CMake/PatchMimalloc.cmake index 4e3cac4..e877dbe 100644 --- a/CMake/PatchMimalloc.cmake +++ b/CMake/PatchMimalloc.cmake @@ -22,4 +22,15 @@ if(ALREADY_PATCHED EQUAL -1) file(WRITE "${TARGET_FILE}" "${FILE_CONTENT}") else() message(STATUS "mimalloc source is already patched. Skipping.") -endif() \ No newline at end of file +endif() + +# Patch mimalloc complaing about false positive alignment issues in libc loader +file(READ "${SOURCE_DIR}/CMakeLists.txt" MI_CMAKE_CONTENT) +string(REPLACE + "set(mi_debug_default ON)" + "set(mi_debug_default OFF)" + MI_CMAKE_CONTENT + "${MI_CMAKE_CONTENT}" +) +file(WRITE "${SOURCE_DIR}/CMakeLists.txt" "${MI_CMAKE_CONTENT}") +message(STATUS "Patched mimalloc: Forced MI_DEBUG default to OFF to silence alignment warnings.") \ No newline at end of file diff --git a/README.md b/README.md index 0e7a121..d7c59c6 100644 --- a/README.md +++ b/README.md @@ -116,10 +116,21 @@ IACore is built with CMake. You can include it in your project via `FetchContent ### CMake Example ```cmake -add_subdirectory(IACore) +cmake_minimum_required(VERSION 3.28) +project(MyGame) -add_executable(MyApp Main.cpp) -target_link_libraries(MyApp PRIVATE IACore) +# Or you can use FetchContent +add_subdirectory(external/IACore) + +# Apply IACore's standard project configuration +# This applies C++20 and strict warning flags globally to your targets. +iacore_setup_project() + +# Define your targets +add_executable(MyGame src/main.cpp) + +# Link IACore +target_link_libraries(MyGame PRIVATE IACore) ``` ## 🤝 Contributing diff --git a/Src/IACore/imp/cpp/IACore.cpp b/Src/IACore/imp/cpp/IACore.cpp index 402e44b..145203b 100644 --- a/Src/IACore/imp/cpp/IACore.cpp +++ b/Src/IACore/imp/cpp/IACore.cpp @@ -16,6 +16,8 @@ #include #include +#include + namespace IACore { HighResTimePoint g_startTime{}; @@ -30,6 +32,8 @@ namespace IACore g_mainThreadID = std::this_thread::get_id(); g_startTime = HighResClock::now(); Logger::Initialize(); + + mi_option_set(mi_option_verbose, 0); } VOID Terminate() diff --git a/Src/IACore/inc/IACore/Logger.hpp b/Src/IACore/inc/IACore/Logger.hpp index ff5e8c0..7b2d320 100644 --- a/Src/IACore/inc/IACore/Logger.hpp +++ b/Src/IACore/inc/IACore/Logger.hpp @@ -17,6 +17,15 @@ #include +#define IA_LOG_SET_FILE(path) IACore::Logger::EnableLoggingToDisk(path) +#define IA_LOG_SET_LEVEL(level) IACore::Logger::SetLogLevel(IACore::Logger::ELogLevel::level) + +#define IA_LOG_TRACE(...) IACore::Logger::Trace(__VA_ARGS__) +#define IA_LOG_DEBUG(...) IACore::Logger::Debug(__VA_ARGS__) +#define IA_LOG_INFO(...) IACore::Logger::Info(__VA_ARGS__) +#define IA_LOG_WARN(...) IACore::Logger::Warn(__VA_ARGS__) +#define IA_LOG_ERROR(...) IACore::Logger::Error(__VA_ARGS__) + namespace IACore { class Logger @@ -24,7 +33,8 @@ namespace IACore public: enum class ELogLevel { - VERBOSE, + TRACE, + DEBUG, INFO, WARN, ERROR @@ -34,9 +44,14 @@ namespace IACore STATIC BOOL EnableLoggingToDisk(IN PCCHAR filePath); STATIC VOID SetLogLevel(IN ELogLevel logLevel); - template STATIC VOID Status(FormatterString fmt, Args &&...args) + template STATIC VOID Trace(FormatterString fmt, Args &&...args) { - LogStatus(std::vformat(fmt.get(), std::make_format_args(args...))); + LogTrace(std::vformat(fmt.get(), std::make_format_args(args...))); + } + + template STATIC VOID Debug(FormatterString fmt, Args &&...args) + { + LogDebug(std::vformat(fmt.get(), std::make_format_args(args...))); } template STATIC VOID Info(FormatterString fmt, Args &&...args) @@ -58,7 +73,12 @@ namespace IACore private: #if IA_DISABLE_LOGGING > 0 - STATIC VOID LogStatus(IN String &&msg) + STATIC VOID LogTrace(IN String &&msg) + { + UNUSED(msg); + } + + STATIC VOID LogDebug(IN String &&msg) { UNUSED(msg); } @@ -78,10 +98,16 @@ namespace IACore UNUSED(msg); } #else - STATIC VOID LogStatus(IN String &&msg) + STATIC VOID LogTrace(IN String &&msg) { - if (s_logLevel <= ELogLevel::VERBOSE) - LogInternal(__CC_WHITE, "STATUS", IA_MOVE(msg)); + if (s_logLevel <= ELogLevel::TRACE) + LogInternal(__CC_WHITE, "TRACE", IA_MOVE(msg)); + } + + STATIC VOID LogDebug(IN String &&msg) + { + if (s_logLevel <= ELogLevel::DEBUG) + LogInternal(__CC_CYAN, "DEBUG", IA_MOVE(msg)); } STATIC VOID LogInfo(IN String &&msg) diff --git a/Src/IACore/inc/IACore/PCH.hpp b/Src/IACore/inc/IACore/PCH.hpp index e8f28af..e129411 100644 --- a/Src/IACore/inc/IACore/PCH.hpp +++ b/Src/IACore/inc/IACore/PCH.hpp @@ -119,6 +119,7 @@ # include # include # include +# include # include # include # include