Kajetan Johannes Hammerle 1 месяц назад
Родитель
Сommit
637e909c61
5 измененных файлов с 93 добавлено и 78 удалено
  1. 2 0
      .gitignore
  2. 80 0
      CMakeLists.txt
  3. 0 1
      Main.c
  4. 0 77
      Makefile
  5. 11 0
      start

+ 2 - 0
.gitignore

@@ -1 +1,3 @@
 tetris
+*.swp
+build/

+ 80 - 0
CMakeLists.txt

@@ -0,0 +1,80 @@
+cmake_minimum_required(VERSION 3.25)
+project(tetris C)
+
+set(CMAKE_C_STANDARD 23)
+
+set(SRC
+	"Main.c"
+)
+
+add_executable(${PROJECT_NAME} ${SRC})
+target_link_libraries(${PROJECT_NAME} PRIVATE ncursesw)
+target_compile_options(${PROJECT_NAME} PRIVATE
+	-fdiagnostics-color=always
+    -Wall
+    -Walloc-zero
+    -Walloca
+    -Wanalyzer-too-complex
+    -Warith-conversion
+    -Warray-bounds=2
+    -Warray-parameter
+    -Wattribute-alias=2
+    -Wbad-function-cast
+    -Wbidi-chars=any
+    -Wcast-align=strict
+    -Wcast-qual
+    -Wconversion
+    -Wdate-time
+    -Wdisabled-optimization
+    -Wdouble-promotion
+    -Wduplicated-branches
+    -Wduplicated-cond
+    -Wenum-compare
+    -Wenum-conversion
+    -Werror
+    -Wextra
+    -Wfloat-equal
+    -Wformat-overflow=2
+    -Wformat-signedness
+    -Wformat-truncation=2
+    -Wformat=2
+    -Wframe-larger-than=8388608
+    -Wimplicit-fallthrough=5
+    -Winfinite-recursion
+    -Winit-self
+    -Winvalid-pch
+    -Wjump-misses-init
+    -Wlarger-than=1073741824
+    -Wlogical-op
+    -Wmissing-braces
+    -Wmissing-declarations
+    -Wmissing-include-dirs
+    -Wmissing-prototypes
+    -Wmultichar
+    -Wnarrowing
+    -Wnested-externs
+    -Wnormalized=nfkc
+    -Wnull-dereference
+    -Wold-style-definition
+    -Woverlength-strings
+    -Wredundant-decls
+    -Wshadow
+    -Wshift-overflow=2
+    -Wsign-conversion
+    -Wstack-protector
+    -Wstack-usage=8388608
+    -Wstrict-overflow=2
+    -Wstrict-prototypes
+    -Wstringop-overflow=4
+    -Wswitch-enum
+    -Wtrampolines
+    -Wtrivial-auto-var-init
+    -Wundef
+    -Wunreachable-code
+    -Wunused-const-variable=2
+    -Wuse-after-free=3
+    -Wvla
+    -Wwrite-strings
+    -pedantic
+    -pedantic-errors
+)

+ 0 - 1
Main.c

@@ -9,7 +9,6 @@
 #include <time.h>
 #include <unistd.h>
 #include <wchar.h>
-#include <wctype.h>
 
 static const wchar_t moving = L'\u2592';
 static const wchar_t still = L'\u2593';

+ 0 - 77
Makefile

@@ -1,77 +0,0 @@
-all: tetris
-
-run: tetris
-	./tetris
-	
-tetris: *.c
-	gcc -o tetris *.c -lncursesw \
-		-Wall \
-		-Walloc-zero \
-		-Walloca \
-		-Wanalyzer-too-complex \
-		-Warith-conversion \
-		-Warray-bounds=2 \
-		-Warray-parameter \
-		-Wattribute-alias=2 \
-		-Wbad-function-cast \
-		-Wbidi-chars=any \
-		-Wcast-align=strict \
-		-Wcast-qual \
-		-Wconversion \
-		-Wdate-time \
-		-Wdisabled-optimization \
-		-Wdouble-promotion \
-		-Wduplicated-branches \
-		-Wduplicated-cond \
-		-Wenum-compare \
-		-Wenum-conversion \
-		-Werror \
-		-Wextra \
-		-Wfloat-equal \
-		-Wformat-overflow=2 \
-		-Wformat-signedness \
-		-Wformat-truncation=2 \
-		-Wformat=2 \
-		-Wframe-larger-than=8388608 \
-		-Wimplicit-fallthrough=5 \
-		-Winfinite-recursion \
-		-Winit-self \
-		-Winvalid-pch \
-		-Wjump-misses-init \
-		-Wlarger-than=1073741824 \
-		-Wlogical-op \
-		-Wmissing-braces \
-		-Wmissing-declarations \
-		-Wmissing-include-dirs \
-		-Wmissing-prototypes \
-		-Wmultichar \
-		-Wnarrowing \
-		-Wnested-externs \
-		-Wnormalized=nfkc \
-		-Wnull-dereference \
-		-Wold-style-definition \
-		-Woverlength-strings \
-		-Wredundant-decls \
-		-Wshadow \
-		-Wshift-overflow=2 \
-		-Wsign-conversion \
-		-Wstack-protector \
-		-Wstack-usage=8388608 \
-		-Wstrict-overflow=2 \
-		-Wstrict-prototypes \
-		-Wstringop-overflow=4 \
-		-Wswitch-enum \
-		-Wtrampolines \
-		-Wtrivial-auto-var-init \
-		-Wundef \
-		-Wunreachable-code \
-		-Wunused-const-variable=2 \
-		-Wuse-after-free=3 \
-		-Wvla \
-		-Wwrite-strings \
-		-pedantic \
-		-pedantic-errors \
-		-O3
-	
-clean:
-	rm -f tetris

+ 11 - 0
start

@@ -0,0 +1,11 @@
+#!/bin/bash
+set -e
+clear
+cd "$(dirname "$0")"
+
+folder="build"
+if [ ! -e "$folder" ]; then
+    cmake -B "$folder" -S . -G Ninja
+fi
+ninja -C "$folder"
+./$folder/tetris