diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..dbe07121 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,53 @@ +cmake_minimum_required(VERSION 3.12) + +project(libtoolchain + VERSION 1.0.0 + LANGUAGES CXX C +) + +# Set C++ standard +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# Platform detection +if(WIN32) + set(PLATFORM_NAME "win32") +elseif(APPLE) + set(PLATFORM_NAME "macos") +else() + set(PLATFORM_NAME "linux") +endif() + +# Output directories +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin/${PLATFORM_NAME}) + +# Collect source files from all subdirectories +file(GLOB_RECURSE TOOLCHAIN_SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cc + ${CMAKE_CURRENT_SOURCE_DIR}/src/*.c +) + +# Create static library +add_library(toolchain STATIC ${TOOLCHAIN_SOURCES}) + +# Include directories +target_include_directories(toolchain + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/include +) + +# Link dependencies +target_link_libraries(toolchain + PUBLIC + mbedtls + fmt +) + +# Compiler flags +if(NOT MSVC) + target_compile_options(toolchain PRIVATE -Wall -Wno-unused-value -Wno-unused-but-set-variable -fPIC) + if(APPLE) + target_compile_options(toolchain PRIVATE -Wno-unused-private-field) + endif() +endif() diff --git a/include/tc/crypto/detail/CmacImpl.h b/include/tc/crypto/detail/CmacImpl.h index a4589510..8a208d8b 100644 --- a/include/tc/crypto/detail/CmacImpl.h +++ b/include/tc/crypto/detail/CmacImpl.h @@ -145,7 +145,7 @@ class CmacImpl if (mState == State::Initialized) { // finalise mac, and tranisition to done state - std::array M_last; + std::array M_last = {}; // 1) transform last unprocessed to M_last block if (mUnprocessedBlockPos == kBlockSize) diff --git a/include/tc/io/FileStream.h b/include/tc/io/FileStream.h index bd557d25..99d2ea1f 100644 --- a/include/tc/io/FileStream.h +++ b/include/tc/io/FileStream.h @@ -26,7 +26,7 @@ #include #ifdef _WIN32 -#include +#include #else #include #endif diff --git a/include/tc/types.h b/include/tc/types.h index 8cdc8377..c6988143 100644 --- a/include/tc/types.h +++ b/include/tc/types.h @@ -20,7 +20,9 @@ #include #ifdef _WIN32 +#ifndef NOMINMAX #define NOMINMAX +#endif #endif /// Alias uint8_t to byte_t to more explicity indicate its role in memory related contexts @@ -62,4 +64,4 @@ namespace tc { /// Returns if a value of type uint64_t is too large to be stored as size_t. bool is_uint64_t_too_large_for_size_t(uint64_t val); -} \ No newline at end of file +} diff --git a/src/io/FileStream.cpp b/src/io/FileStream.cpp index 279694d2..fc0b35aa 100644 --- a/src/io/FileStream.cpp +++ b/src/io/FileStream.cpp @@ -198,7 +198,9 @@ void tc::io::FileStream::dispose() #ifdef _WIN32 +#ifdef _MSC_VER #pragma warning(disable : 4065) // disable warning for switch case with only default case +#endif void tc::io::FileStream::open_impl(const tc::io::Path& path, FileMode mode, FileAccess access) { @@ -272,7 +274,7 @@ void tc::io::FileStream::open_impl(const tc::io::Path& path, FileMode mode, File } // append can only open in write only mode - if (mode == tc::io::FileMode::Append && (access_flag & GENERIC_READ | GENERIC_WRITE) != GENERIC_WRITE) + if (mode == tc::io::FileMode::Append && (access_flag & (GENERIC_READ | GENERIC_WRITE)) != GENERIC_WRITE) { throw tc::ArgumentException(kClassName + "::open()", "Stream opened in Append mode can only work with Write access. ReadWrite is not permitted"); } @@ -443,7 +445,9 @@ void tc::io::FileStream::flush_impl() } } +#ifdef _MSC_VER #pragma warning(default : 4065) // reenable warning for switch case with only default case +#endif #else void tc::io::FileStream::open_impl(const tc::io::Path& path, FileMode mode, FileAccess access) diff --git a/src/io/LocalFileSystem.cpp b/src/io/LocalFileSystem.cpp index 0785ffe3..b50bf1c9 100644 --- a/src/io/LocalFileSystem.cpp +++ b/src/io/LocalFileSystem.cpp @@ -9,7 +9,9 @@ #include #include +#ifdef _MSC_VER #pragma warning(disable : 4065) // disable warning for switch case with only default case +#endif #else #include @@ -580,6 +582,8 @@ void tc::io::LocalFileSystem::getDirectoryChildren(const std::string& method_nam #ifdef _WIN32 +#ifdef _MSC_VER #pragma warning(default : 4065) // reenable warning for switch case with only default case +#endif -#endif \ No newline at end of file +#endif