diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..c144259 --- /dev/null +++ b/.clang-format @@ -0,0 +1,29 @@ +--- +BasedOnStyle: LLVM +ColumnLimit: 120 +UseTab: Never +TabWidth: 2 +--- +Language: Cpp +DerivePointerAlignment: false +PointerAlignment: Left +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: false +IndentCaseLabels: false +AllowShortBlocksOnASingleLine: Always +AlignOperands: true +AlignTrailingComments: true +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: Yes +BreakConstructorInitializersBeforeComma: true +AlwaysBreakAfterReturnType: None +AlwaysBreakAfterDefinitionReturnType: None +AllowShortFunctionsOnASingleLine: All +Cpp11BracedListStyle: true +NamespaceIndentation: None +BinPackArguments: true +BinPackParameters: true +SortIncludes: false +AccessModifierOffset: -2 +ConstructorInitializerIndentWidth: 0 +ConstructorInitializerAllOnOneLineOrOnePerLine: true diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000..7533dea --- /dev/null +++ b/.clang-tidy @@ -0,0 +1 @@ +Checks: '*,-misc-unused-parameters,-modernize-use-trailing-return-type,-readability-named-parameter,-readability-convert-member-functions-to-static,-readability-uppercase-literal-suffix,-readability-magic-numbers,-hicpp-uppercase-literal-suffix,-hicpp-signed-bitwise,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-pro-type-static-cast-downcast,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-owning-memory,-cppcoreguidelines-pro-type-union-access,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-non-private-member-variables-in-classes,-fuchsia-*,-google-runtime-references,-llvmlibc-*' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 106a42e..e3a5ef5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -104,7 +104,7 @@ jobs: - name: Configure CMake run: | cmake -B build -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" \ - -DClang_DIR=/opt/local/libexec/llvm-11/lib/cmake/clang \ + -DLLVM_ROOT_DIR=/opt/local/libexec/llvm-11 \ -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache . - name: Build @@ -149,9 +149,6 @@ jobs: - name: Enable Visual Studio environment uses: ilammy/msvc-dev-cmd@v1 - - name: Create build directory - run: cmake -E make_directory ${{github.workspace}}/build - - name: Configure CMake run: | $workspace = $env:RUNNER_WORKSPACE -replace '\\', '/' diff --git a/CMakeLists.txt b/CMakeLists.txt index ec2e6d6..440558f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,6 @@ cmake_minimum_required(VERSION 3.10 FATAL_ERROR) # because of c++17 # Set MSVC runtime library flags from CMAKE_MSVC_RUNTIME_LIBRARY cmake_policy(SET CMP0091 NEW) -project(athena) -if (NOT MSVC) - set(CMAKE_CXX_STANDARD 20) - set(CMAKE_CXX_STANDARD_REQUIRED ON) -endif() ################## # Athena Version # @@ -15,7 +10,76 @@ set(ATHENA_MAJOR_VERSION 2) set(ATHENA_MINOR_VERSION 3) set(ATHENA_PATCH_VERSION 0) set(ATHENA_VERSION - ${ATHENA_MAJOR_VERSION}.${ATHENA_MINOR_VERSION}.${ATHENA_PATCH_VERSION}) + ${ATHENA_MAJOR_VERSION}.${ATHENA_MINOR_VERSION}.${ATHENA_PATCH_VERSION}) + +project(athena VERSION ${ATHENA_VERSION} LANGUAGES C CXX) + +if (MSVC) + # Shaddup MSVC + add_compile_definitions(UNICODE=1 _UNICODE=1 __SSE__=1 + _CRT_SECURE_NO_WARNINGS=1 D_SCL_SECURE_NO_WARNINGS=1 + _SCL_SECURE_NO_DEPRECATE=1 _CRT_NONSTDC_NO_WARNINGS=1 + _ENABLE_EXTENDED_ALIGNED_STORAGE=1 NOMINMAX=1) + add_compile_options(/IGNORE:4221 + $<$,$>:/wd4018> + $<$,$>:/wd4800> + $<$,$>:/wd4005> + $<$,$>:/wd4311> + $<$,$>:/wd4068> + $<$,$>:/wd4267> + $<$,$>:/wd4244> + $<$,$>:/wd4200> + $<$,$>:/wd4305> + $<$,$>:/wd4067> + $<$,$>:/wd4146> + $<$,$>:/wd4309> + $<$,$>:/wd4805> + ${VS_OPTIONS}) + + string(REPLACE "/GR " "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + string(REPLACE " /EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + add_compile_options( + # Disable exceptions + $<$:/EHsc-> + + # Disable RTTI + $<$:/GR-> + + # Enforce various standards compliant behavior. + $<$:/permissive-> + + # Enable standard volatile semantics. + $<$:/volatile:iso> + + # Reports the proper value for the __cplusplus preprocessor macro. + $<$:/Zc:__cplusplus> + + # Use latest C++ standard. + $<$:/std:c++latest> + ) + + if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + # Flags for MSVC (not clang-cl) + add_compile_options( + # Allow constexpr variables to have explicit external linkage. + $<$:/Zc:externConstexpr> + + # Assume that new throws exceptions, allowing better code generation. + $<$:/Zc:throwingNew> + + # Link-time Code Generation for Release builds + $<$:/GL> + ) + + # Link-time Code Generation for Release builds + set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "/LTCG") + set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO") + set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/DEBUG /RELEASE /OPT:REF /OPT:ICF /INCREMENTAL:NO /DEBUGTYPE:cv,fixup") + endif () +else () + set(CMAKE_CXX_STANDARD 20) + set(CMAKE_CXX_STANDARD_REQUIRED ON) +endif () ################ # Athena Build #