aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvictorfisac <victorfisac@gmail.com>2017-09-02 08:25:38 +0200
committervictorfisac <victorfisac@gmail.com>2017-09-02 08:25:38 +0200
commitdd50348b4dffe59be03538bdbaf2a3d084426e1f (patch)
tree07105964919c99674aab2b9e6459ab2639b365c8
parent353912b2153b848b270ac15ba97a156b7d336d84 (diff)
parent958fed26c9249b283cca4252827bab46e6736bdb (diff)
downloadraylib-dd50348b4dffe59be03538bdbaf2a3d084426e1f.tar.gz
raylib-dd50348b4dffe59be03538bdbaf2a3d084426e1f.zip
Merge branch 'master' of https://github.com/raysan5/raylib
-rw-r--r--.gitignore22
-rw-r--r--CMakeLists.txt16
-rw-r--r--examples/CMakeLists.txt39
-rw-r--r--examples/Makefile2
-rw-r--r--games/CMakeLists.txt33
-rw-r--r--games/drturtle/CMakeLists.txt18
-rw-r--r--games/just_do/CMakeLists.txt21
-rw-r--r--games/koala_seasons/CMakeLists.txt21
-rw-r--r--games/light_my_ritual/CMakeLists.txt21
-rw-r--r--games/skully_escape/CMakeLists.txt21
-rw-r--r--games/wave_collector/CMakeLists.txt21
-rw-r--r--src/CMakeLists.txt132
-rw-r--r--src/Makefile2
-rw-r--r--utils.cmake49
14 files changed, 416 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index 016b8fa3..de3707bb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -131,3 +131,25 @@ src/libraylib.bc
# Meson build system
builddir/
+
+# CMake stuff
+CMakeCache.txt
+CMakeFiles
+CMakeScripts
+Testing
+Makefile
+cmake_install.cmake
+install_manifest.txt
+compile_commands.json
+CTestTestfile.cmake
+build
+
+# Unignore These makefiles...
+!examples/CMakeLists.txt
+!games/CMakeLists.txt
+
+# binaries made from raylib
+libraylib.a
+libraylib.so
+libraylib.dylib
+libraylib.dll
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 00000000..0dfa0857
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,16 @@
+cmake_minimum_required(VERSION 3.0)
+
+# Config options
+set(BUILD_EXAMPLES ON CACHE BOOL "Build the examples.")
+set(BUILD_GAMES ON CACHE BOOL "Build the example games.")
+
+add_subdirectory(src release)
+
+if (${BUILD_EXAMPLES})
+ add_subdirectory(examples)
+endif()
+
+if (${BUILD_GAMES})
+ add_subdirectory(games)
+endif()
+
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
new file mode 100644
index 00000000..354a1373
--- /dev/null
+++ b/examples/CMakeLists.txt
@@ -0,0 +1,39 @@
+# Setup the project and settings
+project(examples)
+
+include("../utils.cmake")
+
+# Make sure raylib has been built
+# TODO `build` directory should maybe be something else...
+# TODO place somewhere else?
+include_directories("../build/release")
+
+# Get the sources together
+set(example_dirs audio core models others physac shaders text texutures)
+set(example_sources)
+set(example_resources)
+foreach(example_dir ${example_dirs})
+ # Get the .c files
+ file(GLOB sources ${example_dir}/*.c)
+ list(APPEND example_sources ${sources})
+
+ # Any any resources
+ file(GLOB resources ${example_dir}/resources/*)
+ list(APPEND example_resources ${resources})
+endforeach()
+
+# Do each example
+foreach(example_source ${example_sources})
+ # Create the basename for the example
+ get_filename_component(example_name ${example_source} NAME)
+ string(REPLACE ".c" "" example_name ${example_name})
+
+ # Setup the example
+ add_executable(${example_name} ${example_source})
+
+ # Link the libraries
+ link_libraries_to_executable(${example_name})
+endforeach()
+
+# Copy all of the resource files to the destination
+file(COPY ${example_resources} DESTINATION "resources/")
diff --git a/examples/Makefile b/examples/Makefile
index 7c6a1cea..e6ae80f7 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -189,7 +189,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# libraries for Debian GNU/Linux desktop compiling
# requires the following packages:
# libglfw3-dev libopenal-dev libegl1-mesa-dev
- LIBS = -lraylib -lglfw3 -lGL -lopenal -lm -lpthread -ldl
+ LIBS = -lraylib -lglfw -lGL -lopenal -lm -lpthread -ldl
# on XWindow requires also below libraries
LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
else
diff --git a/games/CMakeLists.txt b/games/CMakeLists.txt
new file mode 100644
index 00000000..278d1330
--- /dev/null
+++ b/games/CMakeLists.txt
@@ -0,0 +1,33 @@
+# Setup the project and settings
+project(games)
+
+include("../utils.cmake")
+
+# Make sure raylib has been built
+# TODO `build` directory should maybe be something else...
+# TODO place somewhere else?
+include_directories("../build/release")
+
+# Get the source toegher
+file(GLOB sources *.c)
+
+# Do each game
+foreach(game_source ${sources})
+ # Create the basename for the game
+ get_filename_component(game_name ${game_source} NAME)
+ string(REPLACE ".c" "" game_name ${game_name})
+
+ # Setup the game
+ add_executable(${game_name} ${game_source})
+
+ # Link the libraries
+ link_libraries_to_executable(${game_name})
+endforeach()
+
+# Do the games with subdirectories
+add_subdirectory(drturtle)
+add_subdirectory(just_do)
+add_subdirectory(koala_seasons)
+add_subdirectory(light_my_ritual)
+add_subdirectory(skully_escape)
+add_subdirectory(wave_collector)
diff --git a/games/drturtle/CMakeLists.txt b/games/drturtle/CMakeLists.txt
new file mode 100644
index 00000000..59813fb3
--- /dev/null
+++ b/games/drturtle/CMakeLists.txt
@@ -0,0 +1,18 @@
+# Setup the project and settings
+project(drturtle)
+
+include("../../utils.cmake")
+
+
+# Make sure raylib has been built
+# TODO `build` directory should maybe be something else...
+include_directories("../../build/release")
+
+# Executable & linking
+add_executable(drturtle 06_drturtle_final.c)
+link_libraries_to_executable(drturtle)
+
+# Resources
+# Copy all of the resource files to the destination
+file(COPY "resources/" DESTINATION "resources/")
+
diff --git a/games/just_do/CMakeLists.txt b/games/just_do/CMakeLists.txt
new file mode 100644
index 00000000..11644008
--- /dev/null
+++ b/games/just_do/CMakeLists.txt
@@ -0,0 +1,21 @@
+# Setup the project and settings
+project(just_do)
+
+include("../../utils.cmake")
+
+
+# Make sure raylib has been built
+# TODO `build` directory should maybe be something else...
+include_directories("../../build/release")
+
+# Grab the screens
+file(GLOB screen_sources "screens/*.c")
+
+# Executable & linking
+add_executable(just_do just_do.c ${screen_sources})
+link_libraries_to_executable(just_do)
+
+# Resources
+# Copy all of the resource files to the destination
+file(COPY "resources/" DESTINATION "resources/")
+
diff --git a/games/koala_seasons/CMakeLists.txt b/games/koala_seasons/CMakeLists.txt
new file mode 100644
index 00000000..16069a7e
--- /dev/null
+++ b/games/koala_seasons/CMakeLists.txt
@@ -0,0 +1,21 @@
+# Setup the project and settings
+project(koala_seasons)
+
+include("../../utils.cmake")
+
+
+# Make sure raylib has been built
+# TODO `build` directory should maybe be something else...
+include_directories("../../build/release")
+
+# Grab the screens
+file(GLOB screen_sources "screens/*.c")
+
+# Executable & linking
+add_executable(koala_seasons koala_seasons.c ${screen_sources})
+link_libraries_to_executable(koala_seasons)
+
+# Resources
+# Copy all of the resource files to the destination
+file(COPY "resources/" DESTINATION "resources/")
+
diff --git a/games/light_my_ritual/CMakeLists.txt b/games/light_my_ritual/CMakeLists.txt
new file mode 100644
index 00000000..1e2cafe1
--- /dev/null
+++ b/games/light_my_ritual/CMakeLists.txt
@@ -0,0 +1,21 @@
+# Setup the project and settings
+project(light_my_ritual)
+
+include("../../utils.cmake")
+
+
+# Make sure raylib has been built
+# TODO `build` directory should maybe be something else...
+include_directories("../../build/release")
+
+# Grab the screens
+file(GLOB screen_sources "screens/*.c")
+
+# Executable & linking
+add_executable(light_my_ritual light_my_ritual.c ${screen_sources})
+link_libraries_to_executable(light_my_ritual)
+
+# Resources
+# Copy all of the resource files to the destination
+file(COPY "resources/" DESTINATION "resources/")
+
diff --git a/games/skully_escape/CMakeLists.txt b/games/skully_escape/CMakeLists.txt
new file mode 100644
index 00000000..d14f52d9
--- /dev/null
+++ b/games/skully_escape/CMakeLists.txt
@@ -0,0 +1,21 @@
+# Setup the project and settings
+project(skully_escape)
+
+include("../../utils.cmake")
+
+
+# Make sure raylib has been built
+# TODO `build` directory should maybe be something else...
+include_directories("../../build/release")
+
+# Grab the screens
+file(GLOB screen_sources "screens/*.c")
+
+# Executable & linking
+add_executable(skully_escape skully_escape.c player.c monster.c ${screen_sources})
+link_libraries_to_executable(skully_escape)
+
+# Resources
+# Copy all of the resource files to the destination
+file(COPY "resources/" DESTINATION "resources/")
+
diff --git a/games/wave_collector/CMakeLists.txt b/games/wave_collector/CMakeLists.txt
new file mode 100644
index 00000000..c16bd426
--- /dev/null
+++ b/games/wave_collector/CMakeLists.txt
@@ -0,0 +1,21 @@
+# Setup the project and settings
+project(wave_collector)
+
+include("../../utils.cmake")
+
+
+# Make sure raylib has been built
+# TODO `build` directory should maybe be something else...
+include_directories("../../build/release")
+
+# Grab the screens
+file(GLOB screen_sources "screens/*.c")
+
+# Executable & linking
+add_executable(wave_collector wave_collector.c ${screen_sources})
+link_libraries_to_executable(wave_collector)
+
+# Resources
+# Copy all of the resource files to the destination
+file(COPY "resources/" DESTINATION "resources/")
+
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644
index 00000000..a398d665
--- /dev/null
+++ b/src/CMakeLists.txt
@@ -0,0 +1,132 @@
+# Setup the project and settings
+project(raylib)
+include("../utils.cmake")
+
+set(raylib_VERSION_MAJOR 1)
+set(raylib_VERSION_MINOR 8)
+set(RAYLIB raylib) # Name of the generated library
+
+
+### Config options ###
+# Build a static or shared raylib?
+set(SHARED_RAYLIB OFF CACHE BOOL "Build raylib as a dynamic library")
+
+# Platform
+set(PLATFORM "Desktop" CACHE STRING "Platform to build for.")
+set_property(CACHE PLATFORM PROPERTY STRINGS "Desktop" "Web" "Android" "Raspberry Pi")
+
+# OpenGL version
+set(OPENGL_VERSION "3.3" CACHE STRING "OpenGL Version to build raylib with")
+set_property(CACHE OPENGL_VERSION PROPERTY STRINGS "3.3" "2.1" "1.1" "ES 2.0")
+### Config options ###
+
+
+# Translate the config options to what raylib wants
+if(${PLATFORM} MATCHES "Desktop")
+ set(PLATFORM "PLATFORM_DESKTOP")
+
+ # OpenGL version
+ if (${OPENGL_VERSION} MATCHES "3.3")
+ set(GRAPHICS "GRAPHICS_API_OPENGL_33")
+ elseif (${OPENGL_VERSION} MATCHES "2.1")
+ set(GRAPHICS "GRAPHICS_API_OPENGL_21")
+ elseif (${OPENGL_VERSION} MATCHES "1.1")
+ set(GRAPHICS "GRAPHICS_API_OPENGL_11")
+ elseif (${OPENGL_VERSION} MATCHES "ES 2.0")
+ set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
+ endif()
+
+ # Need to force OpenGL 3.3 on OS X
+ # See: https://github.com/raysan5/raylib/issues/341
+ if(APPLE)
+ set(GRAPHICS "GRAPHICS_API_OPENGL_33")
+ endif()
+elseif(${PLATFORM} MATCHES "Web")
+ set(PLATFORM "PLATFORM_WEB")
+ set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
+
+ # Need to use `emcc`
+ set(CMAKE_C_COMPILER "emcc")
+ set(CMAKE_CXX_COMPILER "em++")
+
+ # Change the name of the output library
+ set(RAYLIB "libraylib.bc")
+
+elseif(${PLATFORM} MATCHES "Android")
+ set(PLATFORM "PLATFORM_ANDROID")
+ set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
+elseif(${PLATFORM} MATCHES "Raspberry Pi")
+ set(PLATFORM "PLATFORM_RPI")
+ set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
+endif()
+
+# Get the sources together
+file(GLOB raylib_sources *.c)
+file(GLOB stb_vorbis external/stb_vorbis.c)
+set(sources ${raylib_sources} ${stb_vorbis})
+
+# Which platform?
+if(${PLATFORM} MATCHES "PLATFORM_DESKTOP")
+ # Build a static or shared raylib?
+ # TODO clean this up a bit?
+ if(${SHARED_RAYLIB})
+ # Shared library
+ add_library(${RAYLIB} SHARED ${sources})
+
+ # Will link -framework (if on OS X)
+ link_os_x_frameworks(raylib)
+ else()
+ # Static library
+ add_library(${RAYLIB} STATIC ${sources})
+
+ if(LINUX)
+ # On Linux, need to link a few extra things for static
+ target_link_libraries(${RAYLIB} m pthread dl)
+ target_link_libraries(${RAYLIB} X11 Xrandr Xinerama Xi Xxf86vm Xcursor) # X11 stuff
+ endif()
+ endif()
+
+ # Always need to link OpenAL and OpenGL
+ if(LINUX)
+ # Elsewhere (such as Linux), need `-lopenal -lGL`
+ target_link_libraries(${RAYLIB} openal)
+ target_link_libraries(${RAYLIB} GL)
+ endif()
+
+ # Add in GLFW as a linking target
+ target_link_libraries(${RAYLIB} glfw)
+
+ # Library file & Header
+ set_target_properties(${RAYLIB} PROPERTIES PUBLIC_HEADER "raylib.h")
+ install(
+ TARGETS ${RAYLIB}
+ ARCHIVE DESTINATION lib
+ LIBRARY DESTINATION lib
+ PUBLIC_HEADER DESTINATION include
+ )
+
+ # Copy the header files to the build directory
+ file(COPY "raylib.h" DESTINATION ".")
+ file(COPY "rlgl.h" DESTINATION ".")
+ file(COPY "physac.h" DESTINATION ".")
+ file(COPY "raymath.h" DESTINATION ".")
+ file(COPY "audio.h" DESTINATION ".")
+elseif(${PLATFORM} MATCHES "PLATFORM_WEB")
+ # For the web.
+ add_executable(${RAYLIB} ${sources})
+endif()
+
+
+# Set the compile flags to raylib
+target_compile_definitions(${RAYLIB}
+ PUBLIC ${PLATFORM}
+ PUBLIC ${GRAPHICS}
+)
+
+
+
+# Print the flags for the user
+message(STATUS "Compiling with the flags:")
+message(STATUS " PLATFORM=" ${PLATFORM})
+message(STATUS " GRAPHICS=" ${GRAPHICS})
+
diff --git a/src/Makefile b/src/Makefile
index 6d0318c1..06b67a04 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -332,7 +332,7 @@ else
ifeq ($(PLATFORM_OS),LINUX)
# compile raylib to shared library version for GNU/Linux.
# WARNING: you should type "make clean" before doing this target
- $(CC) -shared -o $(OUTPUT_PATH)/libraylib.so $(OBJS) -lglfw3 -lGL -lopenal -lm -lpthread -ldl
+ $(CC) -shared -o $(OUTPUT_PATH)/libraylib.so $(OBJS) -lglfw -lGL -lopenal -lm -lpthread -ldl
@echo "raylib shared library generated (libraylib.so)!"
endif
ifeq ($(PLATFORM_OS),OSX)
diff --git a/utils.cmake b/utils.cmake
new file mode 100644
index 00000000..c902f60e
--- /dev/null
+++ b/utils.cmake
@@ -0,0 +1,49 @@
+# All sorts of things that we need cross project
+cmake_minimum_required(VERSION 3.0)
+
+# Detect linux
+if(UNIX AND NOT APPLE)
+ set(LINUX TRUE)
+endif()
+
+# Need GLFW 3.2.1
+find_package(glfw3 3.2.1 REQUIRED)
+
+
+# Linking for OS X -framework options
+# Will do nothing on other OSes
+function(link_os_x_frameworks binary)
+ if(APPLE)
+ find_library(OPENGL_LIBRARY OpenGL)
+ find_library(OPENAL_LIBRARY OpenAL)
+ find_library(COCOA_LIBRARY Cocoa)
+
+ set(OSX_FRAMEWORKS ${OPENGL_LIBRARY} ${OPENAL_LIBRARY} ${COCOA_LIBRARY})
+ target_link_libraries(${binary} ${OSX_FRAMEWORKS})
+ endif()
+endfunction()
+
+
+# Do the linking for executables that are meant to link raylib
+function(link_libraries_to_executable executable)
+ # Link the libraries
+ if(APPLE)
+ # OS X, we use frameworks
+ link_os_x_frameworks(${executable})
+ elseif(LINUX)
+ # Elsewhere (such as Linux), need `-lopenal -lGL`, etc...
+ target_link_libraries(${executable} m pthread dl)
+ target_link_libraries(${executable} openal)
+ target_link_libraries(${executable} GL)
+ target_link_libraries(${executable} X11 Xrandr Xinerama Xi Xxf86vm Xcursor) # X11 stuff
+ else()
+ # TODO windows
+ endif()
+
+ # Add in GLFW as a linking target
+ target_link_libraries(${executable} glfw)
+
+ # And raylib
+ target_link_libraries(${executable} raylib)
+endfunction()
+