2017-07-23 02:45:36 +03:00
|
|
|
# All sorts of things that we need cross project
|
2018-01-27 04:00:40 +03:00
|
|
|
cmake_minimum_required(VERSION 2.8.0)
|
2017-07-23 02:45:36 +03:00
|
|
|
|
|
|
|
# Linking for OS X -framework options
|
|
|
|
# Will do nothing on other OSes
|
2017-10-11 23:33:09 +03:00
|
|
|
if(APPLE)
|
|
|
|
find_library(OPENGL_LIBRARY OpenGL)
|
|
|
|
find_library(COCOA_LIBRARY Cocoa)
|
2017-11-25 22:27:53 +03:00
|
|
|
find_library(IOKIT_LIBRARY IOKit)
|
|
|
|
find_library(COREFOUNDATION_LIBRARY CoreFoundation)
|
|
|
|
find_library(COREVIDEO_LIBRARY CoreVideo)
|
2017-07-23 02:45:36 +03:00
|
|
|
|
2018-01-27 00:57:57 +03:00
|
|
|
set(LIBS_PRIVATE ${OPENGL_LIBRARY} ${COCOA_LIBRARY}
|
2017-11-25 22:27:53 +03:00
|
|
|
${IOKIT_LIBRARY} ${COREFOUNDATION_LIBRARY} ${COREVIDEO_LIBRARY})
|
2018-01-27 01:44:01 +03:00
|
|
|
elseif(WIN32)
|
|
|
|
# no pkg-config --static on Windows yet...
|
|
|
|
else()
|
|
|
|
find_library(pthread NAMES pthread)
|
|
|
|
find_package(OpenGL)
|
|
|
|
if ("${OPENGL_LIBRARIES}" STREQUAL "")
|
|
|
|
# CFLAGS=-m32 cmake on Linux fails for some reason, so fallback to hardcoding
|
|
|
|
set(LIBS_PRIVATE m pthread GL X11 Xrandr Xinerama Xi Xxf86vm Xcursor)
|
|
|
|
else()
|
|
|
|
find_package(X11 REQUIRED X11)
|
|
|
|
find_library(XRANDR_LIBRARY Xrandr)
|
|
|
|
find_library(XI_LIBRARY Xi)
|
|
|
|
find_library(XINERAMA_LIBRARY Xinerama)
|
|
|
|
find_library(XXF86VM_LIBRARY Xxf86vm)
|
|
|
|
find_library(XCURSOR_LIBRARY Xcursor)
|
|
|
|
|
|
|
|
include_directories(${OPENGL_INCLUDE_DIR})
|
|
|
|
|
|
|
|
set(LIBS_PRIVATE m ${pthread} ${OPENGL_LIBRARIES} ${X11_LIBRARIES} ${XRANDR_LIBRARY} ${XINERAMA_LIBRARY} ${XI_LIBRARY} ${XXF86VM_LIBRARY} ${XCURSOR_LIBRARY})
|
|
|
|
endif()
|
2017-11-29 02:05:39 +03:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
|
2018-01-27 01:44:01 +03:00
|
|
|
set(LINUX TRUE)
|
|
|
|
set(LIBS_PRIVATE dl ${LIBS_PRIVATE})
|
2017-11-29 02:05:39 +03:00
|
|
|
endif()
|
|
|
|
|
2017-07-23 02:45:36 +03:00
|
|
|
# Do the linking for executables that are meant to link raylib
|
|
|
|
function(link_libraries_to_executable executable)
|
|
|
|
# And raylib
|
|
|
|
target_link_libraries(${executable} raylib)
|
2017-11-25 22:27:53 +03:00
|
|
|
|
|
|
|
# Link the libraries
|
|
|
|
target_link_libraries(${executable} ${LIBS_PRIVATE})
|
2017-07-23 02:45:36 +03:00
|
|
|
endfunction()
|
|
|
|
|