diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7124752 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Build folder +build/** \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..7e37447 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.21) + +# C/C++ Standard +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_C_STANDARD 99) +set(CMAKE_C_STANDARD_REQUIRED ON) + +# Dependencies +set(RAYLIB_VERSION 5.5) +include(dependencies.cmake) + +# Game source file +include(game.cmake) \ No newline at end of file diff --git a/dependencies.cmake b/dependencies.cmake new file mode 100644 index 0000000..f24cfd5 --- /dev/null +++ b/dependencies.cmake @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.11) + +# Raylib +find_package(raylib ${RAYLIB_VERSION} QUIET) # QUIET or REQUIRED +if (NOT raylib_FOUND) # If there's none, fetch and build raylib + include(FetchContent) + FetchContent_Declare( + raylib + DOWNLOAD_EXTRACT_TIMESTAMP OFF + URL https://github.com/raysan5/raylib/archive/refs/tags/${RAYLIB_VERSION}.tar.gz + ) + FetchContent_GetProperties(raylib) + if (NOT raylib_POPULATED) # Have we downloaded raylib yet? + set(FETCHCONTENT_QUIET NO) + FetchContent_MakeAvailable(raylib) + set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) # don't build the supplied examples + endif() +endif() \ No newline at end of file diff --git a/game.cmake b/game.cmake new file mode 100644 index 0000000..cd7ad9a --- /dev/null +++ b/game.cmake @@ -0,0 +1,37 @@ +# Project +project( + yoyo_card + VERSION 1.0.0 + DESCRIPTION "Gabo card game recreation." + HOMEPAGE_URL "https://www.etheryo.fr" + LANGUAGES CXX C +) +set(TARGET game) + +# Source files +set(SOURCES "${PROJECT_SOURCE_DIR}/src") +add_executable(${TARGET} + ${SOURCES}/main.cpp +) + +# Include folders +target_include_directories(${TARGET} PRIVATE "${PROJECT_SOURCE_DIR}/include") +target_include_directories(${TARGET} PRIVATE "${raylib_INCLUDE_DIRS}") + +# Libraries +target_link_libraries(${TARGET} raylib) + +# Compilation depending on the platform +if(MSVC) + target_compile_options(${TARGET} PUBLIC /W3 /WX /DEBUG ) +else() + target_compile_options(${TARGET} PUBLIC -Wall -Wextra -Wpedantic -Werror) +endif() + +# Output folder +set_target_properties(${TARGET} + PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/game" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/game" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/game" +) \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..95ff383 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,19 @@ +#include + +int main(void) +{ + const int screenWidth = 800; + const int screenHeight = 450; + InitWindow(screenWidth, screenHeight, "raylib hello world"); + + SetTargetFPS(60); + while (!WindowShouldClose()) + { + BeginDrawing(); + ClearBackground(RAYWHITE); + DrawText("Hello world from raylib.", 190, 200, 20, LIGHTGRAY); + EndDrawing(); + } + CloseWindow(); + return 0; +} \ No newline at end of file