2022-12-11 15:37:38 +03:00
|
|
|
# Set OpenGL_GL_PREFERENCE to new "GLVND" even when legacy library exists and
|
|
|
|
# cmake is <= 3.10
|
|
|
|
#
|
|
|
|
# See https://cmake.org/cmake/help/latest/policy/CMP0072.html for more
|
|
|
|
# information.
|
|
|
|
if(POLICY CMP0072)
|
|
|
|
cmake_policy(SET CMP0072 NEW)
|
|
|
|
endif()
|
|
|
|
|
2021-01-26 16:34:27 +03:00
|
|
|
if (${PLATFORM} MATCHES "Desktop")
|
2021-01-14 01:10:02 +03:00
|
|
|
set(PLATFORM_CPP "PLATFORM_DESKTOP")
|
2022-08-09 10:52:56 +03:00
|
|
|
|
2021-01-26 16:34:27 +03:00
|
|
|
if (APPLE)
|
2021-01-14 01:10:02 +03:00
|
|
|
# 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)!")
|
2021-01-26 16:34:27 +03:00
|
|
|
endif ()
|
|
|
|
elseif (WIN32)
|
2021-01-14 01:10:02 +03:00
|
|
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
2021-09-10 21:31:36 +03:00
|
|
|
find_package(OpenGL QUIET)
|
|
|
|
set(LIBS_PRIVATE ${OPENGL_LIBRARIES} winmm)
|
2023-05-28 12:33:14 +03:00
|
|
|
elseif (UNIX)
|
|
|
|
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})
|
2021-01-26 16:34:27 +03:00
|
|
|
else ()
|
2021-01-14 01:10:02 +03:00
|
|
|
find_library(pthread NAMES pthread)
|
|
|
|
find_package(OpenGL QUIET)
|
|
|
|
if ("${OPENGL_LIBRARIES}" STREQUAL "")
|
|
|
|
set(OPENGL_LIBRARIES "GL")
|
2021-01-26 16:34:27 +03:00
|
|
|
endif ()
|
2024-02-27 15:08:16 +03:00
|
|
|
|
2023-05-28 15:49:33 +03:00
|
|
|
set(LIBS_PRIVATE m atomic pthread ${OPENGL_LIBRARIES} ${OSS_LIBRARY})
|
2022-08-09 10:52:56 +03:00
|
|
|
|
2021-01-14 01:10:02 +03:00
|
|
|
if ("${CMAKE_SYSTEM_NAME}" MATCHES "(Net|Open)BSD")
|
|
|
|
find_library(OSS_LIBRARY ossaudio)
|
2023-05-28 15:49:33 +03:00
|
|
|
set(LIBS_PRIVATE m pthread ${OPENGL_LIBRARIES} ${OSS_LIBRARY})
|
2021-01-26 16:34:27 +03:00
|
|
|
endif ()
|
2022-08-09 10:52:56 +03:00
|
|
|
|
2023-05-28 15:49:33 +03:00
|
|
|
if (NOT "${CMAKE_SYSTEM_NAME}" MATCHES "(Net|Open)BSD" AND USE_AUDIO)
|
2022-02-05 15:33:05 +03:00
|
|
|
set(LIBS_PRIVATE ${LIBS_PRIVATE} dl)
|
|
|
|
endif ()
|
2021-01-26 16:34:27 +03:00
|
|
|
endif ()
|
2021-01-14 01:10:02 +03:00
|
|
|
|
2021-01-26 16:34:27 +03:00
|
|
|
elseif (${PLATFORM} MATCHES "Web")
|
2021-01-14 01:10:02 +03:00
|
|
|
set(PLATFORM_CPP "PLATFORM_WEB")
|
2024-06-21 10:07:01 +03:00
|
|
|
if(NOT GRAPHICS)
|
|
|
|
set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
|
|
|
|
endif()
|
2021-01-14 01:10:02 +03:00
|
|
|
set(CMAKE_STATIC_LIBRARY_SUFFIX ".a")
|
|
|
|
|
2021-01-26 16:34:27 +03:00
|
|
|
elseif (${PLATFORM} MATCHES "Android")
|
2021-01-14 01:10:02 +03:00
|
|
|
set(PLATFORM_CPP "PLATFORM_ANDROID")
|
|
|
|
set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
|
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
2022-05-20 18:21:45 +03:00
|
|
|
list(APPEND raylib_sources ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c)
|
2022-01-08 22:14:10 +03:00
|
|
|
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")
|
2022-08-09 10:52:56 +03:00
|
|
|
|
2021-01-14 01:10:02 +03:00
|
|
|
find_library(OPENGL_LIBRARY OpenGL)
|
|
|
|
set(LIBS_PRIVATE m log android EGL GLESv2 OpenSLES atomic c)
|
|
|
|
|
2022-08-09 10:52:56 +03:00
|
|
|
elseif ("${PLATFORM}" MATCHES "DRM")
|
2021-01-14 01:10:02 +03:00
|
|
|
set(PLATFORM_CPP "PLATFORM_DRM")
|
|
|
|
set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
|
2022-08-09 10:52:56 +03:00
|
|
|
|
2021-01-14 01:10:02 +03:00
|
|
|
add_definitions(-D_DEFAULT_SOURCE)
|
|
|
|
add_definitions(-DEGL_NO_X11)
|
|
|
|
add_definitions(-DPLATFORM_DRM)
|
2022-08-09 10:52:56 +03:00
|
|
|
|
2021-01-14 01:10:02 +03:00
|
|
|
find_library(GLESV2 GLESv2)
|
|
|
|
find_library(EGL EGL)
|
|
|
|
find_library(DRM drm)
|
|
|
|
find_library(GBM gbm)
|
2022-08-09 10:52:56 +03:00
|
|
|
|
2024-02-27 15:08:16 +03:00
|
|
|
if (NOT CMAKE_CROSSCOMPILING OR NOT CMAKE_SYSROOT)
|
2021-04-09 20:57:14 +03:00
|
|
|
include_directories(/usr/include/libdrm)
|
|
|
|
endif ()
|
2022-06-24 11:50:24 +03:00
|
|
|
set(LIBS_PRIVATE ${GLESV2} ${EGL} ${DRM} ${GBM} atomic pthread m dl)
|
2021-01-14 01:10:02 +03:00
|
|
|
|
2024-02-23 01:05:41 +03:00
|
|
|
elseif ("${PLATFORM}" MATCHES "SDL")
|
|
|
|
find_package(SDL2 REQUIRED)
|
|
|
|
set(PLATFORM_CPP "PLATFORM_DESKTOP_SDL")
|
|
|
|
set(LIBS_PRIVATE SDL2::SDL2)
|
|
|
|
|
2021-01-26 16:34:27 +03:00
|
|
|
endif ()
|
2021-01-14 01:10:02 +03:00
|
|
|
|
2023-07-13 22:20:06 +03:00
|
|
|
if (NOT ${OPENGL_VERSION} MATCHES "OFF")
|
2024-10-04 12:08:12 +03:00
|
|
|
set(SUGGESTED_GRAPHICS "${GRAPHICS}")
|
|
|
|
|
2022-04-05 10:59:53 +03:00
|
|
|
if (${OPENGL_VERSION} MATCHES "4.3")
|
2024-10-04 12:08:12 +03:00
|
|
|
set(GRAPHICS "GRAPHICS_API_OPENGL_43")
|
2022-04-05 10:59:53 +03:00
|
|
|
elseif (${OPENGL_VERSION} MATCHES "3.3")
|
2021-01-14 01:10:02 +03:00
|
|
|
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")
|
2023-11-07 10:41:15 +03:00
|
|
|
elseif (${OPENGL_VERSION} MATCHES "ES 3.0")
|
|
|
|
set(GRAPHICS "GRAPHICS_API_OPENGL_ES3")
|
2021-01-26 16:34:27 +03:00
|
|
|
endif ()
|
2024-10-04 12:08:12 +03:00
|
|
|
if (NOT "${SUGGESTED_GRAPHICS}" STREQUAL "" AND NOT "${SUGGESTED_GRAPHICS}" STREQUAL "${GRAPHICS}")
|
|
|
|
message(WARNING "You are overriding the suggested GRAPHICS=${SUGGESTED_GRAPHICS} with ${GRAPHICS}! This may fail.")
|
2021-01-26 16:34:27 +03:00
|
|
|
endif ()
|
|
|
|
endif ()
|
2021-01-14 01:10:02 +03:00
|
|
|
|
2021-01-26 16:34:27 +03:00
|
|
|
if (NOT GRAPHICS)
|
2021-01-14 01:10:02 +03:00
|
|
|
set(GRAPHICS "GRAPHICS_API_OPENGL_33")
|
2021-01-26 16:34:27 +03:00
|
|
|
endif ()
|
|
|
|
|
|
|
|
set(LIBS_PRIVATE ${LIBS_PRIVATE} ${OPENAL_LIBRARY})
|
|
|
|
|
|
|
|
if (${PLATFORM} MATCHES "Desktop")
|
|
|
|
set(LIBS_PRIVATE ${LIBS_PRIVATE} glfw)
|
2021-04-09 20:57:14 +03:00
|
|
|
endif ()
|