Replaced build system with cmake

This commit is contained in:
2026-01-14 17:38:44 +08:00
parent 4dadeb807d
commit dfbfe66a15
2 changed files with 27 additions and 0 deletions

5
.gitignore vendored
View File

@ -1,5 +1,10 @@
build/
.vscode/
.idea/
*.class
*.jar
*.pyc
__pycache__/
*.o
*.exe
*.out

22
CMakeLists.txt Normal file
View File

@ -0,0 +1,22 @@
# Specify the minimum required version of CMake
cmake_minimum_required(VERSION 3.14)
# Specify the C++ standard to use
set(CMAKE_C_STANDARD 17)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_COMPILER gcc)
# Define the project name and enable C language
project(starinvaders LANGUAGES C CXX)
# Find all source files in the "src" directory
file(GLOB SOURCES "src/*.c")
# Find zlib and sdl2
find_package(ZLIB REQUIRED)
find_package(SDL2 CONFIG REQUIRED)
# Add an executable target named "starinvaders" from the source files in the "src" directory
add_executable(starinvaders ${SOURCES})
target_link_libraries(starinvaders PRIVATE ZLIB::ZLIB)
target_link_libraries(starinvaders PRIVATE SDL2::SDL2)