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
|
|
|
|
2018-04-07 23:51:03 +03:00
|
|
|
add_definitions("-DRAYLIB_CMAKE=1")
|
2018-04-07 17:32:14 +03:00
|
|
|
|
2017-07-23 02:45:36 +03:00
|
|
|
# Linking for OS X -framework options
|
|
|
|
# Will do nothing on other OSes
|
2018-04-12 20:31:53 +03:00
|
|
|
if(${PLATFORM} MATCHES "Android")
|
|
|
|
find_library(OPENGL_LIBRARY OpenGL)
|
|
|
|
set(LIBS_PRIVATE m log android EGL GLESv2 OpenSLES atomic c)
|
|
|
|
elseif(${PLATFORM} MATCHES "Web")
|
|
|
|
elseif(APPLE)
|
2017-10-11 23:33:09 +03:00
|
|
|
find_library(OPENGL_LIBRARY OpenGL)
|
2017-07-23 02:45:36 +03:00
|
|
|
|
2018-07-03 21:28:44 +03:00
|
|
|
set(LIBS_PRIVATE ${OPENGL_LIBRARY})
|
2018-01-27 01:44:01 +03:00
|
|
|
elseif(WIN32)
|
|
|
|
# no pkg-config --static on Windows yet...
|
|
|
|
else()
|
|
|
|
find_library(pthread NAMES pthread)
|
2018-04-07 23:51:03 +03:00
|
|
|
find_package(OpenGL QUIET)
|
2018-01-27 01:44:01 +03:00
|
|
|
if ("${OPENGL_LIBRARIES}" STREQUAL "")
|
2018-05-12 16:39:13 +03:00
|
|
|
set(OPENGL_LIBRARIES "GL")
|
|
|
|
endif()
|
2018-04-07 17:32:14 +03:00
|
|
|
|
2018-05-12 16:39:13 +03:00
|
|
|
include_directories(${OPENGL_INCLUDE_DIR})
|
2018-01-27 01:44:01 +03:00
|
|
|
|
2018-05-12 16:39:13 +03:00
|
|
|
if ("${CMAKE_SYSTEM_NAME}" MATCHES "(Net|Open)BSD")
|
|
|
|
find_library(OSS_LIBRARY ossaudio)
|
|
|
|
endif()
|
2018-02-11 13:59:36 +03:00
|
|
|
|
2018-05-12 16:39:13 +03:00
|
|
|
set(LIBS_PRIVATE m pthread ${OPENGL_LIBRARIES} ${OSS_LIBRARY})
|
2017-11-29 02:05:39 +03:00
|
|
|
endif()
|
|
|
|
|
2018-05-21 00:03:04 +03:00
|
|
|
if(${PLATFORM} MATCHES "Desktop")
|
|
|
|
if(USE_EXTERNAL_GLFW STREQUAL "ON")
|
2018-02-03 12:17:51 +03:00
|
|
|
find_package(glfw3 3.2.1 REQUIRED)
|
2018-05-21 00:03:04 +03:00
|
|
|
elseif(USE_EXTERNAL_GLFW STREQUAL "IF_POSSIBLE")
|
2018-04-07 23:51:03 +03:00
|
|
|
find_package(glfw3 3.2.1 QUIET)
|
2018-05-21 00:03:04 +03:00
|
|
|
endif()
|
|
|
|
if (glfw3_FOUND)
|
|
|
|
set(LIBS_PRIVATE ${LIBS_PRIVATE} glfw)
|
|
|
|
endif()
|
2018-02-03 12:17:51 +03:00
|
|
|
endif()
|
|
|
|
|
2017-11-29 02:05:39 +03:00
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
|
2018-01-27 01:44:01 +03:00
|
|
|
set(LINUX TRUE)
|
2017-11-29 02:05:39 +03:00
|
|
|
endif()
|
|
|
|
|
2018-02-03 12:17:51 +03:00
|
|
|
foreach(L ${LIBS_PRIVATE})
|
|
|
|
get_filename_component(DIR ${L} PATH)
|
|
|
|
get_filename_component(LIBFILE ${L} NAME_WE)
|
|
|
|
STRING(REGEX REPLACE "^lib" "" FILE ${LIBFILE})
|
|
|
|
|
|
|
|
if (${L} MATCHES "[.]framework$")
|
|
|
|
set(FILE_OPT "-framework ${FILE}")
|
|
|
|
set(DIR_OPT "-F${DIR}")
|
|
|
|
else()
|
|
|
|
set(FILE_OPT "-l${FILE}")
|
|
|
|
set(DIR_OPT "-L${DIR}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if ("${DIR}" STREQUAL "" OR "${DIR}" STREQUAL "${LASTDIR}")
|
|
|
|
set (DIR_OPT "")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(LASTDIR ${DIR})
|
|
|
|
|
2018-02-11 22:00:04 +03:00
|
|
|
set(__PKG_CONFIG_LIBS_PRIVATE ${__PKG_CONFIG_LIBS_PRIVATE} ${DIR_OPT} ${FILE_OPT})
|
|
|
|
string (REPLACE ";" " " __PKG_CONFIG_LIBS_PRIVATE "${__PKG_CONFIG_LIBS_PRIVATE}")
|
2018-02-03 12:17:51 +03:00
|
|
|
endforeach(L)
|
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
2018-02-03 12:17:51 +03:00
|
|
|
# Link raylib
|
|
|
|
if (TARGET raylib_shared)
|
|
|
|
target_link_libraries(${executable} raylib_shared)
|
2018-04-12 20:31:53 +03:00
|
|
|
elseif(${PLATFORM} MATCHES "Web")
|
|
|
|
target_link_libraries(${executable} ${__PKG_CONFIG_LIBS_PRIVATE})
|
|
|
|
target_link_libraries(${executable} raylib)
|
2018-02-03 12:17:51 +03:00
|
|
|
else()
|
2018-02-11 22:00:04 +03:00
|
|
|
target_link_libraries(${executable} raylib ${__PKG_CONFIG_LIBS_PRIVATE})
|
2018-02-03 12:17:51 +03:00
|
|
|
endif()
|
2017-07-23 02:45:36 +03:00
|
|
|
endfunction()
|