aboutsummaryrefslogtreecommitdiff
path: root/deps/raylib/projects/CMake
diff options
context:
space:
mode:
Diffstat (limited to 'deps/raylib/projects/CMake')
-rw-r--r--deps/raylib/projects/CMake/CMakeLists.txt42
-rw-r--r--deps/raylib/projects/CMake/README.md27
-rw-r--r--deps/raylib/projects/CMake/core_basic_window.c83
3 files changed, 152 insertions, 0 deletions
diff --git a/deps/raylib/projects/CMake/CMakeLists.txt b/deps/raylib/projects/CMake/CMakeLists.txt
new file mode 100644
index 0000000..96e33f3
--- /dev/null
+++ b/deps/raylib/projects/CMake/CMakeLists.txt
@@ -0,0 +1,42 @@
+cmake_minimum_required(VERSION 3.11) # FetchContent is available in 3.11+
+project(example)
+
+# Generate compile_commands.json
+set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
+
+# Dependencies
+set(RAYLIB_VERSION 5.5)
+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()
+
+# Our Project
+
+add_executable(${PROJECT_NAME} core_basic_window.c)
+#set(raylib_VERBOSE 1)
+target_link_libraries(${PROJECT_NAME} raylib)
+
+# Web Configurations
+if (${PLATFORM} STREQUAL "Web")
+ set_target_properties(${PROJECT_NAME} PROPERTIES SUFFIX ".html") # Tell Emscripten to build an example.html file.
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s ASYNCIFY -s GL_ENABLE_GET_PROC_ADDRESS=1")
+endif()
+
+# Checks if OSX and links appropriate frameworks (Only required on MacOS)
+if (APPLE)
+ target_link_libraries(${PROJECT_NAME} "-framework IOKit")
+ target_link_libraries(${PROJECT_NAME} "-framework Cocoa")
+ target_link_libraries(${PROJECT_NAME} "-framework OpenGL")
+endif()
diff --git a/deps/raylib/projects/CMake/README.md b/deps/raylib/projects/CMake/README.md
new file mode 100644
index 0000000..fc4fe55
--- /dev/null
+++ b/deps/raylib/projects/CMake/README.md
@@ -0,0 +1,27 @@
+# raylib CMake Project
+
+This provides a base project template which builds with [CMake](https://cmake.org).
+
+## Usage
+
+To compile the example, use one of the following dependending on your build target...
+
+### Desktop
+
+Use the following to build for desktop:
+
+``` bash
+cmake -B build
+cmake --build build
+```
+
+### Web
+
+Compiling for the web requires the [Emscripten SDK](https://emscripten.org/docs/getting_started/downloads.html):
+
+``` bash
+mkdir build
+cd build
+emcmake cmake .. -DPLATFORM=Web -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXECUTABLE_SUFFIX=".html"
+emmake make
+```
diff --git a/deps/raylib/projects/CMake/core_basic_window.c b/deps/raylib/projects/CMake/core_basic_window.c
new file mode 100644
index 0000000..86709f7
--- /dev/null
+++ b/deps/raylib/projects/CMake/core_basic_window.c
@@ -0,0 +1,83 @@
+/*******************************************************************************************
+*
+* raylib [core] example - Basic window (adapted for HTML5 platform)
+*
+* This example is prepared to compile for PLATFORM_WEB and PLATFORM_DESKTOP
+* As you will notice, code structure is slightly different to the other examples...
+* To compile it for PLATFORM_WEB just uncomment #define PLATFORM_WEB at beginning
+*
+* This example has been created using raylib 1.3 (www.raylib.com)
+* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
+*
+* Copyright (c) 2015 Ramon Santamaria (@raysan5)
+*
+********************************************************************************************/
+
+#include "raylib.h"
+
+#if defined(PLATFORM_WEB)
+ #include <emscripten/emscripten.h>
+#endif
+
+//----------------------------------------------------------------------------------
+// Global Variables Definition
+//----------------------------------------------------------------------------------
+int screenWidth = 800;
+int screenHeight = 450;
+
+//----------------------------------------------------------------------------------
+// Module Functions Declaration
+//----------------------------------------------------------------------------------
+void UpdateDrawFrame(void); // Update and Draw one frame
+
+//----------------------------------------------------------------------------------
+// Main Entry Point
+//----------------------------------------------------------------------------------
+int main()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");
+
+#if defined(PLATFORM_WEB)
+ emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
+#else
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ //--------------------------------------------------------------------------------------
+
+ // Main game loop
+ while (!WindowShouldClose()) // Detect window close button or ESC key
+ {
+ UpdateDrawFrame();
+ }
+#endif
+
+ // De-Initialization
+ //--------------------------------------------------------------------------------------
+ CloseWindow(); // Close window and OpenGL context
+ //--------------------------------------------------------------------------------------
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------------
+// Module Functions Definition
+//----------------------------------------------------------------------------------
+void UpdateDrawFrame(void)
+{
+ // Update
+ //----------------------------------------------------------------------------------
+ // TODO: Update your variables here
+ //----------------------------------------------------------------------------------
+
+ // Draw
+ //----------------------------------------------------------------------------------
+ BeginDrawing();
+
+ ClearBackground(RAYWHITE);
+
+ DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
+
+ EndDrawing();
+ //----------------------------------------------------------------------------------
+}