From b2acff66dec7bce30e9704aa9b13070f7c3ffac1 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Wed, 22 Nov 2017 22:33:47 +0100 Subject: Fix macOS build of new rglfw.c approach There have been two problems: * GLFW itself was compiled with the definitions for compiling _against_ GLFW (fixed by removing requirement for external glfw) * rglfw.c was being compiled as C code, although it includes Objective C files. This _might_ break the Windows build, needs to be checked. Fixes #391, but as noted I'd prefer though a separate source directory and build script for GLFW. --- utils.cmake | 7 ------- 1 file changed, 7 deletions(-) (limited to 'utils.cmake') diff --git a/utils.cmake b/utils.cmake index c902f60e..f260fa5e 100644 --- a/utils.cmake +++ b/utils.cmake @@ -6,10 +6,6 @@ if(UNIX AND NOT APPLE) set(LINUX TRUE) endif() -# Need GLFW 3.2.1 -find_package(glfw3 3.2.1 REQUIRED) - - # Linking for OS X -framework options # Will do nothing on other OSes function(link_os_x_frameworks binary) @@ -40,9 +36,6 @@ function(link_libraries_to_executable executable) # TODO windows endif() - # Add in GLFW as a linking target - target_link_libraries(${executable} glfw) - # And raylib target_link_libraries(${executable} raylib) endfunction() -- cgit v1.2.3 From 44376c04fa8ed5bc9ca48598afa1d177d169fa32 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Wed, 11 Oct 2017 22:33:09 +0200 Subject: 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" --- .travis.yml | 8 ++-- appveyor.yml | 2 +- raylib.pc.in | 13 ++++++ src/CMakeLists.txt | 124 +++++++++++++++++++++++++++++++++++------------------ utils.cmake | 40 ++++++++--------- 5 files changed, 117 insertions(+), 70 deletions(-) create mode 100644 raylib.pc.in (limited to 'utils.cmake') diff --git a/.travis.yml b/.travis.yml index 8b122c47..ce4998c7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,9 +13,9 @@ env: global: - VERBOSE=1 matrix: - - CFLAGS=-m64 - - CFLAGS=-m32 - + - CFLAGS=-m64 SHARED=ON + - CFLAGS=-m32 SHARED=OFF +# We don't install x11 32-bit libraries, so skip shared libraries on -m32 before_script: - export CFLAGS="-std=gnu99 $CFLAGS" @@ -32,7 +32,7 @@ before_install: script: - mkdir build - cd build - - cmake -DBUILD_EXAMPLES=OFF -DBUILD_GAMES=OFF .. + - cmake -DSTATIC_RAYLIB=ON -DSHARED_RAYLIB=$SHARED -DBUILD_EXAMPLES=OFF -DBUILD_GAMES=OFF .. - make # - make package # - sudo make install diff --git a/appveyor.yml b/appveyor.yml index 36f161c3..864d0c68 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -37,7 +37,7 @@ before_build: - cd build build_script: - - cmake -G %GENERATOR% -DBUILD_EXAMPLES=OFF -DBUILD_GAMES=OFF .. + - cmake -G %GENERATOR% -DSTATIC_RAYLIB=ON -DSHARED_RAYLIB=OFF -DBUILD_EXAMPLES=OFF -DBUILD_GAMES=OFF .. - cmake --build . --target install after_build: diff --git a/raylib.pc.in b/raylib.pc.in new file mode 100644 index 00000000..0472c283 --- /dev/null +++ b/raylib.pc.in @@ -0,0 +1,13 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include + +Name: raylib +Description: Simple and easy-to-use library to learn videogames programming +URL: https://github.com/raysan5/raylib +Version: @PROJECT_VERSION@ +Libs: -L${libdir} -lraylib +Libs.private:@PKG_CONFIG_LIBS_PRIVATE@ +Requires.private: +Cflags: -I${includedir} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6ab8e606..b29c29fc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,8 +8,17 @@ set(RAYLIB raylib) # Name of the generated library ### Config options ### -# Build a static or shared raylib? +# Shared library is always PIC. Static library should be PIC too if linked into a shared library +set(WITH_PIC OFF CACHE BOOL "Compile static library as position-independent code" OFF) +# Build a static and/or shared raylib? set(SHARED_RAYLIB OFF CACHE BOOL "Build raylib as a dynamic library") +set(STATIC_RAYLIB ON CACHE BOOL "Build raylib as a static library") +set(MACOS_FATLIB ON CACHE BOOL "Build fat library for both i386 and x86_64 on macOS") + +if(NOT (STATIC_RAYLIB OR SHARED_RAYLIB)) + message(FATAL_ERROR "Nothing to do if both -DSHARED_RAYLIB=OFF and -DSTATIC_RAYLIB=OFF...") +endif() + # Platform set(PLATFORM "Desktop" CACHE STRING "Platform to build for.") @@ -66,6 +75,14 @@ elseif(${PLATFORM} MATCHES "Raspberry Pi") set(GRAPHICS "GRAPHICS_API_OPENGL_ES2") endif() +if(BUILD_MACOS_FATLIB) + if (CMAKE_OSX_ARCHITECTURES) + message(FATAL_ERROR "User supplied -DCMAKE_OSX_ARCHITECTURES overrides BUILD_MACOS_FATLIB=ON") + else() + SET(CMAKE_OSX_ARCHITECTURES "x86_64;i386") + endif() +endif() + # Get the sources together file(GLOB raylib_sources *.c) file(GLOB stb_vorbis external/stb_vorbis.c) @@ -73,40 +90,72 @@ set(sources ${raylib_sources} ${stb_vorbis}) # Which platform? if(${PLATFORM} MATCHES "PLATFORM_DESKTOP") - # Build a static or shared raylib? - # TODO clean this up a bit? - if(${SHARED_RAYLIB}) - # Shared library - add_library(${RAYLIB} SHARED ${sources}) - - # Will link -framework (if on OS X) - link_os_x_frameworks(raylib) - else() - # Static library - add_library(${RAYLIB} STATIC ${sources}) - - if(LINUX) - # On Linux, need to link a few extra things for static - target_link_libraries(${RAYLIB} m pthread dl) - target_link_libraries(${RAYLIB} X11 Xrandr Xinerama Xi Xxf86vm Xcursor) # X11 stuff - endif() - endif() - - # Always need to link OpenAL and OpenGL + if(LINUX) - # Elsewhere (such as Linux), need `-lopenal -lGL` - target_link_libraries(${RAYLIB} openal) - target_link_libraries(${RAYLIB} GL) + foreach(L ${LIBS_PRIVATE}) + set(PKG_CONFIG_LIBS_PRIVATE "${PKG_CONFIG_LIBS_PRIVATE} -l${L}") + endforeach(L) + + elseif(APPLE) + # TODO extract framework location and name from ${LIBS_PRIVATE} + # and specify them as -F and -framework instead of hardcoding + foreach(F OpenGL OpenAL Cocoa) + set(PKG_CONFIG_LIBS_PRIVATE "${PKG_CONFIG_LIBS_PRIVATE} -framework ${F}") + endforeach(F) + endif() - - # Library file & Header - set_target_properties(${RAYLIB} PROPERTIES PUBLIC_HEADER "raylib.h") - install( - TARGETS ${RAYLIB} - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - PUBLIC_HEADER DESTINATION include - ) + + if(${SHARED_RAYLIB}) + add_library(${RAYLIB}_shared SHARED ${sources}) + + target_compile_definitions(${RAYLIB}_shared + PUBLIC ${PLATFORM} + PUBLIC ${GRAPHICS} + ) + + set_property(TARGET ${RAYLIB}_shared PROPERTY POSITION_INDEPENDENT_CODE ON) + set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") + set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + set(CMAKE_MACOSX_RPATH ON) + + target_link_libraries(${RAYLIB}_shared ${LIBS_PRIVATE}) + set_target_properties(${RAYLIB}_shared PROPERTIES PUBLIC_HEADER "raylib.h") + if(WIN32) + install( + TARGETS ${RAYLIB}_shared + RUNTIME DESTINATION lib + PUBLIC_HEADER DESTINATION include + ) + else() # Keep lib*.(a|dll) name, but avoid *.lib files overwriting each other on Windows + set_target_properties(${RAYLIB}_shared PROPERTIES OUTPUT_NAME ${RAYLIB}) + install( + TARGETS ${RAYLIB}_shared + LIBRARY DESTINATION lib + PUBLIC_HEADER DESTINATION include + ) + endif() + endif(${SHARED_RAYLIB}) + + if(${STATIC_RAYLIB}) + add_library(${RAYLIB} STATIC ${sources}) + + target_compile_definitions(${RAYLIB} + PUBLIC ${PLATFORM} + PUBLIC ${GRAPHICS} + ) + + if (WITH_PIC) + set_property(TARGET ${RAYLIB} PROPERTY POSITION_INDEPENDENT_CODE ON) + endif() + set_target_properties(${RAYLIB} PROPERTIES PUBLIC_HEADER "raylib.h") + install(TARGETS ${RAYLIB} + ARCHIVE DESTINATION lib + PUBLIC_HEADER DESTINATION include + ) + endif(${STATIC_RAYLIB}) + + configure_file(../raylib.pc.in raylib.pc @ONLY) + install(FILES ${CMAKE_BINARY_DIR}/release/raylib.pc DESTINATION lib/pkgconfig) # Copy the header files to the build directory file(COPY "raylib.h" DESTINATION ".") @@ -119,15 +168,6 @@ elseif(${PLATFORM} MATCHES "PLATFORM_WEB") add_executable(${RAYLIB} ${sources}) endif() - -# Set the compile flags to raylib -target_compile_definitions(${RAYLIB} - PUBLIC ${PLATFORM} - PUBLIC ${GRAPHICS} -) - - - # Print the flags for the user message(STATUS "Compiling with the flags:") message(STATUS " PLATFORM=" ${PLATFORM}) diff --git a/utils.cmake b/utils.cmake index f260fa5e..54221b9c 100644 --- a/utils.cmake +++ b/utils.cmake @@ -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) -- cgit v1.2.3 From f991a075e18df5e58bd6f6f90c1b02b5b353cbe3 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Sat, 25 Nov 2017 20:27:53 +0100 Subject: Build examples and games on Travis CI They were disabled because they failed to build, but this patch set fixes the build on Linux and macOS. This doesn't apply to the AppVeyor build on Windows yet; it currently fails at linking with OpenAL. --- .gitignore | 5 +++++ .travis.yml | 2 +- examples/CMakeLists.txt | 21 ++++++++++++++++++++- examples/others/audio_standalone.c | 7 ++----- games/wave_collector/wave_collector.c | 4 ++-- src/CMakeLists.txt | 2 +- utils.cmake | 12 ++++++++---- 7 files changed, 39 insertions(+), 14 deletions(-) (limited to 'utils.cmake') diff --git a/.gitignore b/.gitignore index 331d062d..65b3020c 100644 --- a/.gitignore +++ b/.gitignore @@ -132,3 +132,8 @@ build # Ignore Android generated files and folders templates/android_project/output + +# Ignore GNU global tags +GPATH +GRTAGS +GTAGS diff --git a/.travis.yml b/.travis.yml index af381d5b..ea51039e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,7 +41,7 @@ before_install: script: - mkdir build - cd build - - cmake -DMACOS_FATLIB=ON -DSTATIC_RAYLIB=ON -DSHARED_RAYLIB=$SHARED -DBUILD_EXAMPLES=OFF -DBUILD_GAMES=OFF .. + - cmake -DMACOS_FATLIB=ON -DSTATIC_RAYLIB=ON -DSHARED_RAYLIB=$SHARED .. - make - make package diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 354a1373..96ce37e0 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -7,9 +7,20 @@ include("../utils.cmake") # TODO `build` directory should maybe be something else... # TODO place somewhere else? include_directories("../build/release") +include_directories("../src/external") +include_directories("../src/external/glfw/include") # Get the sources together -set(example_dirs audio core models others physac shaders text texutures) +set(example_dirs audio core models others shaders text texutures) +set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=199309L) + include(CheckSymbolExists) + check_symbol_exists(CLOCK_MONOTONIC time.h HAVE_CLOCK_MONOTONIC) + check_symbol_exists(QueryPerformanceCounter windows.h HAVE_QPC) +set(CMAKE_REQUIRED_DEFINITIONS) +if(HAVE_QPC OR HAVE_CLOCK_MONOTONIC) + set(example_dirs ${example_dirs} physac) +endif() + set(example_sources) set(example_resources) foreach(example_dir ${example_dirs}) @@ -22,6 +33,14 @@ foreach(example_dir ${example_dirs}) list(APPEND example_resources ${resources}) endforeach() +include(CheckIncludeFiles) +check_include_files(OVR_CAPI_GL.h HAVE_OCULUS_CAPI) +if(NOT HAVE_OCULUS_CAPI) + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/oculus_rift.c) +endif() +list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/standard_lighting.c) + + # Do each example foreach(example_source ${example_sources}) # Create the basename for the example diff --git a/examples/others/audio_standalone.c b/examples/others/audio_standalone.c index 0a09c988..97c3fd0d 100644 --- a/examples/others/audio_standalone.c +++ b/examples/others/audio_standalone.c @@ -26,14 +26,11 @@ ********************************************************************************************/ #include +#include "audio.h" #if defined(_WIN32) #include // Windows only, no stardard library -#endif - -#include "audio.h" - -#if defined(__linux__) +#else #include #include #include diff --git a/games/wave_collector/wave_collector.c b/games/wave_collector/wave_collector.c index d4ce33d9..e28c0b84 100644 --- a/games/wave_collector/wave_collector.c +++ b/games/wave_collector/wave_collector.c @@ -63,7 +63,7 @@ static void UpdateDrawFrame(void); // Update and Draw one frame #if defined(PLATFORM_ANDROID) void android_main(struct android_app *app) #else -int main(void) +int main(int argc, char *argv[]) #endif { // Initialization @@ -315,4 +315,4 @@ static void UpdateDrawFrame(void) EndDrawing(); //---------------------------------------------------------------------------------- -} \ No newline at end of file +} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 47938030..47bee1ce 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -51,7 +51,7 @@ if(${PLATFORM} MATCHES "Desktop") if(APPLE) set(GRAPHICS "GRAPHICS_API_OPENGL_33") set_source_files_properties(rglfw.c PROPERTIES COMPILE_FLAGS "-x objective-c") - link_libraries("-framework CoreFoundation -framework Cocoa -framework IOKit -framework CoreVideo") + link_libraries("${LIBS_PRIVATE}") elseif(WIN32) add_definitions(-D_CRT_SECURE_NO_WARNINGS) endif() diff --git a/utils.cmake b/utils.cmake index 54221b9c..84c73fe2 100644 --- a/utils.cmake +++ b/utils.cmake @@ -12,8 +12,12 @@ if(APPLE) find_library(OPENGL_LIBRARY OpenGL) find_library(OPENAL_LIBRARY OpenAL) find_library(COCOA_LIBRARY Cocoa) + find_library(IOKIT_LIBRARY IOKit) + find_library(COREFOUNDATION_LIBRARY CoreFoundation) + find_library(COREVIDEO_LIBRARY CoreVideo) - set(LIBS_PRIVATE ${OPENGL_LIBRARY} ${OPENAL_LIBRARY} ${COCOA_LIBRARY}) + set(LIBS_PRIVATE ${OPENGL_LIBRARY} ${OPENAL_LIBRARY} ${COCOA_LIBRARY} + ${IOKIT_LIBRARY} ${COREFOUNDATION_LIBRARY} ${COREVIDEO_LIBRARY}) elseif(LINUX) # Elsewhere (such as Linux), need `-lopenal -lGL`, etc... set(LIBS_PRIVATE @@ -27,10 +31,10 @@ endif() # Do the linking for executables that are meant to link raylib function(link_libraries_to_executable executable) - # Link the libraries - target_link_libraries(${executable} ${LIBS_PRIVATE}) - # And raylib target_link_libraries(${executable} raylib) + + # Link the libraries + target_link_libraries(${executable} ${LIBS_PRIVATE}) endfunction() -- cgit v1.2.3 From 2f471414c2f830e61a200ecd956f37e45ce94e96 Mon Sep 17 00:00:00 2001 From: Martinfx Date: Wed, 29 Nov 2017 00:05:39 +0100 Subject: Added compile with cmake for FreeBSD --- src/CMakeLists.txt | 19 +++++++++++++++---- utils.cmake | 30 ++++++++++++++++++++++++------ 2 files changed, 39 insertions(+), 10 deletions(-) (limited to 'utils.cmake') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 47bee1ce..e4f5e8fc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,7 +5,6 @@ include("../utils.cmake") set(PROJECT_VERSION 1.9.1-dev) set(RAYLIB raylib) # Name of the generated library - ### Config options ### # Shared library is always PIC. Static library should be PIC too if linked into a shared library set(WITH_PIC OFF CACHE BOOL "Compile static library as position-independent code" OFF) @@ -18,7 +17,6 @@ if(NOT (STATIC_RAYLIB OR SHARED_RAYLIB)) message(FATAL_ERROR "Nothing to do if both -DSHARED_RAYLIB=OFF and -DSTATIC_RAYLIB=OFF...") endif() - # Platform set(PLATFORM "Desktop" CACHE STRING "Platform to build for.") set_property(CACHE PLATFORM PROPERTY STRINGS "Desktop" "Web" "Android" "Raspberry Pi") @@ -28,8 +26,14 @@ set(OPENGL_VERSION "3.3" CACHE STRING "OpenGL Version to build raylib with") set_property(CACHE OPENGL_VERSION PROPERTY STRINGS "3.3" "2.1" "1.1" "ES 2.0") ### Config options ### +if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD) + find_package(OpenGL REQUIRED) + find_package(OpenAL REQUIRED) + include_directories(${OPENGL_INCLUDE_DIR} ${OPENAL_INCLUDE_DIR}) +endif() + include_directories(external/glfw/include) -include_directories(external/openal/include) # For use with AppVeyor on Windows +include_directories(external/include) # For use with AppVeyor on Windows # Translate the config options to what raylib wants if(${PLATFORM} MATCHES "Desktop") @@ -55,6 +59,7 @@ if(${PLATFORM} MATCHES "Desktop") elseif(WIN32) add_definitions(-D_CRT_SECURE_NO_WARNINGS) endif() + elseif(${PLATFORM} MATCHES "Web") set(PLATFORM "PLATFORM_WEB") set(GRAPHICS "GRAPHICS_API_OPENGL_ES2") @@ -94,14 +99,20 @@ if(${PLATFORM} MATCHES "PLATFORM_DESKTOP") foreach(L ${LIBS_PRIVATE}) set(PKG_CONFIG_LIBS_PRIVATE "${PKG_CONFIG_LIBS_PRIVATE} -l${L}") endforeach(L) + endif() - elseif(APPLE) + if(APPLE) # TODO extract framework location and name from ${LIBS_PRIVATE} # and specify them as -F and -framework instead of hardcoding foreach(F OpenGL OpenAL Cocoa) set(PKG_CONFIG_LIBS_PRIVATE "${PKG_CONFIG_LIBS_PRIVATE} -framework ${F}") endforeach(F) + endif() + if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD) + foreach(L OpenGL OpenAL) + set(PKG_CONFIG_LIBS_PRIVATE "${PKG_CONFIG_LIBS_PRIVATE} -l${L}") + endforeach(L) endif() if(${SHARED_RAYLIB}) diff --git a/utils.cmake b/utils.cmake index 84c73fe2..43b479da 100644 --- a/utils.cmake +++ b/utils.cmake @@ -1,9 +1,8 @@ # All sorts of things that we need cross project cmake_minimum_required(VERSION 2.8.0) -# Detect linux -if(UNIX AND NOT APPLE) - set(LINUX TRUE) +if(CMAKE_SYSTEM_NAME STREQUAL Linux) + set(LINUX TRUE) endif() # Linking for OS X -framework options @@ -18,17 +17,36 @@ if(APPLE) set(LIBS_PRIVATE ${OPENGL_LIBRARY} ${OPENAL_LIBRARY} ${COCOA_LIBRARY} ${IOKIT_LIBRARY} ${COREFOUNDATION_LIBRARY} ${COREVIDEO_LIBRARY}) -elseif(LINUX) +endif() + +if(CMAKE_SYSTEM_NAME STREQUAL 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() +if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD) + find_package(OpenGL REQUIRED) + find_package(OpenAL REQUIRED) + include_directories(${OPENGL_INCLUDE_DIR} ${OPENAL_INCLUDE_DIR}) + + find_package(X11 REQUIRED) + find_library(OpenAL REQUIRED) + find_library(pthread NAMES pthread) + find_library(Xrandr NAMES Xrandr) + find_library(Xi NAMES Xi) + find_library(Xinerama NAMES Xinerama) + find_library(Xxf86vm NAMES Xxf86vm) + find_library(Xcursor NAMES Xcursor) + + set(LIBS_PRIVATE m ${pthread} ${OPENAL_LIBRARY} ${X11_LIBRARIES} ${Xrandr} ${Xinerama} ${Xi} ${Xxf86vm} ${Xcursor}) +endif() + +# TODO Support Windows + # Do the linking for executables that are meant to link raylib function(link_libraries_to_executable executable) # And raylib -- cgit v1.2.3 From de78fa69bc49afa83898e33e73b6dfbffc43f0e4 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Wed, 6 Dec 2017 22:18:14 +0100 Subject: Fix CI builds after mini_al changes --- .travis.yml | 2 +- appveyor.yml | 3 --- src/CMakeLists.txt | 3 +-- src/external/mini_al.h | 4 +++- utils.cmake | 1 - 5 files changed, 5 insertions(+), 8 deletions(-) (limited to 'utils.cmake') diff --git a/.travis.yml b/.travis.yml index 28641b38..7d1ffef0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ before_script: before_install: - if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install -y gcc-multilib - libopenal-dev + libasound2-dev libxcursor-dev libxinerama-dev mesa-common-dev libx11-dev libxrandr-dev libxi-dev xorg-dev libgl1-mesa-dev libglu1-mesa-dev libglew-dev; diff --git a/appveyor.yml b/appveyor.yml index bee59fa5..a8572d07 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -28,9 +28,6 @@ environment: bits: 64 before_build: - - appveyor DownloadFile http://openal-soft.org/openal-binaries/openal-soft-1.17.2-bin.zip - - 7z x openal-soft-1.17.2-bin.zip - - move openal-soft-1.17.2-bin src\external\openal - if [%compiler%]==[mingw] set CFLAGS=-m%BITS% & set LDFLAGS=-m%BITS% & set GENERATOR="MinGW Makefiles" - if [%COMPILER%]==[msvc15] if [%BITS%]==[32] set GENERATOR="Visual Studio 14 2015" - if [%COMPILER%]==[msvc15] if [%BITS%]==[64] set GENERATOR="Visual Studio 14 2015 Win64" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 819dd1a4..200ae6f9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -83,8 +83,7 @@ endif() # Get the sources together file(GLOB raylib_sources *.c) file(GLOB stb_vorbis external/stb_vorbis.c) -file(GLOB mini_al external/mini_al.c) -set(sources ${raylib_sources} ${stb_vorbis}) +file(GLOB mini_al external/mini_al.c ${stb_vorbis}) set(sources ${raylib_sources} ${mini_al}) # Which platform? diff --git a/src/external/mini_al.h b/src/external/mini_al.h index 7d83b548..36c394ad 100644 --- a/src/external/mini_al.h +++ b/src/external/mini_al.h @@ -2745,12 +2745,14 @@ static mal_result mal_context__try_get_device_name_by_id(mal_context* pContext, } } break; #endif + #if 0 #ifdef MAL_HAS_COREAUDIO - case mal_backend_coreaudio + case mal_backend_coreaudio: { // TODO: Implement me. } break; #endif + #endif #ifdef MAL_HAS_OSS case mal_backend_oss: { diff --git a/utils.cmake b/utils.cmake index 43b479da..d2c82cd1 100644 --- a/utils.cmake +++ b/utils.cmake @@ -23,7 +23,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL 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 endif() -- cgit v1.2.3 From 1093766669f7a96de09e205e9bab97c0e361a427 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Fri, 26 Jan 2018 22:57:57 +0100 Subject: CMake: remove OpenAL dependency --- src/CMakeLists.txt | 2 +- utils.cmake | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) (limited to 'utils.cmake') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e86bff9b..c8958c28 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -99,7 +99,7 @@ if(${PLATFORM} MATCHES "PLATFORM_DESKTOP") if(APPLE) # TODO extract framework location and name from ${LIBS_PRIVATE} # and specify them as -F and -framework instead of hardcoding - foreach(F OpenGL OpenAL Cocoa) + foreach(F OpenGL Cocoa) set(PKG_CONFIG_LIBS_PRIVATE "${PKG_CONFIG_LIBS_PRIVATE} -framework ${F}") endforeach(F) endif() diff --git a/utils.cmake b/utils.cmake index d2c82cd1..d07dce3e 100644 --- a/utils.cmake +++ b/utils.cmake @@ -9,18 +9,16 @@ endif() # Will do nothing on other OSes if(APPLE) find_library(OPENGL_LIBRARY OpenGL) - find_library(OPENAL_LIBRARY OpenAL) find_library(COCOA_LIBRARY Cocoa) find_library(IOKIT_LIBRARY IOKit) find_library(COREFOUNDATION_LIBRARY CoreFoundation) find_library(COREVIDEO_LIBRARY CoreVideo) - set(LIBS_PRIVATE ${OPENGL_LIBRARY} ${OPENAL_LIBRARY} ${COCOA_LIBRARY} + set(LIBS_PRIVATE ${OPENGL_LIBRARY} ${COCOA_LIBRARY} ${IOKIT_LIBRARY} ${COREFOUNDATION_LIBRARY} ${COREVIDEO_LIBRARY}) endif() if(CMAKE_SYSTEM_NAME STREQUAL Linux) - # Elsewhere (such as Linux), need `-lopenal -lGL`, etc... set(LIBS_PRIVATE m pthread dl GL @@ -29,11 +27,9 @@ endif() if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD) find_package(OpenGL REQUIRED) - find_package(OpenAL REQUIRED) - include_directories(${OPENGL_INCLUDE_DIR} ${OPENAL_INCLUDE_DIR}) + include_directories(${OPENGL_INCLUDE_DIR}) find_package(X11 REQUIRED) - find_library(OpenAL REQUIRED) find_library(pthread NAMES pthread) find_library(Xrandr NAMES Xrandr) find_library(Xi NAMES Xi) @@ -41,7 +37,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD) find_library(Xxf86vm NAMES Xxf86vm) find_library(Xcursor NAMES Xcursor) - set(LIBS_PRIVATE m ${pthread} ${OPENAL_LIBRARY} ${X11_LIBRARIES} ${Xrandr} ${Xinerama} ${Xi} ${Xxf86vm} ${Xcursor}) + set(LIBS_PRIVATE m ${pthread} ${X11_LIBRARIES} ${Xrandr} ${Xinerama} ${Xi} ${Xxf86vm} ${Xcursor}) endif() # TODO Support Windows -- cgit v1.2.3 From 7f7aac643a46e7cab5e65365ada4b0436f12bca4 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Fri, 26 Jan 2018 23:44:01 +0100 Subject: CMake: Search dependencies and build pkg-config's Libs.private with it --- src/CMakeLists.txt | 37 ++++++++++++++++++++----------------- utils.cmake | 49 +++++++++++++++++++++++-------------------------- 2 files changed, 43 insertions(+), 43 deletions(-) (limited to 'utils.cmake') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c8958c28..ccbfe0cf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -90,25 +90,28 @@ set(sources ${raylib_sources} ${mini_al}) # Which platform? if(${PLATFORM} MATCHES "PLATFORM_DESKTOP") - if(LINUX) - foreach(L ${LIBS_PRIVATE}) - set(PKG_CONFIG_LIBS_PRIVATE "${PKG_CONFIG_LIBS_PRIVATE} -l${L}") - endforeach(L) - endif() + foreach(L ${LIBS_PRIVATE}) + get_filename_component(DIR ${L} PATH) + get_filename_component(LIBFILE ${L} NAME_WE) + STRING(REGEX REPLACE "^lib" "" FILE ${LIBFILE}) - if(APPLE) - # TODO extract framework location and name from ${LIBS_PRIVATE} - # and specify them as -F and -framework instead of hardcoding - foreach(F OpenGL Cocoa) - set(PKG_CONFIG_LIBS_PRIVATE "${PKG_CONFIG_LIBS_PRIVATE} -framework ${F}") - endforeach(F) - endif() + 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}) + + set(PKG_CONFIG_LIBS_PRIVATE "${PKG_CONFIG_LIBS_PRIVATE} ${DIR_OPT}${FILE_OPT}") + endforeach(L) - if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD) - foreach(L ${LIBS_PRIVATE}) - set(PKG_CONFIG_LIBS_PRIVATE "${PKG_CONFIG_LIBS_PRIVATE} -l${L}") - endforeach(L) - endif() if(${SHARED_RAYLIB}) add_library(${RAYLIB}_shared SHARED ${sources}) diff --git a/utils.cmake b/utils.cmake index d07dce3e..beffdf6a 100644 --- a/utils.cmake +++ b/utils.cmake @@ -1,9 +1,5 @@ # All sorts of things that we need cross project -cmake_minimum_required(VERSION 2.8.0) - -if(CMAKE_SYSTEM_NAME STREQUAL Linux) - set(LINUX TRUE) -endif() +cmake_minimum_required(VERSION 2.8.) # Linking for OS X -framework options # Will do nothing on other OSes @@ -16,32 +12,33 @@ if(APPLE) set(LIBS_PRIVATE ${OPENGL_LIBRARY} ${COCOA_LIBRARY} ${IOKIT_LIBRARY} ${COREFOUNDATION_LIBRARY} ${COREVIDEO_LIBRARY}) +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() endif() if(CMAKE_SYSTEM_NAME STREQUAL Linux) - set(LIBS_PRIVATE - m pthread dl - GL - X11 Xrandr Xinerama Xi Xxf86vm Xcursor) # X11 stuff -endif() - -if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD) - find_package(OpenGL REQUIRED) - include_directories(${OPENGL_INCLUDE_DIR}) - - find_package(X11 REQUIRED) - find_library(pthread NAMES pthread) - find_library(Xrandr NAMES Xrandr) - find_library(Xi NAMES Xi) - find_library(Xinerama NAMES Xinerama) - find_library(Xxf86vm NAMES Xxf86vm) - find_library(Xcursor NAMES Xcursor) - - set(LIBS_PRIVATE m ${pthread} ${X11_LIBRARIES} ${Xrandr} ${Xinerama} ${Xi} ${Xxf86vm} ${Xcursor}) + set(LINUX TRUE) + set(LIBS_PRIVATE dl ${LIBS_PRIVATE}) endif() -# TODO Support Windows - # Do the linking for executables that are meant to link raylib function(link_libraries_to_executable executable) # And raylib -- cgit v1.2.3 From 2090ad8119fd622f80ff8a8707f416abec1db375 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Sat, 27 Jan 2018 02:00:40 +0100 Subject: CMake: Add missing 0 to minimum version Removed by mistake. --- utils.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils.cmake') diff --git a/utils.cmake b/utils.cmake index beffdf6a..efdfae50 100644 --- a/utils.cmake +++ b/utils.cmake @@ -1,5 +1,5 @@ # All sorts of things that we need cross project -cmake_minimum_required(VERSION 2.8.) +cmake_minimum_required(VERSION 2.8.0) # Linking for OS X -framework options # Will do nothing on other OSes -- cgit v1.2.3 From 7f5fa4d49c4641a8dc0a6716b64cec9166f3fcdc Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Sat, 3 Feb 2018 10:17:51 +0100 Subject: CMake: Add tristate option for using system GLFW (#455) -DWITH_SYSTEM_GLFW=ON: Link against system glfw and fail otherwise -DWITH_SYSTEM_GLFW=OFF: Use embedded rglfw.c -DWITH_SYSTEM_GLFW=IF_POSSIBLE: Probe for system glfw but fallback to rglfw if unavailable Also change Linux 64-bit CI build to install system glfw and use it, so this doesn't bitrot. Addresses #453. --- .travis.yml | 14 +++++++++++--- src/CMakeLists.txt | 43 ++++++++++++------------------------------- utils.cmake | 50 ++++++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 67 insertions(+), 40 deletions(-) (limited to 'utils.cmake') diff --git a/.travis.yml b/.travis.yml index 0974b218..b22892eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ matrix: env: ARCH=i386 sudo: required - os: linux - env: ARCH=amd64 + env: ARCH=amd64 GLFW=SYSTEM sudo: required - os: osx env: ARCH=universal @@ -30,14 +30,22 @@ before_install: export RAYLIB_PACKAGE_SUFFIX="-Linux-$ARCH"; if [ "$ARCH" == "i386" ]; then export CFLAGS="-m32"; fi; if [ "$ARCH" == "amd64" ]; then export CFLAGS="-m64"; fi; + if [ "$GLFW" == "SYSTEM" ]; then + wget 'http://ftp.de.debian.org/debian/pool/main/g/glfw3/libglfw3_3.2.1-1_amd64.deb'; + wget 'http://ftp.de.debian.org/debian/pool/main/g/glfw3/libglfw3-dev_3.2.1-1_amd64.deb'; + sudo dpkg -i libglfw3_3.2.1-1_amd64.deb libglfw3-dev_3.2.1-1_amd64.deb; + fi; + fi + - if [ "$TRAVIS_OS_NAME" == "osx" ]; then + export RAYLIB_PACKAGE_SUFFIX="-macOS"; + if [ "$GLFW" == "SYSTEM" ]; then brew update; brew install glfw; fi; fi - - if [ "$TRAVIS_OS_NAME" == "osx" ]; then export RAYLIB_PACKAGE_SUFFIX="-macOS"; fi - "$CC --version" script: - mkdir build - cd build - - cmake -DMACOS_FATLIB=ON -DSTATIC_RAYLIB=ON -DSHARED_RAYLIB=ON -DBUILD_EXAMPLES=ON -DBUILD_GAMES=ON .. + - cmake -DMACOS_FATLIB=ON -DSTATIC_RAYLIB=ON -DSHARED_RAYLIB=ON -DBUILD_EXAMPLES=ON -DBUILD_GAMES=ON -DWITH_SYSTEM_GLFW=IF_POSSIBLE .. - make VERBOSE=1 - make package diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 809eb4ce..54d3e59c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -26,9 +26,19 @@ set_property(CACHE PLATFORM PROPERTY STRINGS "Desktop" "Web" "Android" "Raspberr set(OPENGL_VERSION "3.3" CACHE STRING "OpenGL Version to build raylib with") set_property(CACHE OPENGL_VERSION PROPERTY STRINGS "3.3" "2.1" "1.1" "ES 2.0") -### Config options ### -include_directories(external/glfw/include) +# Get the sources together +file(GLOB raylib_sources *.c) +if(glfw3_FOUND) + list(REMOVE_ITEM raylib_sources ${CMAKE_CURRENT_SOURCE_DIR}/rglfw.c) +else() + include_directories(external/glfw/include) +endif() +file(GLOB stb_vorbis external/stb_vorbis.c) +file(GLOB mini_al external/mini_al.c ${stb_vorbis}) +set(sources ${raylib_sources} ${mini_al}) + +### Config options ### # Translate the config options to what raylib wants if(${PLATFORM} MATCHES "Desktop") set(PLATFORM "PLATFORM_DESKTOP") @@ -81,38 +91,9 @@ if(MACOS_FATLIB) endif() endif() -# Get the sources together -file(GLOB raylib_sources *.c) -file(GLOB stb_vorbis external/stb_vorbis.c) -file(GLOB mini_al external/mini_al.c ${stb_vorbis}) -set(sources ${raylib_sources} ${mini_al}) - # Which platform? if(${PLATFORM} MATCHES "PLATFORM_DESKTOP") - 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}) - - set(PKG_CONFIG_LIBS_PRIVATE "${PKG_CONFIG_LIBS_PRIVATE} ${DIR_OPT}${FILE_OPT}") - endforeach(L) - - if(${SHARED_RAYLIB}) add_library(${RAYLIB}_shared SHARED ${sources}) diff --git a/utils.cmake b/utils.cmake index efdfae50..871ad119 100644 --- a/utils.cmake +++ b/utils.cmake @@ -1,6 +1,9 @@ # All sorts of things that we need cross project cmake_minimum_required(VERSION 2.8.0) +set(WITH_SYSTEM_GLFW OFF CACHE STRING "Link raylib against system GLFW instead of embedded one") +set_property(CACHE WITH_SYSTEM_GLFW PROPERTY STRINGS ON OFF IF_POSSIBLE) + # Linking for OS X -framework options # Will do nothing on other OSes if(APPLE) @@ -27,24 +30,59 @@ else() 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() endif() +if(WITH_SYSTEM_GLFW STREQUAL "ON") + find_package(glfw3 3.2.1 REQUIRED) +else(WITH_SYSTEM_GLFW STREQUAL "IF_POSSIBLE") + find_package(glfw3 3.2.1) +endif() +if (glfw3_FOUND) + set(LIBS_PRIVATE ${LIBS_PRIVATE} glfw) +endif() + + if(CMAKE_SYSTEM_NAME STREQUAL Linux) set(LINUX TRUE) set(LIBS_PRIVATE dl ${LIBS_PRIVATE}) endif() +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}) + + set(PKG_CONFIG_LIBS_PRIVATE ${PKG_CONFIG_LIBS_PRIVATE} ${DIR_OPT} ${FILE_OPT}) + string (REPLACE ";" " " PKG_CONFIG_LIBS_PRIVATE "${PKG_CONFIG_LIBS_PRIVATE}") +endforeach(L) + + + # Do the linking for executables that are meant to link raylib function(link_libraries_to_executable executable) - # And raylib - target_link_libraries(${executable} raylib) - - # Link the libraries - target_link_libraries(${executable} ${LIBS_PRIVATE}) + # Link raylib + if (TARGET raylib_shared) + target_link_libraries(${executable} raylib_shared) + else() + target_link_libraries(${executable} raylib ${PKG_CONFIG_LIBS_PRIVATE}) + endif() endfunction() -- cgit v1.2.3 From 2b2b1f91ee3a486280ef6c3704b1772b544a466b Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Sat, 3 Feb 2018 13:29:55 +0100 Subject: CMake: Fix typo in GLFW detection Let it be noted I utterly dislike their syntax. --- utils.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils.cmake') diff --git a/utils.cmake b/utils.cmake index 871ad119..ad709b22 100644 --- a/utils.cmake +++ b/utils.cmake @@ -38,7 +38,7 @@ endif() if(WITH_SYSTEM_GLFW STREQUAL "ON") find_package(glfw3 3.2.1 REQUIRED) -else(WITH_SYSTEM_GLFW STREQUAL "IF_POSSIBLE") +elseif(WITH_SYSTEM_GLFW STREQUAL "IF_POSSIBLE") find_package(glfw3 3.2.1) endif() if (glfw3_FOUND) -- cgit v1.2.3 From cb66c89dfa096239be8522fc3a518c94b76d0cd4 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Sun, 4 Feb 2018 12:08:36 +0100 Subject: CMake: Rename WITH_SYSTEM_GLFW to USE_EXTERNAL_GLFW for consistency with Makefile. Requested by @raysan5 in #453. --- .travis.yml | 2 +- utils.cmake | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'utils.cmake') diff --git a/.travis.yml b/.travis.yml index b22892eb..55d8357d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,7 +45,7 @@ before_install: script: - mkdir build - cd build - - cmake -DMACOS_FATLIB=ON -DSTATIC_RAYLIB=ON -DSHARED_RAYLIB=ON -DBUILD_EXAMPLES=ON -DBUILD_GAMES=ON -DWITH_SYSTEM_GLFW=IF_POSSIBLE .. + - cmake -DMACOS_FATLIB=ON -DSTATIC_RAYLIB=ON -DSHARED_RAYLIB=ON -DBUILD_EXAMPLES=ON -DBUILD_GAMES=ON -DUSE_EXTERNAL_GLFW=IF_POSSIBLE .. - make VERBOSE=1 - make package diff --git a/utils.cmake b/utils.cmake index ad709b22..68fd1f76 100644 --- a/utils.cmake +++ b/utils.cmake @@ -1,8 +1,8 @@ # All sorts of things that we need cross project cmake_minimum_required(VERSION 2.8.0) -set(WITH_SYSTEM_GLFW OFF CACHE STRING "Link raylib against system GLFW instead of embedded one") -set_property(CACHE WITH_SYSTEM_GLFW PROPERTY STRINGS ON OFF IF_POSSIBLE) +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) # Linking for OS X -framework options # Will do nothing on other OSes @@ -36,9 +36,9 @@ else() endif() endif() -if(WITH_SYSTEM_GLFW STREQUAL "ON") +if(USE_EXTERNAL_GLFW STREQUAL "ON") find_package(glfw3 3.2.1 REQUIRED) -elseif(WITH_SYSTEM_GLFW STREQUAL "IF_POSSIBLE") +elseif(USE_EXTERNAL_GLFW STREQUAL "IF_POSSIBLE") find_package(glfw3 3.2.1) endif() if (glfw3_FOUND) -- cgit v1.2.3 From 09b022305f3fd365d5d0424ff51982bcca5a572f Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Sun, 11 Feb 2018 11:59:36 +0100 Subject: mini_al: Support {Net,Open}BSD OSS Fixes this build failure: http://www.cpantesters.org/cpan/report/a069fade-0e1f-11e8-a1cf-bb670eaac09d --- src/external/mini_al.h | 6 +++++- utils.cmake | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'utils.cmake') diff --git a/src/external/mini_al.h b/src/external/mini_al.h index 35846385..c9ab40fa 100644 --- a/src/external/mini_al.h +++ b/src/external/mini_al.h @@ -59,7 +59,7 @@ // // Building (BSD) // -------------- -// The BSD build uses OSS and should Just Work without any linking nor include path configuration. +// BSD build uses OSS. Requires linking to -lossaudio on {Open,Net}BSD, but not FreeBSD. // // Building (Emscripten) // --------------------- @@ -6712,6 +6712,10 @@ static mal_result mal_device__main_loop__alsa(mal_device* pDevice) #include #include +#ifndef SNDCTL_DSP_HALT +#define SNDCTL_DSP_HALT SNDCTL_DSP_RESET +#endif + int mal_open_temp_device__oss() { // The OSS sample code uses "/dev/mixer" as the device for getting system properties so I'm going to do the same. diff --git a/utils.cmake b/utils.cmake index 68fd1f76..dd4160d3 100644 --- a/utils.cmake +++ b/utils.cmake @@ -32,7 +32,11 @@ else() 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}) + if ("${CMAKE_SYSTEM_NAME}" MATCHES "(Net|Open)BSD") + find_library(OSS_LIBRARY ossaudio) + endif() + + set(LIBS_PRIVATE m ${pthread} ${OPENGL_LIBRARIES} ${X11_LIBRARIES} ${XRANDR_LIBRARY} ${XINERAMA_LIBRARY} ${XI_LIBRARY} ${XXF86VM_LIBRARY} ${XCURSOR_LIBRARY} ${OSS_LIBRARY}) endif() endif() -- cgit v1.2.3 From 1be72a2e72bcae18241d4a6dd6427aeaaf54e4d5 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Sun, 11 Feb 2018 20:00:04 +0100 Subject: pkg-config: Empty Requires.private on shared-only build If user doesn't build the static library, `pkg-config --static --libs raylib` should be equivalent to `pkg-config --libs raylib`. --- raylib.pc.in | 2 +- src/CMakeLists.txt | 4 +++- utils.cmake | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) (limited to 'utils.cmake') diff --git a/raylib.pc.in b/raylib.pc.in index 93984363..d71a5e2c 100644 --- a/raylib.pc.in +++ b/raylib.pc.in @@ -8,6 +8,6 @@ Description: Simple and easy-to-use library to learn videogames programming URL: http://github.com/raysan5/raylib Version: @PROJECT_VERSION@ Libs: -L${libdir} -lraylib -Libs.private:@PKG_CONFIG_LIBS_PRIVATE@ +Libs.private: @PKG_CONFIG_LIBS_PRIVATE@ Requires.private: Cflags: -I${includedir} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e9784ff4..40871455 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -137,6 +137,8 @@ if(${PLATFORM} MATCHES "PLATFORM_DESKTOP") PUBLIC ${GRAPHICS} ) + set(PKG_CONFIG_LIBS_PRIVATE ${__PKG_CONFIG_LIBS_PRIVATE}) + if (WITH_PIC) set_property(TARGET ${RAYLIB} PROPERTY POSITION_INDEPENDENT_CODE ON) endif() @@ -149,7 +151,7 @@ if(${PLATFORM} MATCHES "PLATFORM_DESKTOP") configure_file(../raylib.pc.in raylib.pc @ONLY) install(FILES ${CMAKE_BINARY_DIR}/release/raylib.pc DESTINATION lib/pkgconfig) - + # Copy the header files to the build directory file(COPY "raylib.h" DESTINATION ".") file(COPY "rlgl.h" DESTINATION ".") diff --git a/utils.cmake b/utils.cmake index dd4160d3..2c6a3771 100644 --- a/utils.cmake +++ b/utils.cmake @@ -74,8 +74,8 @@ foreach(L ${LIBS_PRIVATE}) set(LASTDIR ${DIR}) - set(PKG_CONFIG_LIBS_PRIVATE ${PKG_CONFIG_LIBS_PRIVATE} ${DIR_OPT} ${FILE_OPT}) - string (REPLACE ";" " " PKG_CONFIG_LIBS_PRIVATE "${PKG_CONFIG_LIBS_PRIVATE}") + set(__PKG_CONFIG_LIBS_PRIVATE ${__PKG_CONFIG_LIBS_PRIVATE} ${DIR_OPT} ${FILE_OPT}) + string (REPLACE ";" " " __PKG_CONFIG_LIBS_PRIVATE "${__PKG_CONFIG_LIBS_PRIVATE}") endforeach(L) @@ -86,7 +86,7 @@ function(link_libraries_to_executable executable) if (TARGET raylib_shared) target_link_libraries(${executable} raylib_shared) else() - target_link_libraries(${executable} raylib ${PKG_CONFIG_LIBS_PRIVATE}) + target_link_libraries(${executable} raylib ${__PKG_CONFIG_LIBS_PRIVATE}) endif() endfunction() -- cgit v1.2.3 From 3caa044bf259653eadcba5dc413101b95c6ebfbb Mon Sep 17 00:00:00 2001 From: Milan Nikolic Date: Sat, 7 Apr 2018 16:32:14 +0200 Subject: Add GNUInstallDirs and USE_AUDIO/USE_WAYLAND options to CMake (#518) --- src/CMakeLists.txt | 26 +++++++++++++++++--------- utils.cmake | 45 +++++++++++++++++++++++++++++++++++---------- 2 files changed, 52 insertions(+), 19 deletions(-) (limited to 'utils.cmake') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index db5d55c3..f02a5068 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,7 @@ # Setup the project and settings project(raylib) include("../utils.cmake") +include(GNUInstallDirs) set(PROJECT_VERSION 1.9.4) 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? option(SHARED "Build raylib as a dynamic library" OFF) 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) if(NOT (STATIC OR SHARED)) @@ -43,9 +45,15 @@ else() include_directories(external/glfw/include) endif() -file(GLOB stb_vorbis external/stb_vorbis.c) -file(GLOB mini_al external/mini_al.c ${stb_vorbis}) -set(sources ${raylib_sources} ${mini_al}) +if(USE_AUDIO) + file(GLOB stb_vorbis external/stb_vorbis.c) + file(GLOB mini_al external/mini_al.c ${stb_vorbis}) + 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 ### # 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(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") + set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_LIBDIR}") set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) set(CMAKE_MACOSX_RPATH ON) @@ -132,8 +140,8 @@ if(${PLATFORM} MATCHES "PLATFORM_DESKTOP") set_target_properties(${RAYLIB}_shared PROPERTIES OUTPUT_NAME ${RAYLIB}) install( TARGETS ${RAYLIB}_shared - LIBRARY DESTINATION lib - PUBLIC_HEADER DESTINATION include + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" ) endif() endif(${SHARED}) @@ -153,13 +161,13 @@ if(${PLATFORM} MATCHES "PLATFORM_DESKTOP") endif() set_target_properties(${RAYLIB} PROPERTIES PUBLIC_HEADER "raylib.h") install(TARGETS ${RAYLIB} - ARCHIVE DESTINATION lib - PUBLIC_HEADER DESTINATION include + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" ) endif(${STATIC}) 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 file(COPY "raylib.h" DESTINATION ".") diff --git a/utils.cmake b/utils.cmake index 2c6a3771..fc9ea8f6 100644 --- a/utils.cmake +++ b/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_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 # Will do nothing on other OSes if(APPLE) @@ -18,25 +22,47 @@ if(APPLE) elseif(WIN32) # no pkg-config --static on Windows yet... else() + if(USE_WAYLAND) + set(_GLFW_WAYLAND 1) + else() + set(_GLFW_X11 1) + endif() + 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) + if(NOT USE_WAYLAND) + # 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() + # 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() - 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) + if(NOT USE_WAYLAND) + 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) + 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}) if ("${CMAKE_SYSTEM_NAME}" MATCHES "(Net|Open)BSD") find_library(OSS_LIBRARY ossaudio) endif() - set(LIBS_PRIVATE m ${pthread} ${OPENGL_LIBRARIES} ${X11_LIBRARIES} ${XRANDR_LIBRARY} ${XINERAMA_LIBRARY} ${XI_LIBRARY} ${XXF86VM_LIBRARY} ${XCURSOR_LIBRARY} ${OSS_LIBRARY}) + 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}) + else() + set(LIBS_PRIVATE m ${pthread} ${OPENGL_LIBRARIES} ${WAYLAND_CLIENT_LIBRARY} ${WAYLAND_CURSOR_LIBRARY} ${WAYLAND_EGL_LIBRARY} ${OSS_LIBRARY}) + endif() endif() endif() @@ -49,7 +75,6 @@ if (glfw3_FOUND) set(LIBS_PRIVATE ${LIBS_PRIVATE} glfw) endif() - if(CMAKE_SYSTEM_NAME STREQUAL Linux) set(LINUX TRUE) set(LIBS_PRIVATE dl ${LIBS_PRIVATE}) -- cgit v1.2.3 From 1dbce352479f64748879fecb9df646654cd92229 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Sat, 7 Apr 2018 22:51:03 +0200 Subject: CMake: Generate config.h from CMakeOptions.txt I would have liked config.h to be selected by include dir configuration, but this way is less intrusive. --- src/CMakeLists.txt | 10 ++++--- src/CMakeOptions.txt | 62 ++++++++++++++++++++++++++++++++++++++++++- src/config.h | 8 ++++-- src/config.h.in | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++ utils.cmake | 12 +++------ 5 files changed, 151 insertions(+), 15 deletions(-) create mode 100644 src/config.h.in (limited to 'utils.cmake') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7bf8e3b0..632669ea 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,22 +1,26 @@ # Setup the project and settings project(raylib) -include("../utils.cmake") include(GNUInstallDirs) set(PROJECT_VERSION 1.9.4) set(API_VERSION 1) set(RAYLIB raylib) # Name of the generated library +include("CMakeOptions.txt") +configure_file(config.h.in ${CMAKE_BINARY_DIR}/cmake/config.h) +include_directories(${CMAKE_BINARY_DIR}) + +include("../utils.cmake") + # Get the sources together file(GLOB raylib_sources *.c) + if(glfw3_FOUND) list(REMOVE_ITEM raylib_sources ${CMAKE_CURRENT_SOURCE_DIR}/rglfw.c) else() include_directories(external/glfw/include) endif() -include("CMakeOptions.txt") - if(USE_AUDIO) file(GLOB stb_vorbis external/stb_vorbis.c) file(GLOB mini_al external/mini_al.c ${stb_vorbis}) diff --git a/src/CMakeOptions.txt b/src/CMakeOptions.txt index ef530d8e..7fc7a915 100644 --- a/src/CMakeOptions.txt +++ b/src/CMakeOptions.txt @@ -1,11 +1,19 @@ ### Config options ### +include(CMakeDependentOption) # Shared library is always PIC. Static library should be PIC too if linked into a shared library option(WITH_PIC "Compile static library as position-independent code" OFF) option(SHARED "Build raylib as a dynamic library" OFF) 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(USE_AUDIO "Build raylib with audio module" ON) +cmake_dependent_option(USE_OPENAL_BACKEND "Link raylib with openAL instead of mini-al" OFF "USE_AUDIO" OFF) +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) +if(UNIX AND NOT APPLE) + option(USE_WAYLAND "Use Wayland for window creation" OFF) +endif() + set(PLATFORM "Desktop" CACHE STRING "Platform to build for.") set_property(CACHE PLATFORM PROPERTY STRINGS "Desktop" "Web" "Android" "Raspberry Pi") @@ -13,6 +21,58 @@ set_property(CACHE PLATFORM PROPERTY STRINGS "Desktop" "Web" "Android" "Raspberr set(OPENGL_VERSION "3.3" CACHE STRING "OpenGL Version to build raylib with") set_property(CACHE OPENGL_VERSION PROPERTY STRINGS "3.3" "2.1" "1.1" "ES 2.0") +# core.c +option(SUPPORT_BUSY_WAIT_LOOP "Use busy wait loop for timing sync instead of a high-resolution timer" ON) +option(SUPPORT_CAMERA_SYSTEM "Provide camera module (camera.h) with multiple predefined cameras: free, 1st/3rd person, orbital" ON) +option(SUPPORT_DEFAULT_FONT "Default font is loaded on window initialization to be available for the user to render simple text. If enabled, uses external module functions to load default raylib font (module: text)" ON) +option(SUPPORT_GIF_RECORDING "Allow automatic gif recording of current screen pressing CTRL+F12, defined in KeyCallback()" ON) +option(SUPPORT_GESTURES_SYSTEM "Gestures module is included (gestures.h) to support gestures detection: tap, hold, swipe, drag" ON) +option(SUPPORT_MOUSE_GESTURES "Mouse gestures are directly mapped like touches and processed by gestures system" ON) + +# rlgl.c +option(SUPPORT_VR_SIMULATOR "Support VR simulation functionality (stereo rendering)" ON) +option(SUPPORT_DISTORTION_SHADER "Include stereo rendering distortion shader (shader_distortion.h)" ON) + +# models.c +option(SUPPORT_FILEFORMAT_OBJ "Support loading OBJ file format" ON) +option(SUPPORT_FILEFORMAT_MTL "Support loading MTL file format" ON) +option(SUPPORT_MESH_GENERATION "Support procedural mesh generation functions, uses external par_shapes.h library. NOTE: Some generated meshes DO NOT include generated texture coordinates" ON) + +# textures.c +option(SUPPORT_IMAGE_GENERATION "Support proedural image generation functionality (gradient, spot, perlin-noise, cellular)" ON) +option(SUPPORT_FILEFORMAT_PNG "Support loading PNG as textures" ON) +option(SUPPORT_FILEFORMAT_DDS "Support loading DDS as textures" ON) +option(SUPPORT_FILEFORMAT_HDR "Support loading HDR as textures" ON) +option(SUPPORT_FILEFORMAT_KTX "Support loading KTX as textures" ON) +option(SUPPORT_FILEFORMAT_ASTC "Support loading ASTC as textures" ON) +option(SUPPORT_FILEFORMAT_BMP "Support loading BMP as textures" OFF) +option(SUPPORT_FILEFORMAT_TGA "Support loading TGA as textures" OFF) +option(SUPPORT_FILEFORMAT_JPG "Support loading JPG as textures" OFF) +option(SUPPORT_FILEFORMAT_GIF "Support loading GIF as textures" OFF) +option(SUPPORT_FILEFORMAT_PSD "Support loading PSD as textures" OFF) +option(SUPPORT_FILEFORMAT_PKM "Support loading PKM as textures" OFF) +option(SUPPORT_FILEFORMAT_PVR "Support loading PVR as textures" OFF) + +# audio.c +option(SUPPORT_FILEFORMAT_WAV "Support loading WAV for sound" ON) +option(SUPPORT_FILEFORMAT_OGG "Support loading OGG for sound" ON) +option(SUPPORT_FILEFORMAT_XM "Support loading XM for sound" ON) +option(SUPPORT_FILEFORMAT_MOD "Support loading MOD for sound" ON) +option(SUPPORT_FILEFORMAT_FLAC "Support loading FLAC for sound" OFF) + +# shapes.c +option(USE_DEFAULT_FONT_TEXTURE "Draw rectangle shapes using font texture white character instead of default white texture. Allows drawing rectangles and text with a single draw call, very useful for GUI systems!" ON) + +# utils.c +option(SUPPORT_SAVE_PNG "Support saving image data in PNG file format" ON) +option(SUPPORT_SAVE_BMP "Support saving image data in BMP file format" OFF) +option(SUPPORT_TRACELOG "Show TraceLog() output messages. NOTE: By default LOG_DEBUG traces not shown" ON) + +option(SUPPORT_FILEFORMAT_FNT "Support loading fonts in FNT format" ON) +option(SUPPORT_FILEFORMAT_TTF "Support loading font in TTF format" ON) + +option(SUPPORT_IMAGE_MANIPULATION "Support multiple image editing functions to scale, adjust colors, flip, draw on images, crop... If not defined only three image editing functions supported: ImageFormat(), ImageAlphaMask(), ImageToPOT()" ON) + if(NOT (STATIC OR SHARED)) message(FATAL_ERROR "Nothing to do if both -DSHARED=OFF and -DSTATIC=OFF...") endif() diff --git a/src/config.h b/src/config.h index 40b9d7c4..0013c131 100644 --- a/src/config.h +++ b/src/config.h @@ -1,5 +1,7 @@ -/* Edit to control what features raylib is compiled with. */ - +/* Edit to control what features Makefile'd raylib is compiled with. */ +#ifdef RAYLIB_CMAKE /* Edit CMakeOptions.txt for CMake instead! */ +#include "cmake/config.h" +#else // text.c /* Default font is loaded on window initialization to be available for the user to render simple text. NOTE: If enabled, uses external module functions to load default raylib font (module: text) */ #define SUPPORT_DEFAULT_FONT 1 @@ -72,3 +74,5 @@ #define SUPPORT_SAVE_PNG 1 /* Support saving image data as PMP fileformat. NOTE: Requires stb_image_write library */ /* #undef SUPPORT_SAVE_BMP */ + +#endif diff --git a/src/config.h.in b/src/config.h.in new file mode 100644 index 00000000..5b6ed054 --- /dev/null +++ b/src/config.h.in @@ -0,0 +1,74 @@ +/* config.h.in */ + +// text.c +/* Default font is loaded on window initialization to be available for the user to render simple text. NOTE: If enabled, uses external module functions to load default raylib font (module: text) */ +#cmakedefine SUPPORT_DEFAULT_FONT 1 +/* Selected desired fileformats to be supported for loading. */ +#cmakedefine SUPPORT_FILEFORMAT_FNT 1 +#cmakedefine SUPPORT_FILEFORMAT_TTF 1 + +// textures.c +/* Selecte desired fileformats to be supported for image data loading. */ +#cmakedefine SUPPORT_FILEFORMAT_PNG 1 +#cmakedefine SUPPORT_FILEFORMAT_DDS 1 +#cmakedefine SUPPORT_FILEFORMAT_HDR 1 +#cmakedefine SUPPORT_FILEFORMAT_KTX 1 +#cmakedefine SUPPORT_FILEFORMAT_ASTC 1 +#cmakedefine SUPPORT_FILEFORMAT_BMP 1 +#cmakedefine SUPPORT_FILEFORMAT_TGA 1 +#cmakedefine SUPPORT_FILEFORMAT_JPG 1 +#cmakedefine SUPPORT_FILEFORMAT_GIF 1 +#cmakedefine SUPPORT_FILEFORMAT_PSD 1 +#cmakedefine SUPPORT_FILEFORMAT_PKM 1 +#cmakedefine SUPPORT_FILEFORMAT_PVR 1 + +/* Support multiple image editing functions to scale, adjust colors, flip, draw on images, crop... If not defined only three image editing functions supported: ImageFormat(), ImageAlphaMask(), ImageToPOT() */ +#cmakedefine SUPPORT_IMAGE_MANIPULATION 1 + +/* Support proedural image generation functionality (gradient, spot, perlin-noise, cellular) */ +#cmakedefine SUPPORT_IMAGE_GENERATION 1 + +// rlgl.c +/* Support VR simulation functionality (stereo rendering) */ +#cmakedefine SUPPORT_VR_SIMULATOR 1 +/* Include stereo rendering distortion shader (shader_distortion.h) */ +#cmakedefine SUPPORT_DISTORTION_SHADER 1 + +// core.c +/* Camera module is included (camera.h) and multiple predefined cameras are available: free, 1st/3rd person, orbital */ +#cmakedefine SUPPORT_CAMERA_SYSTEM 1 +/* Gestures module is included (gestures.h) to support gestures detection: tap, hold, swipe, drag */ +#cmakedefine SUPPORT_GESTURES_SYSTEM 1 +/* Mouse gestures are directly mapped like touches and processed by gestures system. */ +#cmakedefine SUPPORT_MOUSE_GESTURES 1 +/* Use busy wait loop for timing sync, if not defined, a high-resolution timer is setup and used */ +#cmakedefine SUPPORT_BUSY_WAIT_LOOP 1 +/* Allow automatic gif recording of current screen pressing CTRL+F12, defined in KeyCallback() */ +#cmakedefine SUPPORT_GIF_RECORDING 1 + +// audio.c +/* Desired fileformats to be supported for loading. */ +#cmakedefine SUPPORT_FILEFORMAT_WAV 1 +#cmakedefine SUPPORT_FILEFORMAT_OGG 1 +#cmakedefine SUPPORT_FILEFORMAT_XM 1 +#cmakedefine SUPPORT_FILEFORMAT_MOD 1 +#cmakedefine SUPPORT_FILEFORMAT_FLAC 1 + +// models.c +/* Selected desired fileformats to be supported for loading. */ +#cmakedefine SUPPORT_FILEFORMAT_OBJ 1 +#cmakedefine SUPPORT_FILEFORMAT_MTL 1 + +/* Support procedural mesh generation functions, uses external par_shapes.h library + * NOTE: Some generated meshes DO NOT include generated texture coordinates + */ +#cmakedefine SUPPORT_MESH_GENERATION 1 + +// utils.c +/* Show TraceLog() output messages. NOTE: By default LOG_DEBUG traces not shown */ +#cmakedefine SUPPORT_TRACELOG 1 + +/* Support saving image data as PNG fileformat. NOTE: Requires stb_image_write library */ +#cmakedefine SUPPORT_SAVE_PNG 1 +/* Support saving image data as PMP fileformat. NOTE: Requires stb_image_write library */ +#cmakedefine SUPPORT_SAVE_BMP 1 diff --git a/utils.cmake b/utils.cmake index fc9ea8f6..71e34e01 100644 --- a/utils.cmake +++ b/utils.cmake @@ -1,12 +1,7 @@ # All sorts of things that we need cross project cmake_minimum_required(VERSION 2.8.0) -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) - -if(UNIX AND NOT APPLE) - option(USE_WAYLAND "Use Wayland for window creation" OFF) -endif() +add_definitions("-DRAYLIB_CMAKE=1") # Linking for OS X -framework options # Will do nothing on other OSes @@ -29,7 +24,7 @@ else() endif() find_library(pthread NAMES pthread) - find_package(OpenGL) + find_package(OpenGL QUIET) if ("${OPENGL_LIBRARIES}" STREQUAL "") if(NOT USE_WAYLAND) # CFLAGS=-m32 cmake on Linux fails for some reason, so fallback to hardcoding @@ -69,7 +64,7 @@ endif() if(USE_EXTERNAL_GLFW STREQUAL "ON") find_package(glfw3 3.2.1 REQUIRED) elseif(USE_EXTERNAL_GLFW STREQUAL "IF_POSSIBLE") - find_package(glfw3 3.2.1) + find_package(glfw3 3.2.1 QUIET) endif() if (glfw3_FOUND) set(LIBS_PRIVATE ${LIBS_PRIVATE} glfw) @@ -114,4 +109,3 @@ function(link_libraries_to_executable executable) target_link_libraries(${executable} raylib ${__PKG_CONFIG_LIBS_PRIVATE}) endif() endfunction() - -- cgit v1.2.3