Generate and install pkg-config pc file

After installation, compiling new programs is possible with
    $ cc game.c `pkg-config --static --libs --cflags raylib`
or
    $ cc game.c `pkg-config --libs --cflags raylib`
depending on configuration

Also adds following configuration options:
- WITH_PIC "Compile static library as position-independent code"
- STATIC_RAYLIB "Build raylib as a static library"
- MACOS_FATLIB  "Build fat library for both i386 and x86_64 on macOS"
This commit is contained in:
Ahmad Fatoum 2017-10-11 22:33:09 +02:00
parent 589cec0dd5
commit 44376c04fa
No known key found for this signature in database
GPG key ID: C3EAC3DE9321D59B
5 changed files with 117 additions and 70 deletions

View file

@ -1,5 +1,5 @@
# All sorts of things that we need cross project
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 2.8.0)
# Detect linux
if(UNIX AND NOT APPLE)
@ -8,33 +8,27 @@ endif()
# Linking for OS X -framework options
# Will do nothing on other OSes
function(link_os_x_frameworks binary)
if(APPLE)
find_library(OPENGL_LIBRARY OpenGL)
find_library(OPENAL_LIBRARY OpenAL)
find_library(COCOA_LIBRARY Cocoa)
set(OSX_FRAMEWORKS ${OPENGL_LIBRARY} ${OPENAL_LIBRARY} ${COCOA_LIBRARY})
target_link_libraries(${binary} ${OSX_FRAMEWORKS})
endif()
endfunction()
if(APPLE)
find_library(OPENGL_LIBRARY OpenGL)
find_library(OPENAL_LIBRARY OpenAL)
find_library(COCOA_LIBRARY Cocoa)
set(LIBS_PRIVATE ${OPENGL_LIBRARY} ${OPENAL_LIBRARY} ${COCOA_LIBRARY})
elseif(LINUX)
# Elsewhere (such as Linux), need `-lopenal -lGL`, etc...
set(LIBS_PRIVATE
m pthread dl
openal
GL
X11 Xrandr Xinerama Xi Xxf86vm Xcursor) # X11 stuff
else()
# TODO Windows
endif()
# Do the linking for executables that are meant to link raylib
function(link_libraries_to_executable executable)
# Link the libraries
if(APPLE)
# OS X, we use frameworks
link_os_x_frameworks(${executable})
elseif(LINUX)
# Elsewhere (such as Linux), need `-lopenal -lGL`, etc...
target_link_libraries(${executable} m pthread dl)
target_link_libraries(${executable} openal)
target_link_libraries(${executable} GL)
target_link_libraries(${executable} X11 Xrandr Xinerama Xi Xxf86vm Xcursor) # X11 stuff
else()
# TODO windows
endif()
target_link_libraries(${executable} ${LIBS_PRIVATE})
# And raylib
target_link_libraries(${executable} raylib)