You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.3 KiB

  1. # All sorts of things that we need cross project
  2. cmake_minimum_required(VERSION 3.0)
  3. # Detect linux
  4. if(UNIX AND NOT APPLE)
  5. set(LINUX TRUE)
  6. endif()
  7. # Need GLFW 3.2.1
  8. find_package(glfw3 3.2.1 REQUIRED)
  9. # Linking for OS X -framework options
  10. # Will do nothing on other OSes
  11. function(link_os_x_frameworks binary)
  12. if(APPLE)
  13. find_library(OPENGL_LIBRARY OpenGL)
  14. find_library(OPENAL_LIBRARY OpenAL)
  15. find_library(COCOA_LIBRARY Cocoa)
  16. set(OSX_FRAMEWORKS ${OPENGL_LIBRARY} ${OPENAL_LIBRARY} ${COCOA_LIBRARY})
  17. target_link_libraries(${binary} ${OSX_FRAMEWORKS})
  18. endif()
  19. endfunction()
  20. # Do the linking for executables that are meant to link raylib
  21. function(link_libraries_to_executable executable)
  22. # Link the libraries
  23. if(APPLE)
  24. # OS X, we use frameworks
  25. link_os_x_frameworks(${executable})
  26. elseif(LINUX)
  27. # Elsewhere (such as Linux), need `-lopenal -lGL`, etc...
  28. target_link_libraries(${executable} m pthread dl)
  29. target_link_libraries(${executable} openal)
  30. target_link_libraries(${executable} GL)
  31. target_link_libraries(${executable} X11 Xrandr Xinerama Xi Xxf86vm Xcursor) # X11 stuff
  32. else()
  33. # TODO windows
  34. endif()
  35. # Add in GLFW as a linking target
  36. target_link_libraries(${executable} glfw)
  37. # And raylib
  38. target_link_libraries(${executable} raylib)
  39. endfunction()