Turned Makefile into CMake

This commit is contained in:
TriantaTV 2023-08-10 18:34:43 -05:00
parent fb672c7ddb
commit a8cc2d1174
7 changed files with 28 additions and 22 deletions

15
CMakeLists.txt Normal file
View File

@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 3.10)
project(
snakeplusplus
LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 11 CACHE STRING "The C++ standard to use")
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
include_directories(${snakeplusplus_SOURCE_DIR}/src)
add_subdirectory(src)

View File

@ -1,22 +0,0 @@
INC := -I include
STD := -std=c++11
SFML := -lsfml-graphics -lsfml-window -lsfml-system
all: compile link
fresh: dirs compile link
compile:
g++ $(INC) $(STD) -c -o build/main.o src/main.cpp
g++ $(INC) $(STD) -c -o build/playerinterface.o src/playerinterface.cpp
g++ $(INC) $(STD) -c -o build/gamestate.o src/gamestate.cpp
g++ $(INC) $(STD) -c -o build/snake.o src/snake.cpp
dirs:
mkdir bin build
link:
g++ build/*.o -o bin/SnakePlusPlus.out $(SFML)
clean:
rm bin/*.out build/*.o

13
src/CMakeLists.txt Normal file
View File

@ -0,0 +1,13 @@
find_package(SFML COMPONENTS graphics window system REQUIRED)
add_executable(snakeplusplus
./main.cpp
./gamestate.cpp
./snake.cpp
./playerinterface.cpp
)
target_include_directories(snakeplusplus PUBLIC ${CMAKE_CURRENT_LIST_DIR})
target_link_libraries(snakeplusplus sfml-graphics)