aboutsummaryrefslogtreecommitdiffstats
path: root/raylib/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'raylib/cmake')
-rw-r--r--raylib/cmake/AddIfFlagCompiles.cmake12
-rw-r--r--raylib/cmake/BuildOptions.cmake18
-rw-r--r--raylib/cmake/CompileDefinitions.cmake115
-rw-r--r--raylib/cmake/CompilerFlags.cmake83
-rw-r--r--raylib/cmake/EnumOption.cmake9
-rw-r--r--raylib/cmake/GlfwImport.cmake34
-rw-r--r--raylib/cmake/InstallConfigurations.cmake29
-rw-r--r--raylib/cmake/JoinPaths.cmake26
-rw-r--r--raylib/cmake/LibraryConfigurations.cmake112
-rw-r--r--raylib/cmake/LibraryPathToLinkerFlags.cmake24
-rw-r--r--raylib/cmake/PackConfigurations.cmake13
-rw-r--r--raylib/cmake/PopulateConfigVariablesLocally.cmake11
-rw-r--r--raylib/cmake/raylib-config-version.cmake21
-rw-r--r--raylib/cmake/raylib-config.cmake77
14 files changed, 584 insertions, 0 deletions
diff --git a/raylib/cmake/AddIfFlagCompiles.cmake b/raylib/cmake/AddIfFlagCompiles.cmake
new file mode 100644
index 0000000..403607b
--- /dev/null
+++ b/raylib/cmake/AddIfFlagCompiles.cmake
@@ -0,0 +1,12 @@
+include(CheckCCompilerFlag)
+function(add_if_flag_compiles flag)
+ CHECK_C_COMPILER_FLAG("${flag}" COMPILER_HAS_THOSE_TOGGLES)
+ set(outcome "Failed")
+ if(COMPILER_HAS_THOSE_TOGGLES)
+ foreach(var ${ARGN})
+ set(${var} "${flag} ${${var}}" PARENT_SCOPE)
+ endforeach()
+ set(outcome "compiles")
+ endif()
+ message(STATUS "Testing if ${flag} can be used -- ${outcome}")
+endfunction()
diff --git a/raylib/cmake/BuildOptions.cmake b/raylib/cmake/BuildOptions.cmake
new file mode 100644
index 0000000..0fce642
--- /dev/null
+++ b/raylib/cmake/BuildOptions.cmake
@@ -0,0 +1,18 @@
+if(${PLATFORM} MATCHES "Desktop" AND APPLE)
+ if(MACOS_FATLIB)
+ if (CMAKE_OSX_ARCHITECTURES)
+ message(FATAL_ERROR "User supplied -DCMAKE_OSX_ARCHITECTURES overrides -DMACOS_FATLIB=ON")
+ else()
+ set(CMAKE_OSX_ARCHITECTURES "x86_64;i386")
+ endif()
+ endif()
+endif()
+
+# This helps support the case where emsdk toolchain file is used
+# either by setting it with -DCMAKE_TOOLCHAIN_FILE=<path_to_emsdk>/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake
+# or by using "emcmake cmake -B build -S ." as described in https://emscripten.org/docs/compiling/Building-Projects.html
+if(EMSCRIPTEN)
+ SET(PLATFORM Web CACHE STRING "Forcing PLATFORM_WEB because EMSCRIPTEN was detected")
+endif()
+
+# vim: ft=cmake
diff --git a/raylib/cmake/CompileDefinitions.cmake b/raylib/cmake/CompileDefinitions.cmake
new file mode 100644
index 0000000..7fbbef9
--- /dev/null
+++ b/raylib/cmake/CompileDefinitions.cmake
@@ -0,0 +1,115 @@
+# Adding compile definitions
+target_compile_definitions("raylib" PUBLIC "${PLATFORM_CPP}")
+target_compile_definitions("raylib" PUBLIC "${GRAPHICS}")
+
+function(define_if target variable)
+ if (${${variable}})
+ message(STATUS "${variable}=${${variable}}")
+ target_compile_definitions(${target} PUBLIC "${variable}")
+ endif ()
+endfunction()
+
+if (${CUSTOMIZE_BUILD})
+ target_compile_definitions("raylib" PUBLIC EXTERNAL_CONFIG_FLAGS)
+ define_if("raylib" USE_AUDIO)
+ define_if("raylib" SUPPORT_MODULE_RSHAPES)
+ define_if("raylib" SUPPORT_MODULE_RTEXTURES)
+ define_if("raylib" SUPPORT_MODULE_RTEXT)
+ define_if("raylib" SUPPORT_MODULE_RMODELS)
+ define_if("raylib" SUPPORT_MODULE_RAUDIO)
+ define_if("raylib" SUPPORT_CAMERA_SYSTEM)
+ define_if("raylib" SUPPORT_GESTURES_SYSTEM)
+ define_if("raylib" SUPPORT_MOUSE_GESTURES)
+ define_if("raylib" SUPPORT_SSH_KEYBOARD_RPI)
+ define_if("raylib" SUPPORT_DEFAULT_FONT)
+ define_if("raylib" SUPPORT_SCREEN_CAPTURE)
+ define_if("raylib" SUPPORT_GIF_RECORDING)
+ define_if("raylib" SUPPORT_BUSY_WAIT_LOOP)
+ define_if("raylib" SUPPORT_EVENTS_WAITING)
+ define_if("raylib" SUPPORT_WINMM_HIGHRES_TIMER)
+ define_if("raylib" SUPPORT_DATA_STORAGE)
+ define_if("raylib" SUPPORT_COMPRESSION_API)
+ define_if("raylib" SUPPORT_QUADS_DRAW_MODE)
+ define_if("raylib" SUPPORT_IMAGE_EXPORT)
+ define_if("raylib" SUPPORT_IMAGE_GENERATION)
+ define_if("raylib" SUPPORT_IMAGE_MANIPULATION)
+ define_if("raylib" SUPPORT_FILEFORMAT_PNG)
+ define_if("raylib" SUPPORT_FILEFORMAT_DDS)
+ define_if("raylib" SUPPORT_FILEFORMAT_HDR)
+ define_if("raylib" SUPPORT_FILEFORMAT_KTX)
+ define_if("raylib" SUPPORT_FILEFORMAT_ASTC)
+ define_if("raylib" SUPPORT_FILEFORMAT_BMP)
+ define_if("raylib" SUPPORT_FILEFORMAT_TGA)
+ define_if("raylib" SUPPORT_FILEFORMAT_JPG)
+ define_if("raylib" SUPPORT_FILEFORMAT_GIF)
+ define_if("raylib" SUPPORT_FILEFORMAT_QOI)
+ define_if("raylib" SUPPORT_FILEFORMAT_PSD)
+ define_if("raylib" SUPPORT_FILEFORMAT_PKM)
+ define_if("raylib" SUPPORT_FILEFORMAT_PVR)
+ define_if("raylib" SUPPORT_FILEFORMAT_FNT)
+ define_if("raylib" SUPPORT_FILEFORMAT_TTF)
+ define_if("raylib" SUPPORT_TEXT_MANIPULATION)
+ define_if("raylib" SUPPORT_MESH_GENERATION)
+ define_if("raylib" SUPPORT_FILEFORMAT_OBJ)
+ define_if("raylib" SUPPORT_FILEFORMAT_MTL)
+ define_if("raylib" SUPPORT_FILEFORMAT_IQM)
+ define_if("raylib" SUPPORT_FILEFORMAT_GLTF)
+ define_if("raylib" SUPPORT_FILEFORMAT_VOX)
+ define_if("raylib" SUPPORT_FILEFORMAT_WAV)
+ define_if("raylib" SUPPORT_FILEFORMAT_OGG)
+ define_if("raylib" SUPPORT_FILEFORMAT_XM)
+ define_if("raylib" SUPPORT_FILEFORMAT_MOD)
+ define_if("raylib" SUPPORT_FILEFORMAT_MP3)
+ define_if("raylib" SUPPORT_FILEFORMAT_FLAC)
+ define_if("raylib" SUPPORT_STANDARD_FILEIO)
+ define_if("raylib" SUPPORT_TRACELOG)
+
+ if (UNIX AND NOT APPLE)
+ target_compile_definitions("raylib" PUBLIC "MAX_FILEPATH_LENGTH=4096")
+ else ()
+ target_compile_definitions("raylib" PUBLIC "MAX_FILEPATH_LENGTH=512")
+ endif ()
+
+ target_compile_definitions("raylib" PUBLIC "MAX_GAMEPADS=4")
+ target_compile_definitions("raylib" PUBLIC "MAX_GAMEPAD_AXIS=8")
+ target_compile_definitions("raylib" PUBLIC "MAX_GAMEPAD_BUTTONS=32")
+ target_compile_definitions("raylib" PUBLIC "MAX_TOUCH_POINTS=10")
+ target_compile_definitions("raylib" PUBLIC "MAX_KEY_PRESSED_QUEUE=16")
+
+ target_compile_definitions("raylib" PUBLIC "STORAGE_DATA_FILE=\"storage.data\"")
+ target_compile_definitions("raylib" PUBLIC "MAX_KEY_PRESSED_QUEUE=16")
+ target_compile_definitions("raylib" PUBLIC "MAX_DECOMPRESSION_SIZE=64")
+
+ if (${GRAPHICS} MATCHES "GRAPHICS_API_OPENGL_33" OR ${GRAPHICS} MATCHES "GRAPHICS_API_OPENGL_11")
+ target_compile_definitions("raylib" PUBLIC "DEFAULT_BATCH_BUFFER_ELEMENTS=8192")
+ elseif (${GRAPHICS} MATCHES "GRAPHICS_API_OPENGL_ES2")
+ target_compile_definitions("raylib" PUBLIC "DEFAULT_BATCH_BUFFER_ELEMENTS=2048")
+ endif ()
+
+ target_compile_definitions("raylib" PUBLIC "DEFAULT_BATCH_DRAWCALLS=256")
+ target_compile_definitions("raylib" PUBLIC "MAX_MATRIX_STACK_SIZE=32")
+ target_compile_definitions("raylib" PUBLIC "MAX_SHADER_LOCATIONS=32")
+ target_compile_definitions("raylib" PUBLIC "MAX_MATERIAL_MAPS=12")
+ target_compile_definitions("raylib" PUBLIC "RL_CULL_DISTANCE_NEAR=0.01")
+ target_compile_definitions("raylib" PUBLIC "RL_CULL_DISTANCE_FAR=1000.0")
+
+ target_compile_definitions("raylib" PUBLIC "DEFAULT_SHADER_ATTRIB_NAME_POSITION=\"vertexPosition\"")
+ target_compile_definitions("raylib" PUBLIC "DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD=\"vertexTexCoord\"")
+ target_compile_definitions("raylib" PUBLIC "DEFAULT_SHADER_ATTRIB_NAME_NORMAL=\"vertexNormal\"")
+ target_compile_definitions("raylib" PUBLIC "DEFAULT_SHADER_ATTRIB_NAME_COLOR=\"vertexColor\"")
+ target_compile_definitions("raylib" PUBLIC "DEFAULT_SHADER_ATTRIB_NAME_TANGENT=\"vertexTangent\"")
+ target_compile_definitions("raylib" PUBLIC "DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2=\"vertexTexCoord2\"")
+
+ target_compile_definitions("raylib" PUBLIC "MAX_TEXT_BUFFER_LENGTH=1024")
+ target_compile_definitions("raylib" PUBLIC "MAX_TEXT_UNICODE_CHARS=512")
+ target_compile_definitions("raylib" PUBLIC "MAX_TEXTSPLIT_COUNT=128")
+
+ target_compile_definitions("raylib" PUBLIC "AUDIO_DEVICE_FORMAT=ma_format_f32")
+ target_compile_definitions("raylib" PUBLIC "AUDIO_DEVICE_CHANNELS=2")
+ target_compile_definitions("raylib" PUBLIC "AUDIO_DEVICE_SAMPLE_RATE=44100")
+ target_compile_definitions("raylib" PUBLIC "DEFAULT_AUDIO_BUFFER_SIZE=4096")
+
+ target_compile_definitions("raylib" PUBLIC "MAX_TRACELOG_MSG_LENGTH=128")
+ target_compile_definitions("raylib" PUBLIC "MAX_UWP_MESSAGES=512")
+endif ()
+
diff --git a/raylib/cmake/CompilerFlags.cmake b/raylib/cmake/CompilerFlags.cmake
new file mode 100644
index 0000000..5255534
--- /dev/null
+++ b/raylib/cmake/CompilerFlags.cmake
@@ -0,0 +1,83 @@
+include(AddIfFlagCompiles)
+
+# Makes +/- operations on void pointers be considered an error
+# https://gcc.gnu.org/onlinedocs/gcc/Pointer-Arith.html
+add_if_flag_compiles(-Werror=pointer-arith CMAKE_C_FLAGS)
+
+# Generates error whenever a function is used before being declared
+# https://gcc.gnu.org/onlinedocs/gcc-4.0.1/gcc/Warning-Options.html
+add_if_flag_compiles(-Werror=implicit-function-declaration CMAKE_C_FLAGS)
+
+# Allows some casting of pointers without generating a warning
+add_if_flag_compiles(-fno-strict-aliasing CMAKE_C_FLAGS)
+
+# Allows some casting of pointers without generating a warning
+add_if_flag_compiles(-O3 CMAKE_C_FLAGS)
+add_if_flag_compiles(-march=native CMAKE_C_FLAGS)
+
+if (ENABLE_MSAN AND ENABLE_ASAN)
+ # MSAN and ASAN both work on memory - ASAN does more things
+ MESSAGE(WARNING "Compiling with both AddressSanitizer and MemorySanitizer is not recommended")
+endif()
+
+if (ENABLE_ASAN)
+
+ # If enabled it would generate errors/warnings for all kinds of memory errors
+ # (like returning a stack variable by reference)
+ # https://clang.llvm.org/docs/AddressSanitizer.html
+
+ add_if_flag_compiles(-fno-omit-frame-pointer CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
+ add_if_flag_compiles(-fsanitize=address CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
+
+endif()
+
+if (ENABLE_UBSAN)
+
+ # If enabled this will generate errors for undefined behavior points
+ # (like adding +1 to the maximum int value)
+ # https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
+
+ add_if_flag_compiles(-fno-omit-frame-pointer CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
+ add_if_flag_compiles(-fsanitize=undefined CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
+
+endif()
+
+if (ENABLE_MSAN)
+
+ # If enabled this will generate warnings for places where uninitialized memory is used
+ # https://clang.llvm.org/docs/MemorySanitizer.html
+
+ add_if_flag_compiles(-fno-omit-frame-pointer CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
+ add_if_flag_compiles(-fsanitize=memory CMAKE_C_FLAGS CMAKE_LINKER_FLAGS)
+
+endif()
+
+if(CMAKE_VERSION VERSION_LESS "3.1")
+ if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ add_if_flag_compiles(-std=gnu99 CMAKE_C_FLAGS)
+ endif()
+else()
+ set (CMAKE_C_STANDARD 99)
+endif()
+
+if(${PLATFORM} MATCHES "Android")
+
+ # If enabled will remove dead code during the linking process
+ # https://gcc.gnu.org/onlinedocs/gnat_ugn/Compilation-options.html
+ add_if_flag_compiles(-ffunction-sections CMAKE_C_FLAGS)
+
+ # If enabled will generate some exception data (usually disabled for C programs)
+ # https://gcc.gnu.org/onlinedocs/gcc-4.2.4/gcc/Code-Gen-Options.html
+ add_if_flag_compiles(-funwind-tables CMAKE_C_FLAGS)
+
+ # If enabled adds stack protection guards around functions that allocate memory
+ # https://www.keil.com/support/man/docs/armclang_ref/armclang_ref_cjh1548250046139.htm
+ add_if_flag_compiles(-fstack-protector-strong CMAKE_C_FLAGS)
+
+ # Marks that the library will not be compiled with an executable stack
+ add_if_flag_compiles(-Wa,--noexecstack CMAKE_C_FLAGS)
+
+ # Do not expand symbolic links or resolve paths like "/./" or "/../", etc.
+ # https://gcc.gnu.org/onlinedocs/gcc/Directory-Options.html
+ add_if_flag_compiles(-no-canonical-prefixes CMAKE_C_FLAGS)
+endif()
diff --git a/raylib/cmake/EnumOption.cmake b/raylib/cmake/EnumOption.cmake
new file mode 100644
index 0000000..d7d343f
--- /dev/null
+++ b/raylib/cmake/EnumOption.cmake
@@ -0,0 +1,9 @@
+macro(enum_option var values description)
+ set(${var}_VALUES ${values})
+ list(GET ${var}_VALUES 0 default)
+ set(${var} "${default}" CACHE STRING "${description}")
+ set_property(CACHE ${var} PROPERTY STRINGS ${${var}_VALUES})
+ if (NOT ";${${var}_VALUES};" MATCHES ";${${var}};")
+ message(FATAL_ERROR "Unknown value ${${var}}. Only -D${var}=${${var}_VALUES} allowed.")
+ endif()
+endmacro()
diff --git a/raylib/cmake/GlfwImport.cmake b/raylib/cmake/GlfwImport.cmake
new file mode 100644
index 0000000..1b94cdf
--- /dev/null
+++ b/raylib/cmake/GlfwImport.cmake
@@ -0,0 +1,34 @@
+
+if(USE_EXTERNAL_GLFW STREQUAL "ON")
+ find_package(glfw3 3.3.3 REQUIRED)
+elseif(USE_EXTERNAL_GLFW STREQUAL "IF_POSSIBLE")
+ find_package(glfw3 3.3.3 QUIET)
+endif()
+if (glfw3_FOUND)
+ set(LIBS_PRIVATE ${LIBS_PRIVATE} glfw)
+endif()
+
+# Explicitly check against "ON", because USE_EXTERNAL_GLFW is a tristate option
+# Also adding only on desktop (web also uses glfw but it is more limited and is added using an emcc linker flag)
+if(NOT glfw3_FOUND AND NOT USE_EXTERNAL_GLFW STREQUAL "ON" AND "${PLATFORM}" MATCHES "Desktop")
+ MESSAGE(STATUS "Using raylib's GLFW")
+ set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
+ set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
+ set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
+ set(GLFW_INSTALL OFF CACHE BOOL "" FORCE)
+ set(GLFW_USE_WAYLAND ${USE_WAYLAND} CACHE BOOL "" FORCE)
+
+ set(WAS_SHARED ${BUILD_SHARED_LIBS})
+ set(BUILD_SHARED_LIBS OFF CACHE BOOL " " FORCE)
+
+ add_subdirectory(external/glfw)
+
+ set(BUILD_SHARED_LIBS ${WAS_SHARED} CACHE BOOL " " FORCE)
+ unset(WAS_SHARED)
+
+ list(APPEND raylib_sources $<TARGET_OBJECTS:glfw>)
+ include_directories(BEFORE SYSTEM external/glfw/include)
+else()
+ MESSAGE(STATUS "Using external GLFW")
+ set(GLFW_PKG_DEPS glfw3)
+endif()
diff --git a/raylib/cmake/InstallConfigurations.cmake b/raylib/cmake/InstallConfigurations.cmake
new file mode 100644
index 0000000..6a89ad5
--- /dev/null
+++ b/raylib/cmake/InstallConfigurations.cmake
@@ -0,0 +1,29 @@
+install(
+ TARGETS raylib EXPORT raylib-targets
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
+ PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
+)
+
+# PKG_CONFIG_LIBS_PRIVATE is used in raylib.pc.in
+if (NOT BUILD_SHARED_LIBS)
+ include(LibraryPathToLinkerFlags)
+ library_path_to_linker_flags(__PKG_CONFIG_LIBS_PRIVATE "${LIBS_PRIVATE}")
+ set(PKG_CONFIG_LIBS_PRIVATE ${__PKG_CONFIG_LIBS_PRIVATE} ${GLFW_PKG_LIBS})
+ string(REPLACE ";" " " PKG_CONFIG_LIBS_PRIVATE "${PKG_CONFIG_LIBS_PRIVATE}")
+elseif (BUILD_SHARED_LIBS)
+ set(PKG_CONFIG_LIBS_EXTRA "")
+endif ()
+
+join_paths(libdir_for_pc_file "\${exec_prefix}" "${CMAKE_INSTALL_LIBDIR}")
+join_paths(includedir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
+configure_file(../raylib.pc.in raylib.pc @ONLY)
+configure_file(../cmake/raylib-config-version.cmake raylib-config-version.cmake @ONLY)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/raylib.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/raylib-config-version.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/raylib")
+install(FILES ${PROJECT_SOURCE_DIR}/../cmake/raylib-config.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/raylib")
+
+# populates raylib_{FOUND, INCLUDE_DIRS, LIBRARIES, LDFLAGS, DEFINITIONS}
+include(PopulateConfigVariablesLocally)
+populate_config_variables_locally(raylib)
diff --git a/raylib/cmake/JoinPaths.cmake b/raylib/cmake/JoinPaths.cmake
new file mode 100644
index 0000000..1de3012
--- /dev/null
+++ b/raylib/cmake/JoinPaths.cmake
@@ -0,0 +1,26 @@
+# This module provides function for joining paths
+# known from most languages
+#
+# Original license:
+# SPDX-License-Identifier: (MIT OR CC0-1.0)
+# Explicit permission given to distribute this module under
+# the terms of the project as described in /LICENSE.rst.
+# Copyright 2020 Jan Tojnar
+# https://github.com/jtojnar/cmake-snips
+#
+# Modelled after Python’s os.path.join
+# https://docs.python.org/3.7/library/os.path.html#os.path.join
+# Windows not supported
+function(join_paths joined_path first_path_segment)
+ set(temp_path "${first_path_segment}")
+ foreach(current_segment IN LISTS ARGN)
+ if(NOT ("${current_segment}" STREQUAL ""))
+ if(IS_ABSOLUTE "${current_segment}")
+ set(temp_path "${current_segment}")
+ else()
+ set(temp_path "${temp_path}/${current_segment}")
+ endif()
+ endif()
+ endforeach()
+ set(${joined_path} "${temp_path}" PARENT_SCOPE)
+endfunction()
diff --git a/raylib/cmake/LibraryConfigurations.cmake b/raylib/cmake/LibraryConfigurations.cmake
new file mode 100644
index 0000000..9227aef
--- /dev/null
+++ b/raylib/cmake/LibraryConfigurations.cmake
@@ -0,0 +1,112 @@
+if (${PLATFORM} MATCHES "Desktop")
+ set(PLATFORM_CPP "PLATFORM_DESKTOP")
+
+ if (APPLE)
+ # Need to force OpenGL 3.3 on OS X
+ # See: https://github.com/raysan5/raylib/issues/341
+ set(GRAPHICS "GRAPHICS_API_OPENGL_33")
+ find_library(OPENGL_LIBRARY OpenGL)
+ set(LIBS_PRIVATE ${OPENGL_LIBRARY})
+ link_libraries("${LIBS_PRIVATE}")
+ if (NOT CMAKE_SYSTEM STRLESS "Darwin-18.0.0")
+ add_definitions(-DGL_SILENCE_DEPRECATION)
+ MESSAGE(AUTHOR_WARNING "OpenGL is deprecated starting with macOS 10.14 (Mojave)!")
+ endif ()
+ elseif (WIN32)
+ add_definitions(-D_CRT_SECURE_NO_WARNINGS)
+ find_package(OpenGL QUIET)
+ set(LIBS_PRIVATE ${OPENGL_LIBRARIES} winmm)
+ else ()
+ find_library(pthread NAMES pthread)
+ find_package(OpenGL QUIET)
+ if ("${OPENGL_LIBRARIES}" STREQUAL "")
+ set(OPENGL_LIBRARIES "GL")
+ endif ()
+
+ if ("${CMAKE_SYSTEM_NAME}" MATCHES "(Net|Open)BSD")
+ find_library(OSS_LIBRARY ossaudio)
+ endif ()
+
+ set(LIBS_PRIVATE m pthread ${OPENGL_LIBRARIES} ${OSS_LIBRARY})
+
+ if (USE_AUDIO)
+ set(LIBS_PRIVATE ${LIBS_PRIVATE} dl)
+ endif ()
+ endif ()
+
+elseif (${PLATFORM} MATCHES "Web")
+ set(PLATFORM_CPP "PLATFORM_WEB")
+ set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s USE_GLFW=3 -s ASSERTIONS=1 --profiling")
+ set(CMAKE_STATIC_LIBRARY_SUFFIX ".a")
+
+elseif (${PLATFORM} MATCHES "Android")
+ set(PLATFORM_CPP "PLATFORM_ANDROID")
+ set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
+ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+ set(raylib_sources "${raylib_sources} ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c")
+ add_definitions(-DANDROID -D__ANDROID_API__=21)
+ include_directories(${ANDROID_NDK}/sources/android/native_app_glue)
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--exclude-libs,libatomic.a -Wl,--build-id -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings -u ANativeActivity_onCreate -Wl,-undefined,dynamic_lookup")
+
+ find_library(OPENGL_LIBRARY OpenGL)
+ set(LIBS_PRIVATE m log android EGL GLESv2 OpenSLES atomic c)
+
+elseif (${PLATFORM} MATCHES "Raspberry Pi")
+ set(PLATFORM_CPP "PLATFORM_RPI")
+ set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
+
+ add_definitions(-D_DEFAULT_SOURCE)
+
+ find_library(GLESV2 brcmGLESv2 HINTS /opt/vc/lib)
+ find_library(EGL brcmEGL HINTS /opt/vc/lib)
+ find_library(BCMHOST bcm_host HINTS /opt/vc/lib)
+ include_directories(/opt/vc/include /opt/vc/include/interface/vmcs_host/linux /opt/vc/include/interface/vcos/pthreads)
+ link_directories(/opt/vc/lib)
+ set(LIBS_PRIVATE ${GLESV2} ${EGL} ${BCMHOST} pthread rt m dl)
+
+elseif (${PLATFORM} MATCHES "DRM")
+ set(PLATFORM_CPP "PLATFORM_DRM")
+ set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
+
+ add_definitions(-D_DEFAULT_SOURCE)
+ add_definitions(-DEGL_NO_X11)
+ add_definitions(-DPLATFORM_DRM)
+
+ find_library(GLESV2 GLESv2)
+ find_library(EGL EGL)
+ find_library(DRM drm)
+ find_library(GBM gbm)
+
+ if (NOT CMAKE_CROSSCOMPILING)
+ include_directories(/usr/include/libdrm)
+ endif ()
+ set(LIBS_PRIVATE ${GLESV2} ${EGL} ${DRM} ${GBM} pthread m dl)
+
+endif ()
+
+if (${OPENGL_VERSION})
+ set(${SUGGESTED_GRAPHICS} "${GRAPHICS}")
+ 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 ()
+ if ("${SUGGESTED_GRAPHICS}" AND NOT "${SUGGESTED_GRAPHICS}" STREQUAL "${GRAPHICS}")
+ message(WARNING "You are overriding the suggested GRAPHICS=${SUGGESTED_GRAPHICS} with ${GRAPHICS}! This may fail")
+ endif ()
+endif ()
+
+if (NOT GRAPHICS)
+ set(GRAPHICS "GRAPHICS_API_OPENGL_33")
+endif ()
+
+set(LIBS_PRIVATE ${LIBS_PRIVATE} ${OPENAL_LIBRARY})
+
+if (${PLATFORM} MATCHES "Desktop")
+ set(LIBS_PRIVATE ${LIBS_PRIVATE} glfw)
+endif ()
diff --git a/raylib/cmake/LibraryPathToLinkerFlags.cmake b/raylib/cmake/LibraryPathToLinkerFlags.cmake
new file mode 100644
index 0000000..05942b7
--- /dev/null
+++ b/raylib/cmake/LibraryPathToLinkerFlags.cmake
@@ -0,0 +1,24 @@
+function(library_path_to_linker_flags LD_FLAGS LIB_PATHS)
+ foreach(L ${LIB_PATHS})
+ get_filename_component(DIR ${L} PATH)
+ get_filename_component(LIBFILE ${L} NAME_WE)
+ STRING(REGEX REPLACE "^lib" "" FILE ${LIBFILE})
+
+ if (${L} MATCHES "[.]framework$")
+ set(FILE_OPT "-framework ${FILE}")
+ set(DIR_OPT "-F${DIR}")
+ else()
+ set(FILE_OPT "-l${FILE}")
+ set(DIR_OPT "-L${DIR}")
+ endif()
+
+ if ("${DIR}" STREQUAL "" OR "${DIR}" STREQUAL "${LASTDIR}")
+ set (DIR_OPT "")
+ endif()
+
+ set(LASTDIR ${DIR})
+
+ set(${LD_FLAGS} ${${LD_FLAGS}} ${DIR_OPT} ${FILE_OPT} PARENT_SCOPE)
+ string (REPLACE ";" " " ${LD_FLAGS} "${${LD_FLAGS}}")
+ endforeach()
+endfunction()
diff --git a/raylib/cmake/PackConfigurations.cmake b/raylib/cmake/PackConfigurations.cmake
new file mode 100644
index 0000000..74eded0
--- /dev/null
+++ b/raylib/cmake/PackConfigurations.cmake
@@ -0,0 +1,13 @@
+# Packaging
+SET(CPACK_PACKAGE_NAME "raylib")
+SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Simple and easy-to-use library to enjoy videogames programming")
+SET(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
+SET(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
+SET(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
+SET(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
+SET(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/../README.md")
+SET(CPACK_RESOURCE_FILE_WELCOME "${PROJECT_SOURCE_DIR}/../README.md")
+SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/../LICENSE")
+SET(CPACK_PACKAGE_FILE_NAME "raylib-${PROJECT_VERSION}$ENV{RAYLIB_PACKAGE_SUFFIX}")
+SET(CPACK_GENERATOR "ZIP;TGZ") # Remove this, if you want the NSIS installer on Windows
+include(CPack) \ No newline at end of file
diff --git a/raylib/cmake/PopulateConfigVariablesLocally.cmake b/raylib/cmake/PopulateConfigVariablesLocally.cmake
new file mode 100644
index 0000000..151070e
--- /dev/null
+++ b/raylib/cmake/PopulateConfigVariablesLocally.cmake
@@ -0,0 +1,11 @@
+macro(populate_config_variables_locally target)
+ get_property(raylib_INCLUDE_DIRS TARGET ${target} PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
+ #get_property(raylib_LIBRARIES TARGET ${target} PROPERTY LOCATION) # only works for SHARED
+ get_property(raylib_LDFLAGS TARGET ${target} PROPERTY INTERFACE_LINK_LIBRARIES)
+ get_property(raylib_DEFINITIONS TARGET ${target} PROPERTY DEFINITIONS)
+
+ set(raylib_INCLUDE_DIRS "${raylib_INCLUDE_DIRS}" PARENT_SCOPE)
+ #set(raylib_LIBRARIES "${raylib_INCLUDE_DIRS}" PARENT_SCOPE)
+ set(raylib_LDFLAGS "${raylib_LDFLAGS}" PARENT_SCOPE)
+ set(raylib_DEFINITIONS "${raylib_DEFINITIONS}" PARENT_SCOPE)
+endmacro()
diff --git a/raylib/cmake/raylib-config-version.cmake b/raylib/cmake/raylib-config-version.cmake
new file mode 100644
index 0000000..74fd03c
--- /dev/null
+++ b/raylib/cmake/raylib-config-version.cmake
@@ -0,0 +1,21 @@
+set(PACKAGE_VERSION "@PROJECT_VERSION@")
+
+if(PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION)
+ set(PACKAGE_VERSION_EXACT TRUE)
+endif()
+if(NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION)
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+else(NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION)
+ set(PACKAGE_VERSION_UNSUITABLE TRUE)
+endif(NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION)
+
+# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
+if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "@CMAKE_SIZEOF_VOID_P@" STREQUAL "")
+ return()
+endif()
+
+if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "@CMAKE_SIZEOF_VOID_P@")
+ math(EXPR installedBits "8 * 8")
+ set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
+ set(PACKAGE_VERSION_UNSUITABLE TRUE)
+endif()
diff --git a/raylib/cmake/raylib-config.cmake b/raylib/cmake/raylib-config.cmake
new file mode 100644
index 0000000..0af5306
--- /dev/null
+++ b/raylib/cmake/raylib-config.cmake
@@ -0,0 +1,77 @@
+# - Try to find raylib
+# Options:
+# raylib_USE_STATIC_LIBS - OFF by default
+# raylib_VERBOSE - OFF by default
+# Once done, this defines a raylib target that can be passed to
+# target_link_libraries as well as following variables:
+#
+# raylib_FOUND - System has raylib installed
+# raylib_INCLUDE_DIRS - The include directories for the raylib header(s)
+# raylib_LIBRARIES - The libraries needed to use raylib
+# raylib_LDFLAGS - The linker flags needed with raylib
+# raylib_DEFINITIONS - Compiler switches required for using raylib
+
+set(XPREFIX PC_RAYLIB)
+
+find_package(PkgConfig QUIET)
+pkg_check_modules(${XPREFIX} QUIET raylib)
+
+if (raylib_USE_STATIC_LIBS)
+ set(XPREFIX ${XPREFIX}_STATIC)
+endif()
+
+set(raylib_DEFINITIONS ${${XPREFIX}_CFLAGS})
+
+find_path(raylib_INCLUDE_DIR
+ NAMES raylib.h
+ HINTS ${${XPREFIX}_INCLUDE_DIRS}
+)
+
+set(RAYLIB_NAMES raylib)
+
+if (raylib_USE_STATIC_LIBS)
+ set(RAYLIB_NAMES libraylib.a raylib.lib ${RAYLIB_NAMES})
+endif()
+
+find_library(raylib_LIBRARY
+ NAMES ${RAYLIB_NAMES}
+ HINTS ${${XPREFIX}_LIBRARY_DIRS}
+)
+
+set(raylib_LIBRARIES ${raylib_LIBRARY})
+set(raylib_LIBRARY_DIRS ${${XPREFIX}_LIBRARY_DIRS})
+set(raylib_LIBRARY_DIR ${raylib_LIBRARY_DIRS})
+set(raylib_INCLUDE_DIRS ${raylib_INCLUDE_DIR})
+set(raylib_LDFLAGS ${${XPREFIX}_LDFLAGS})
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(raylib DEFAULT_MSG
+ raylib_LIBRARY
+ raylib_INCLUDE_DIR
+)
+
+mark_as_advanced(raylib_LIBRARY raylib_INCLUDE_DIR)
+
+if (raylib_USE_STATIC_LIBS)
+ add_library(raylib STATIC IMPORTED GLOBAL)
+else()
+ add_library(raylib SHARED IMPORTED GLOBAL)
+endif()
+string (REPLACE ";" " " raylib_LDFLAGS "${raylib_LDFLAGS}")
+
+set_target_properties(raylib
+ PROPERTIES
+ IMPORTED_LOCATION "${raylib_LIBRARIES}"
+ IMPORTED_IMPLIB "${raylib_LIBRARIES}"
+ INTERFACE_INCLUDE_DIRECTORIES "${raylib_INCLUDE_DIRS}"
+ INTERFACE_LINK_LIBRARIES "${raylib_LDFLAGS}"
+ INTERFACE_COMPILE_OPTIONS "${raylib_DEFINITIONS}"
+)
+
+if (raylib_VERBOSE)
+ message(STATUS "raylib_FOUND: ${raylib_FOUND}")
+ message(STATUS "raylib_INCLUDE_DIRS: ${raylib_INCLUDE_DIRS}")
+ message(STATUS "raylib_LIBRARIES: ${raylib_LIBRARIES}")
+ message(STATUS "raylib_LDFLAGS: ${raylib_LDFLAGS}")
+ message(STATUS "raylib_DEFINITIONS: ${raylib_DEFINITIONS}")
+endif()