diff options
| -rw-r--r-- | .clang-format | 38 | ||||
| -rw-r--r-- | .clangd | 7 | ||||
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | CMakeLists.txt | 29 | ||||
| -rw-r--r-- | src/CMakeLists.txt | 3 |
5 files changed, 71 insertions, 7 deletions
diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..386c0ac --- /dev/null +++ b/.clang-format @@ -0,0 +1,38 @@ +AccessModifierOffset: 0 +AlignAfterOpenBracket: DontAlign +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: Left +AlignOperands: true +AlignTrailingComments: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: true +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: true +AllowShortLoopsOnASingleLine: true +BraceWrapping: + AfterClass: true + AfterControlStatement: false + AfterEnum: false + AfterFunction: true + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: true + AfterUnion: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: false + SplitEmptyNamespace: true + SplitEmptyRecord: true +ColumnLimit: 120 +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +IndentWidth: 4 +Language: Cpp +MaxEmptyLinesToKeep: 2 +SortIncludes: true +Standard: c++20 +TabWidth: 4 +UseTab: Never @@ -0,0 +1,7 @@ +Diagnostics:
+# UnusedIncludes: Strict // clangd 14
+ ClangTidy:
+ Add: [performance*, modernize*, readability*, bugprone*]
+ Remove: [modernize-avoir-c-arrays]
+# InlayHints: // clangd 14
+# Enabled: Yes // clangd 14
@@ -1,6 +1,5 @@ /build /out /.vs -/.clangd /.cache compile_commands.json diff --git a/CMakeLists.txt b/CMakeLists.txt index 6aaa0f0..3b18938 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,21 +6,42 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake" CACHE STRING "Vcpkg toolchain file") -if(WIN32) +project(path-tracer VERSION 1.0 LANGUAGES CXX) + +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") add_compile_options( -msse4.1 -fcolor-diagnostics -fansi-escape-codes # colored output when using ninja + # https://github.com/cpp-best-practices/cppbestpractices/blob/master/02-Use_the_Tools_Available.md#gcc--clang + -Wall + -Wextra + -Wshadow + -Wcast-align + -Wnon-virtual-dtor + -Wpedantic + -Wunused ) endif() -project(path-tracer VERSION 1.0 LANGUAGES CXX) - find_package(imgui CONFIG REQUIRED) -find_package(Vulkan REQUIRED) find_package(nlohmann_json CONFIG REQUIRED) +find_package(Vulkan REQUIRED) if(UNIX AND NOT APPLE) find_package(X11 REQUIRED) endif() +find_program(CMAKE_CXX_CPPCHECK NAMES cppcheck) +if (CMAKE_CXX_CPPCHECK) + file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/cppcheck) + + list( + APPEND CMAKE_CXX_CPPCHECK + "--project=${CMAKE_BINARY_DIR}/compile_commands.json" + "--cppcheck-build-dir=${CMAKE_BINARY_DIR}/cppcheck" + "--enable=all" + "-iinclude/thirdparty" + ) +endif() + add_subdirectory(src) add_subdirectory(shaders) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e8bef7e..ff5f034 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,7 +7,7 @@ if(UNIX AND NOT APPLE) include_directories(${X11_xcb_INCLUDE_PATH}) endif() -set(LIBRARIES imgui::imgui) +set(LIBRARIES imgui::imgui nlohmann_json::nlohmann_json) add_executable( path-tracer @@ -32,4 +32,3 @@ if(UNIX AND NOT APPLE) endif() target_link_libraries(path-tracer PRIVATE ${LIBRARIES}) -target_link_libraries(path-tracer PRIVATE nlohmann_json nlohmann_json::nlohmann_json) |
