aboutsummaryrefslogtreecommitdiff
path: root/utils.cmake
diff options
context:
space:
mode:
authorRay <raysan5@gmail.com>2017-08-27 20:59:55 +0200
committerGitHub <noreply@github.com>2017-08-27 20:59:55 +0200
commitb951f8700e8ee2b456a3daf9974d679286bbf26f (patch)
tree07105964919c99674aab2b9e6459ab2639b365c8 /utils.cmake
parent0fc1323c80c2501c36741c05fd771ac1d001d049 (diff)
parent958fed26c9249b283cca4252827bab46e6736bdb (diff)
downloadraylib-b951f8700e8ee2b456a3daf9974d679286bbf26f.tar.gz
raylib-b951f8700e8ee2b456a3daf9974d679286bbf26f.zip
Merge pull request #349 from raysan5/master
Integrate master changes into develop branch
Diffstat (limited to 'utils.cmake')
-rw-r--r--utils.cmake49
1 files changed, 49 insertions, 0 deletions
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()
+