Browse Source

Merge branch 'master' of https://github.com/raysan5/raylib

Ray 3 years ago
parent
commit
ddb8be3564
3 changed files with 32 additions and 20 deletions
  1. 12 0
      CMakeLists.txt
  2. 10 10
      cmake/LibraryConfigurations.cmake
  3. 10 10
      examples/CMakeLists.txt

+ 12 - 0
CMakeLists.txt

@@ -1,6 +1,18 @@
 cmake_minimum_required(VERSION 3.0)
 cmake_minimum_required(VERSION 3.0)
 project(raylib)
 project(raylib)
 
 
+# Avoid excessive expansion of variables in conditionals. In particular, if
+# "PLATFORM" is "DRM" than:
+#
+# if (${PLATFORM} MATCHES "DRM")
+#
+# may expand e.g to:
+#
+# if (/usr/lib/aarch64-linux-gnu/libdrm.so MATCHES "DRM")
+#
+# See https://cmake.org/cmake/help/latest/policy/CMP0054.html
+cmake_policy(SET CMP0054 NEW)
+
 # Directory for easier includes
 # Directory for easier includes
 # Anywhere you see include(...) you can check <root>/cmake for that file
 # Anywhere you see include(...) you can check <root>/cmake for that file
 set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
 set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

+ 10 - 10
cmake/LibraryConfigurations.cmake

@@ -1,6 +1,6 @@
 if (${PLATFORM} MATCHES "Desktop")
 if (${PLATFORM} MATCHES "Desktop")
     set(PLATFORM_CPP "PLATFORM_DESKTOP")
     set(PLATFORM_CPP "PLATFORM_DESKTOP")
-    
+
     if (APPLE)
     if (APPLE)
         # Need to force OpenGL 3.3 on OS X
         # Need to force OpenGL 3.3 on OS X
         # See: https://github.com/raysan5/raylib/issues/341
         # See: https://github.com/raysan5/raylib/issues/341
@@ -22,11 +22,11 @@ if (${PLATFORM} MATCHES "Desktop")
         if ("${OPENGL_LIBRARIES}" STREQUAL "")
         if ("${OPENGL_LIBRARIES}" STREQUAL "")
             set(OPENGL_LIBRARIES "GL")
             set(OPENGL_LIBRARIES "GL")
         endif ()
         endif ()
-        
+
         if ("${CMAKE_SYSTEM_NAME}" MATCHES "(Net|Open)BSD")
         if ("${CMAKE_SYSTEM_NAME}" MATCHES "(Net|Open)BSD")
             find_library(OSS_LIBRARY ossaudio)
             find_library(OSS_LIBRARY ossaudio)
         endif ()
         endif ()
-        
+
         set(LIBS_PRIVATE m atomic pthread ${OPENGL_LIBRARIES} ${OSS_LIBRARY})
         set(LIBS_PRIVATE m atomic pthread ${OPENGL_LIBRARIES} ${OSS_LIBRARY})
 
 
         if (USE_AUDIO)
         if (USE_AUDIO)
@@ -48,16 +48,16 @@ elseif (${PLATFORM} MATCHES "Android")
     add_definitions(-DANDROID -D__ANDROID_API__=21)
     add_definitions(-DANDROID -D__ANDROID_API__=21)
     include_directories(${ANDROID_NDK}/sources/android/native_app_glue)
     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")
     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)
     find_library(OPENGL_LIBRARY OpenGL)
     set(LIBS_PRIVATE m log android EGL GLESv2 OpenSLES atomic c)
     set(LIBS_PRIVATE m log android EGL GLESv2 OpenSLES atomic c)
 
 
 elseif (${PLATFORM} MATCHES "Raspberry Pi")
 elseif (${PLATFORM} MATCHES "Raspberry Pi")
     set(PLATFORM_CPP "PLATFORM_RPI")
     set(PLATFORM_CPP "PLATFORM_RPI")
     set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
     set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
-    
+
     add_definitions(-D_DEFAULT_SOURCE)
     add_definitions(-D_DEFAULT_SOURCE)
-    
+
     find_library(GLESV2 brcmGLESv2 HINTS /opt/vc/lib)
     find_library(GLESV2 brcmGLESv2 HINTS /opt/vc/lib)
     find_library(EGL brcmEGL HINTS /opt/vc/lib)
     find_library(EGL brcmEGL HINTS /opt/vc/lib)
     find_library(BCMHOST bcm_host HINTS /opt/vc/lib)
     find_library(BCMHOST bcm_host HINTS /opt/vc/lib)
@@ -65,19 +65,19 @@ elseif (${PLATFORM} MATCHES "Raspberry Pi")
     link_directories(/opt/vc/lib)
     link_directories(/opt/vc/lib)
     set(LIBS_PRIVATE ${GLESV2} ${EGL} ${BCMHOST} pthread rt m dl)
     set(LIBS_PRIVATE ${GLESV2} ${EGL} ${BCMHOST} pthread rt m dl)
 
 
-elseif (${PLATFORM} MATCHES "DRM")
+elseif ("${PLATFORM}" MATCHES "DRM")
     set(PLATFORM_CPP "PLATFORM_DRM")
     set(PLATFORM_CPP "PLATFORM_DRM")
     set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
     set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
-    
+
     add_definitions(-D_DEFAULT_SOURCE)
     add_definitions(-D_DEFAULT_SOURCE)
     add_definitions(-DEGL_NO_X11)
     add_definitions(-DEGL_NO_X11)
     add_definitions(-DPLATFORM_DRM)
     add_definitions(-DPLATFORM_DRM)
-    
+
     find_library(GLESV2 GLESv2)
     find_library(GLESV2 GLESv2)
     find_library(EGL EGL)
     find_library(EGL EGL)
     find_library(DRM drm)
     find_library(DRM drm)
     find_library(GBM gbm)
     find_library(GBM gbm)
-    
+
     if (NOT CMAKE_CROSSCOMPILING)
     if (NOT CMAKE_CROSSCOMPILING)
         include_directories(/usr/include/libdrm)
         include_directories(/usr/include/libdrm)
     endif ()
     endif ()

+ 10 - 10
examples/CMakeLists.txt

@@ -52,7 +52,7 @@ foreach (example_dir ${example_dirs})
     # Get the .c files
     # Get the .c files
     file(GLOB sources ${example_dir}/*.c)
     file(GLOB sources ${example_dir}/*.c)
     list(APPEND example_sources ${sources})
     list(APPEND example_sources ${sources})
-    
+
     # Any any resources
     # Any any resources
     file(GLOB resources ${example_dir}/resources/*)
     file(GLOB resources ${example_dir}/resources/*)
     list(APPEND example_resources ${resources})
     list(APPEND example_resources ${resources})
@@ -71,7 +71,7 @@ if (${PLATFORM} MATCHES "Android")
     list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_3d_camera_free.c)
     list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_3d_camera_free.c)
     list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_3d_camera_first_person.c)
     list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_3d_camera_first_person.c)
     list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_world_screen.c)
     list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_world_screen.c)
-    
+
     list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_mesh_picking.c)
     list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_mesh_picking.c)
     list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_cubicmap.c)
     list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_cubicmap.c)
     list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_skybox.c)
     list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_skybox.c)
@@ -86,8 +86,8 @@ if (${PLATFORM} MATCHES "Android")
     list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_animation.c)
     list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_animation.c)
     list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_first_person_maze.c)
     list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_first_person_maze.c)
 	list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_magicavoxel_loading.c)
 	list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_magicavoxel_loading.c)
-    
-	
+
+
     list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_custom_uniform.c)
     list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_custom_uniform.c)
     list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_model_shader.c)
     list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_model_shader.c)
     list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_postprocessing.c)
     list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_postprocessing.c)
@@ -101,13 +101,13 @@ elseif (${PLATFORM} MATCHES "Web")
     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s ALLOW_MEMORY_GROWTH=1 --no-heap-copy")
     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s ALLOW_MEMORY_GROWTH=1 --no-heap-copy")
     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --shell-file ${CMAKE_SOURCE_DIR}/src/shell.html")
     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --shell-file ${CMAKE_SOURCE_DIR}/src/shell.html")
     set(CMAKE_EXECUTABLE_SUFFIX ".html")
     set(CMAKE_EXECUTABLE_SUFFIX ".html")
-    
+
     # Remove the -rdynamic flag because otherwise emscripten
     # Remove the -rdynamic flag because otherwise emscripten
     # does not generate HTML+JS+WASM files, only a non-working
     # does not generate HTML+JS+WASM files, only a non-working
     # and fat HTML
     # and fat HTML
     string(REPLACE "-rdynamic" "" CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS}")
     string(REPLACE "-rdynamic" "" CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS}")
 
 
-elseif (${PLATFORM} STREQUAL "DRM")
+elseif ("${PLATFORM}" STREQUAL "DRM")
     list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/rlgl_standalone.c)
     list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/rlgl_standalone.c)
     list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/raylib_opengl_interop.c)
     list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/raylib_opengl_interop.c)
 
 
@@ -124,15 +124,15 @@ foreach (example_source ${example_sources})
     # Create the basename for the example
     # Create the basename for the example
     get_filename_component(example_name ${example_source} NAME)
     get_filename_component(example_name ${example_source} NAME)
     string(REPLACE ".c" "" example_name ${example_name})
     string(REPLACE ".c" "" example_name ${example_name})
-    
+
     # Setup the example
     # Setup the example
     add_executable(${example_name} ${example_source})
     add_executable(${example_name} ${example_source})
-    
+
     target_link_libraries(${example_name} raylib)
     target_link_libraries(${example_name} raylib)
-    
+
     string(REGEX MATCH ".*/.*/" resources_dir ${example_source})
     string(REGEX MATCH ".*/.*/" resources_dir ${example_source})
     string(APPEND resources_dir "resources")
     string(APPEND resources_dir "resources")
-    
+
     if (${PLATFORM} MATCHES "Web" AND EXISTS ${resources_dir})
     if (${PLATFORM} MATCHES "Web" AND EXISTS ${resources_dir})
         # The local resources path needs to be mapped to /resources virtual path
         # The local resources path needs to be mapped to /resources virtual path
         string(APPEND resources_dir "@resources")
         string(APPEND resources_dir "@resources")