Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

88 linhas
2.7 KiB

  1. # All sorts of things that we need cross project
  2. cmake_minimum_required(VERSION 2.8.0)
  3. set(USE_EXTERNAL_GLFW OFF CACHE STRING "Link raylib against system GLFW instead of embedded one")
  4. set_property(CACHE USE_EXTERNAL_GLFW PROPERTY STRINGS ON OFF IF_POSSIBLE)
  5. # Linking for OS X -framework options
  6. # Will do nothing on other OSes
  7. if(APPLE)
  8. find_library(OPENGL_LIBRARY OpenGL)
  9. find_library(COCOA_LIBRARY Cocoa)
  10. find_library(IOKIT_LIBRARY IOKit)
  11. find_library(COREFOUNDATION_LIBRARY CoreFoundation)
  12. find_library(COREVIDEO_LIBRARY CoreVideo)
  13. set(LIBS_PRIVATE ${OPENGL_LIBRARY} ${COCOA_LIBRARY}
  14. ${IOKIT_LIBRARY} ${COREFOUNDATION_LIBRARY} ${COREVIDEO_LIBRARY})
  15. elseif(WIN32)
  16. # no pkg-config --static on Windows yet...
  17. else()
  18. find_library(pthread NAMES pthread)
  19. find_package(OpenGL)
  20. if ("${OPENGL_LIBRARIES}" STREQUAL "")
  21. # CFLAGS=-m32 cmake on Linux fails for some reason, so fallback to hardcoding
  22. set(LIBS_PRIVATE m pthread GL X11 Xrandr Xinerama Xi Xxf86vm Xcursor)
  23. else()
  24. find_package(X11 REQUIRED X11)
  25. find_library(XRANDR_LIBRARY Xrandr)
  26. find_library(XI_LIBRARY Xi)
  27. find_library(XINERAMA_LIBRARY Xinerama)
  28. find_library(XXF86VM_LIBRARY Xxf86vm)
  29. find_library(XCURSOR_LIBRARY Xcursor)
  30. include_directories(${OPENGL_INCLUDE_DIR})
  31. set(LIBS_PRIVATE m ${pthread} ${OPENGL_LIBRARIES} ${X11_LIBRARIES} ${XRANDR_LIBRARY} ${XINERAMA_LIBRARY} ${XI_LIBRARY} ${XXF86VM_LIBRARY} ${XCURSOR_LIBRARY})
  32. endif()
  33. endif()
  34. if(USE_EXTERNAL_GLFW STREQUAL "ON")
  35. find_package(glfw3 3.2.1 REQUIRED)
  36. elseif(USE_EXTERNAL_GLFW STREQUAL "IF_POSSIBLE")
  37. find_package(glfw3 3.2.1)
  38. endif()
  39. if (glfw3_FOUND)
  40. set(LIBS_PRIVATE ${LIBS_PRIVATE} glfw)
  41. endif()
  42. if(CMAKE_SYSTEM_NAME STREQUAL Linux)
  43. set(LINUX TRUE)
  44. set(LIBS_PRIVATE dl ${LIBS_PRIVATE})
  45. endif()
  46. foreach(L ${LIBS_PRIVATE})
  47. get_filename_component(DIR ${L} PATH)
  48. get_filename_component(LIBFILE ${L} NAME_WE)
  49. STRING(REGEX REPLACE "^lib" "" FILE ${LIBFILE})
  50. if (${L} MATCHES "[.]framework$")
  51. set(FILE_OPT "-framework ${FILE}")
  52. set(DIR_OPT "-F${DIR}")
  53. else()
  54. set(FILE_OPT "-l${FILE}")
  55. set(DIR_OPT "-L${DIR}")
  56. endif()
  57. if ("${DIR}" STREQUAL "" OR "${DIR}" STREQUAL "${LASTDIR}")
  58. set (DIR_OPT "")
  59. endif()
  60. set(LASTDIR ${DIR})
  61. set(PKG_CONFIG_LIBS_PRIVATE ${PKG_CONFIG_LIBS_PRIVATE} ${DIR_OPT} ${FILE_OPT})
  62. string (REPLACE ";" " " PKG_CONFIG_LIBS_PRIVATE "${PKG_CONFIG_LIBS_PRIVATE}")
  63. endforeach(L)
  64. # Do the linking for executables that are meant to link raylib
  65. function(link_libraries_to_executable executable)
  66. # Link raylib
  67. if (TARGET raylib_shared)
  68. target_link_libraries(${executable} raylib_shared)
  69. else()
  70. target_link_libraries(${executable} raylib ${PKG_CONFIG_LIBS_PRIVATE})
  71. endif()
  72. endfunction()