Add GNUInstallDirs and USE_AUDIO/USE_WAYLAND options to CMake (#518)
This commit is contained in:
parent
b8bd1d2ea6
commit
3caa044bf2
2 changed files with 52 additions and 19 deletions
|
@ -1,6 +1,7 @@
|
||||||
# Setup the project and settings
|
# Setup the project and settings
|
||||||
project(raylib)
|
project(raylib)
|
||||||
include("../utils.cmake")
|
include("../utils.cmake")
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
set(PROJECT_VERSION 1.9.4)
|
set(PROJECT_VERSION 1.9.4)
|
||||||
set(API_VERSION 1)
|
set(API_VERSION 1)
|
||||||
|
@ -12,6 +13,7 @@ option(WITH_PIC "Compile static library as position-independent code" OFF)
|
||||||
# Build a static and/or shared raylib?
|
# Build a static and/or shared raylib?
|
||||||
option(SHARED "Build raylib as a dynamic library" OFF)
|
option(SHARED "Build raylib as a dynamic library" OFF)
|
||||||
option(STATIC "Build raylib as a static library" ON)
|
option(STATIC "Build raylib as a static library" ON)
|
||||||
|
option(USE_AUDIO "Build raylib with audio module" ON)
|
||||||
option(MACOS_FATLIB "Build fat library for both i386 and x86_64 on macOS" ON)
|
option(MACOS_FATLIB "Build fat library for both i386 and x86_64 on macOS" ON)
|
||||||
|
|
||||||
if(NOT (STATIC OR SHARED))
|
if(NOT (STATIC OR SHARED))
|
||||||
|
@ -43,9 +45,15 @@ else()
|
||||||
include_directories(external/glfw/include)
|
include_directories(external/glfw/include)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(USE_AUDIO)
|
||||||
file(GLOB stb_vorbis external/stb_vorbis.c)
|
file(GLOB stb_vorbis external/stb_vorbis.c)
|
||||||
file(GLOB mini_al external/mini_al.c ${stb_vorbis})
|
file(GLOB mini_al external/mini_al.c ${stb_vorbis})
|
||||||
set(sources ${raylib_sources} ${mini_al})
|
set(sources ${raylib_sources} ${mini_al})
|
||||||
|
else()
|
||||||
|
set(INCLUDE_AUDIO_MODULE 0)
|
||||||
|
list(REMOVE_ITEM raylib_sources ${CMAKE_CURRENT_SOURCE_DIR}/audio.c)
|
||||||
|
set(sources ${raylib_sources})
|
||||||
|
endif()
|
||||||
|
|
||||||
### Config options ###
|
### Config options ###
|
||||||
# Translate the config options to what raylib wants
|
# Translate the config options to what raylib wants
|
||||||
|
@ -112,7 +120,7 @@ if(${PLATFORM} MATCHES "PLATFORM_DESKTOP")
|
||||||
)
|
)
|
||||||
|
|
||||||
set_property(TARGET ${RAYLIB}_shared PROPERTY POSITION_INDEPENDENT_CODE ON)
|
set_property(TARGET ${RAYLIB}_shared PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||||
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
|
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_LIBDIR}")
|
||||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||||
set(CMAKE_MACOSX_RPATH ON)
|
set(CMAKE_MACOSX_RPATH ON)
|
||||||
|
|
||||||
|
@ -132,8 +140,8 @@ if(${PLATFORM} MATCHES "PLATFORM_DESKTOP")
|
||||||
set_target_properties(${RAYLIB}_shared PROPERTIES OUTPUT_NAME ${RAYLIB})
|
set_target_properties(${RAYLIB}_shared PROPERTIES OUTPUT_NAME ${RAYLIB})
|
||||||
install(
|
install(
|
||||||
TARGETS ${RAYLIB}_shared
|
TARGETS ${RAYLIB}_shared
|
||||||
LIBRARY DESTINATION lib
|
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||||
PUBLIC_HEADER DESTINATION include
|
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
endif(${SHARED})
|
endif(${SHARED})
|
||||||
|
@ -153,13 +161,13 @@ if(${PLATFORM} MATCHES "PLATFORM_DESKTOP")
|
||||||
endif()
|
endif()
|
||||||
set_target_properties(${RAYLIB} PROPERTIES PUBLIC_HEADER "raylib.h")
|
set_target_properties(${RAYLIB} PROPERTIES PUBLIC_HEADER "raylib.h")
|
||||||
install(TARGETS ${RAYLIB}
|
install(TARGETS ${RAYLIB}
|
||||||
ARCHIVE DESTINATION lib
|
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||||
PUBLIC_HEADER DESTINATION include
|
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
||||||
)
|
)
|
||||||
endif(${STATIC})
|
endif(${STATIC})
|
||||||
|
|
||||||
configure_file(../raylib.pc.in raylib.pc @ONLY)
|
configure_file(../raylib.pc.in raylib.pc @ONLY)
|
||||||
install(FILES ${CMAKE_BINARY_DIR}/release/raylib.pc DESTINATION lib/pkgconfig)
|
install(FILES ${CMAKE_BINARY_DIR}/release/raylib.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
||||||
|
|
||||||
# Copy the header files to the build directory
|
# Copy the header files to the build directory
|
||||||
file(COPY "raylib.h" DESTINATION ".")
|
file(COPY "raylib.h" DESTINATION ".")
|
||||||
|
|
27
utils.cmake
27
utils.cmake
|
@ -4,6 +4,10 @@ cmake_minimum_required(VERSION 2.8.0)
|
||||||
set(USE_EXTERNAL_GLFW OFF CACHE STRING "Link raylib against system GLFW instead of embedded one")
|
set(USE_EXTERNAL_GLFW OFF CACHE STRING "Link raylib against system GLFW instead of embedded one")
|
||||||
set_property(CACHE USE_EXTERNAL_GLFW PROPERTY STRINGS ON OFF IF_POSSIBLE)
|
set_property(CACHE USE_EXTERNAL_GLFW PROPERTY STRINGS ON OFF IF_POSSIBLE)
|
||||||
|
|
||||||
|
if(UNIX AND NOT APPLE)
|
||||||
|
option(USE_WAYLAND "Use Wayland for window creation" OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Linking for OS X -framework options
|
# Linking for OS X -framework options
|
||||||
# Will do nothing on other OSes
|
# Will do nothing on other OSes
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
|
@ -18,25 +22,47 @@ if(APPLE)
|
||||||
elseif(WIN32)
|
elseif(WIN32)
|
||||||
# no pkg-config --static on Windows yet...
|
# no pkg-config --static on Windows yet...
|
||||||
else()
|
else()
|
||||||
|
if(USE_WAYLAND)
|
||||||
|
set(_GLFW_WAYLAND 1)
|
||||||
|
else()
|
||||||
|
set(_GLFW_X11 1)
|
||||||
|
endif()
|
||||||
|
|
||||||
find_library(pthread NAMES pthread)
|
find_library(pthread NAMES pthread)
|
||||||
find_package(OpenGL)
|
find_package(OpenGL)
|
||||||
if ("${OPENGL_LIBRARIES}" STREQUAL "")
|
if ("${OPENGL_LIBRARIES}" STREQUAL "")
|
||||||
|
if(NOT USE_WAYLAND)
|
||||||
# CFLAGS=-m32 cmake on Linux fails for some reason, so fallback to hardcoding
|
# 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)
|
set(LIBS_PRIVATE m pthread GL X11 Xrandr Xinerama Xi Xxf86vm Xcursor)
|
||||||
else()
|
else()
|
||||||
|
# CFLAGS=-m32 cmake on Linux fails for some reason, so fallback to hardcoding
|
||||||
|
set(LIBS_PRIVATE m pthread GL wayland-client wayland-cursor wayland-egl)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
if(NOT USE_WAYLAND)
|
||||||
find_package(X11 REQUIRED X11)
|
find_package(X11 REQUIRED X11)
|
||||||
find_library(XRANDR_LIBRARY Xrandr)
|
find_library(XRANDR_LIBRARY Xrandr)
|
||||||
find_library(XI_LIBRARY Xi)
|
find_library(XI_LIBRARY Xi)
|
||||||
find_library(XINERAMA_LIBRARY Xinerama)
|
find_library(XINERAMA_LIBRARY Xinerama)
|
||||||
find_library(XXF86VM_LIBRARY Xxf86vm)
|
find_library(XXF86VM_LIBRARY Xxf86vm)
|
||||||
find_library(XCURSOR_LIBRARY Xcursor)
|
find_library(XCURSOR_LIBRARY Xcursor)
|
||||||
|
else()
|
||||||
|
find_library(WAYLAND_CLIENT_LIBRARY wayland-client)
|
||||||
|
find_library(WAYLAND_CURSOR_LIBRARY wayland-cursor)
|
||||||
|
find_library(WAYLAND_EGL_LIBRARY wayland-egl)
|
||||||
|
endif()
|
||||||
|
|
||||||
include_directories(${OPENGL_INCLUDE_DIR})
|
include_directories(${OPENGL_INCLUDE_DIR})
|
||||||
|
|
||||||
if ("${CMAKE_SYSTEM_NAME}" MATCHES "(Net|Open)BSD")
|
if ("${CMAKE_SYSTEM_NAME}" MATCHES "(Net|Open)BSD")
|
||||||
find_library(OSS_LIBRARY ossaudio)
|
find_library(OSS_LIBRARY ossaudio)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT USE_WAYLAND)
|
||||||
set(LIBS_PRIVATE m ${pthread} ${OPENGL_LIBRARIES} ${X11_LIBRARIES} ${XRANDR_LIBRARY} ${XINERAMA_LIBRARY} ${XI_LIBRARY} ${XXF86VM_LIBRARY} ${XCURSOR_LIBRARY} ${OSS_LIBRARY})
|
set(LIBS_PRIVATE m ${pthread} ${OPENGL_LIBRARIES} ${X11_LIBRARIES} ${XRANDR_LIBRARY} ${XINERAMA_LIBRARY} ${XI_LIBRARY} ${XXF86VM_LIBRARY} ${XCURSOR_LIBRARY} ${OSS_LIBRARY})
|
||||||
|
else()
|
||||||
|
set(LIBS_PRIVATE m ${pthread} ${OPENGL_LIBRARIES} ${WAYLAND_CLIENT_LIBRARY} ${WAYLAND_CURSOR_LIBRARY} ${WAYLAND_EGL_LIBRARY} ${OSS_LIBRARY})
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -49,7 +75,6 @@ if (glfw3_FOUND)
|
||||||
set(LIBS_PRIVATE ${LIBS_PRIVATE} glfw)
|
set(LIBS_PRIVATE ${LIBS_PRIVATE} glfw)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
|
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
|
||||||
set(LINUX TRUE)
|
set(LINUX TRUE)
|
||||||
set(LIBS_PRIVATE dl ${LIBS_PRIVATE})
|
set(LIBS_PRIVATE dl ${LIBS_PRIVATE})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue