aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAhmad Fatoum <ahmad@a3f.at>2018-07-29 12:56:19 +0200
committerGitHub <noreply@github.com>2018-07-29 12:56:19 +0200
commit6905a875eda7e1ac85b768f5aa4e07dc92537bdb (patch)
treef8bf880840312d42478043a04bc7f273f892b180
parentcf021e38117723b655a2399e62f8d5f87ce3d413 (diff)
parent5a94a280d0a7d2866a12e6f9144401881e17de02 (diff)
downloadraylib-6905a875eda7e1ac85b768f5aa4e07dc92537bdb.tar.gz
raylib-6905a875eda7e1ac85b768f5aa4e07dc92537bdb.zip
Merge pull request #608 from a3f/master
CMake: Major cleanup to support find_package(raylib)
-rw-r--r--.travis.yml50
-rw-r--r--CMakeLists.txt2
-rw-r--r--appveyor.yml2
-rw-r--r--cmake/LibraryPathToLinkerFlags.cmake24
-rw-r--r--cmake/PopulateConfigVariablesLocally.cmake11
-rw-r--r--cmake/raylib-config-version.cmake21
-rw-r--r--cmake/raylib-config.cmake68
-rw-r--r--cmake/utils.cmake85
-rw-r--r--examples/CMakeLists.txt37
-rw-r--r--games/CMakeLists.txt15
-rw-r--r--games/drturtle/CMakeLists.txt17
-rw-r--r--games/just_do/CMakeLists.txt17
-rw-r--r--games/koala_seasons/CMakeLists.txt17
-rw-r--r--games/light_my_ritual/CMakeLists.txt17
-rw-r--r--games/skully_escape/CMakeLists.txt17
-rw-r--r--games/wave_collector/CMakeLists.txt17
-rw-r--r--src/CMakeLists.txt213
-rw-r--r--src/CMakeOptions.txt25
-rw-r--r--src/core.c6
19 files changed, 377 insertions, 284 deletions
diff --git a/.travis.yml b/.travis.yml
index 44527b49..ec4a8ebd 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -17,10 +17,10 @@ matrix:
env: ARCH=amd64 INSTALL_GLFW=YES USE_EXTERNAL_GLFW=OFF
sudo: required
- os: linux
- env: ARCH=amd64 INSTALL_GLFW=YES RELEASE=NO
+ env: ARCH=amd64 INSTALL_GLFW=YES OPENAL=ON STATIC=OFF RELEASE=NO
sudo: required
- os: linux
- env: USE_WAYLAND=ON ARCH=amd64 RELEASE=NO
+ env: WAYLAND=ON ARCH=amd64 RELEASE=NO
sudo: required
addons:
apt:
@@ -46,25 +46,27 @@ matrix:
before_script:
before_install:
- - if [ -z "$USE_EXTERNAL_GLFW" ]; then
- export USE_EXTERNAL_GLFW=IF_POSSIBLE;
- fi
- - if [ -z "$SHARED" ]; then
- export SHARED=ON;
+ - if [ -z "$USE_EXTERNAL_GLFW" ]; then export USE_EXTERNAL_GLFW=IF_POSSIBLE; fi
+ - if [ -z "$SHARED" ]; then export SHARED=ON ; fi
+ - if [ -z "$STATIC" ]; then export STATIC=ON ; fi
+ - if [ -z "$OPENAL" ]; then export OPENAL=OFF; fi
+ - if [[ "$INSTALL_GLFW" == "YES" && "$USE_EXTERNAL_GLFW" != "OFF" ]]; then
+ export DONT_TEST=1;
fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then
if [[ "$ARCH" == *-android ]]; then
+ export DONT_TEST=1;
export RAYLIB_PACKAGE_SUFFIX="-Android-arm64";
wget https://dl.google.com/android/repository/android-ndk-r17-linux-x86_64.zip;
unzip -qq android-ndk*.zip;
if [[ "$ARCH" == arm64-* ]]; then
export RAYLIB_PACKAGE_SUFFIX="-Android-arm64";
- export TOOLCHAIN_ARCH=arm64;
- export PREFIX=aarch64-linux-android-;
+ TOOLCHAIN_ARCH=arm64;
+ PREFIX=aarch64-linux-android-;
else
export RAYLIB_PACKAGE_SUFFIX="-Android-arm32";
- export TOOLCHAIN_ARCH=arm;
- export PREFIX=arm-linux-androideabi-;
+ TOOLCHAIN_ARCH=arm;
+ PREFIX=arm-linux-androideabi-;
fi;
android-ndk*/build/tools/make_standalone_toolchain.py --arch $TOOLCHAIN_ARCH --api 21 --install-dir /tmp/android-toolchain;
export PATH=/tmp/android-toolchain/bin:$PATH;
@@ -72,19 +74,21 @@ before_install:
export CXX=${PREFIX}clang++;
export CMAKE_ARCH_ARGS='-DPLATFORM=Android';
elif [ "$ARCH" == "html5" ]; then
+ export DONT_TEST=1;
export RAYLIB_PACKAGE_SUFFIX="-html5";
docker run --privileged=true -dit --name emscripten -v $(pwd):/src trzeci/emscripten:sdk-incoming-64bit bash;
export CMAKE_ARCH_ARGS='-DPLATFORM=Web -DCMAKE_TOOLCHAIN_FILE=../cmake/emscripten.cmake';
- export RUNNER='docker exec -it emscripten cmake -E chdir build';
+ RUNNER='docker exec -it emscripten cmake -E chdir build';
else
sudo apt-get install -y gcc-multilib
libasound2-dev:$ARCH
libxcursor-dev:$ARCH libxinerama-dev:$ARCH mesa-common-dev:$ARCH
libx11-dev:$ARCH libxrandr-dev:$ARCH libxrandr2:$ARCH libxi-dev:$ARCH
libgl1-mesa-dev:$ARCH libglu1-mesa-dev:$ARCH;
- if [ "$ARCH" == "i386" ]; then
- export CMAKE_ARCH_ARGS='-DCMAKE_C_FLAGS=-m32 -DCMAKE_SYSTEM_LIBRARY_PATH=/usr/lib/i386-linux-gnu';
- fi;
+
+ if [ "$OPENAL" == "ON" ]; then sudo apt-get install -y libopenal-dev; fi;
+ if [ "$ARCH" == "i386" ]; then export CMAKE_ARCH_ARGS='-DCMAKE_C_FLAGS=-m32 -DCMAKE_SYSTEM_LIBRARY_PATH=/usr/lib/i386-linux-gnu -DSUPPORT_FILEFORMAT_FLAC=OFF'; fi;
+
export RAYLIB_PACKAGE_SUFFIX="-Linux-$ARCH";
if [ "$INSTALL_GLFW" == "YES" ]; then
wget 'http://ftp.de.debian.org/debian/pool/main/g/glfw3/libglfw3_3.2.1-1_amd64.deb';
@@ -102,7 +106,7 @@ before_install:
script:
- cd build
- - if test -n "${USE_WAYLAND}";
+ - if test -n "$WAYLAND";
then wget https://mirrors.kernel.org/ubuntu/pool/universe/e/extra-cmake-modules/extra-cmake-modules_5.38.0a-0ubuntu1_amd64.deb;
sudo dpkg -i extra-cmake-modules_5.38.0a-0ubuntu1_amd64.deb;
git clone git://anongit.freedesktop.org/wayland/wayland-protocols;
@@ -110,11 +114,19 @@ script:
git checkout 1.12 && ./autogen.sh --prefix=/usr && make && sudo make install;
popd;
fi
- - $RUNNER cmake $CMAKE_ARCH_ARGS -DMACOS_FATLIB=ON -DSTATIC=ON -DSHARED=$SHARED -DBUILD_EXAMPLES=ON -DBUILD_GAMES=ON -DUSE_EXTERNAL_GLFW=$USE_EXTERNAL_GLFW -DUSE_WAYLAND=${USE_WAYLAND} ..
+ - $RUNNER cmake $CMAKE_ARCH_ARGS
+ -DMACOS_FATLIB=ON
+ -DSTATIC=$STATIC -DSHARED=$SHARED
+ -DBUILD_EXAMPLES=ON -DBUILD_GAMES=ON
+ -DUSE_EXTERNAL_GLFW=$USE_EXTERNAL_GLFW
+ -DUSE_WAYLAND=$WAYLAND
+ -DUSE_OPENAL_BACKEND=$OPENAL
+ -DINCLUDE_EVERYTHING=ON
+ ..
- $RUNNER make VERBOSE=1
- - if [ "$RELEASE" != "NO" ]; then $RUNNER make package; fi;
+ - if [ "$RELEASE" != "NO" ]; then $RUNNER make package; fi
- sudo $RUNNER make install
- - if [[ "$ARCH" != *-android && "$ARCH" != html5 ]]; then
+ - if [ ! "$DONT_TEST" ]; then
pkg-config --static --libs raylib;
nm -g release/libraylib.a | grep glfwGetProcAddress || (echo "libraylib.a doesn't contain GLFW symbols! Aborting..." && false);
ctest --output-on-failure;
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a61229ab..aebd4c4b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,7 +6,7 @@ option(BUILD_EXAMPLES "Build the examples." ON)
option(BUILD_GAMES "Build the example games." ON)
option(ENABLE_ASAN "Enable AddressSanitizer (ASAN) for debugging (degrades performance)" OFF)
option(ENABLE_UBSAN "Enable UndefinedBehaviorSanitizer (UBSan) for debugging" OFF)
-option(ENABLE_MSAN "Enable MemorySanitizer (MSan) for debugging (not recommended for run with ASAN)" OFF)
+option(ENABLE_MSAN "Enable MemorySanitizer (MSan) for debugging (not recommended to run with ASAN)" OFF)
if(CMAKE_VERSION VERSION_LESS "3.1")
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
diff --git a/appveyor.yml b/appveyor.yml
index 6452a089..f48486b0 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -39,7 +39,7 @@ before_build:
- cd build
build_script:
- - cmake -G %GENERATOR% -DSTATIC=ON -DSHARED=ON -DBUILD_EXAMPLES=%examples% -DBUILD_GAMES=%examples% ..
+ - cmake -G %GENERATOR% -DSTATIC=ON -DSHARED=ON -DBUILD_EXAMPLES=%examples% -DBUILD_GAMES=%examples% -DINCLUDE_EVERYTHING=ON ..
- cmake --build . --target install
after_build:
diff --git a/cmake/LibraryPathToLinkerFlags.cmake b/cmake/LibraryPathToLinkerFlags.cmake
new file mode 100644
index 00000000..05942b75
--- /dev/null
+++ b/cmake/LibraryPathToLinkerFlags.cmake
@@ -0,0 +1,24 @@
+function(library_path_to_linker_flags LD_FLAGS LIB_PATHS)
+ foreach(L ${LIB_PATHS})
+ 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(${LD_FLAGS} ${${LD_FLAGS}} ${DIR_OPT} ${FILE_OPT} PARENT_SCOPE)
+ string (REPLACE ";" " " ${LD_FLAGS} "${${LD_FLAGS}}")
+ endforeach()
+endfunction()
diff --git a/cmake/PopulateConfigVariablesLocally.cmake b/cmake/PopulateConfigVariablesLocally.cmake
new file mode 100644
index 00000000..151070ea
--- /dev/null
+++ b/cmake/PopulateConfigVariablesLocally.cmake
@@ -0,0 +1,11 @@
+macro(populate_config_variables_locally target)
+ get_property(raylib_INCLUDE_DIRS TARGET ${target} PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
+ #get_property(raylib_LIBRARIES TARGET ${target} PROPERTY LOCATION) # only works for SHARED
+ get_property(raylib_LDFLAGS TARGET ${target} PROPERTY INTERFACE_LINK_LIBRARIES)
+ get_property(raylib_DEFINITIONS TARGET ${target} PROPERTY DEFINITIONS)
+
+ set(raylib_INCLUDE_DIRS "${raylib_INCLUDE_DIRS}" PARENT_SCOPE)
+ #set(raylib_LIBRARIES "${raylib_INCLUDE_DIRS}" PARENT_SCOPE)
+ set(raylib_LDFLAGS "${raylib_LDFLAGS}" PARENT_SCOPE)
+ set(raylib_DEFINITIONS "${raylib_DEFINITIONS}" PARENT_SCOPE)
+endmacro()
diff --git a/cmake/raylib-config-version.cmake b/cmake/raylib-config-version.cmake
new file mode 100644
index 00000000..74fd03cc
--- /dev/null
+++ b/cmake/raylib-config-version.cmake
@@ -0,0 +1,21 @@
+set(PACKAGE_VERSION "@PROJECT_VERSION@")
+
+if(PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION)
+ set(PACKAGE_VERSION_EXACT TRUE)
+endif()
+if(NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION)
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+else(NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION)
+ set(PACKAGE_VERSION_UNSUITABLE TRUE)
+endif(NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION)
+
+# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
+if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "@CMAKE_SIZEOF_VOID_P@" STREQUAL "")
+ return()
+endif()
+
+if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "@CMAKE_SIZEOF_VOID_P@")
+ math(EXPR installedBits "8 * 8")
+ set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
+ set(PACKAGE_VERSION_UNSUITABLE TRUE)
+endif()
diff --git a/cmake/raylib-config.cmake b/cmake/raylib-config.cmake
new file mode 100644
index 00000000..e2e5e9ae
--- /dev/null
+++ b/cmake/raylib-config.cmake
@@ -0,0 +1,68 @@
+# - Try to find raylib
+# Options:
+# raylib_USE_STATIC_LIBS - OFF by default
+# raylib_VERBOSE - OFF by default
+# Once done, this defines a raylib target that can be passed to
+# target_link_libraries as well as following variables:
+#
+# raylib_FOUND - System has raylib installed
+# raylib_INCLUDE_DIRS - The include directories for the raylib header(s)
+# raylib_LIBRARIES - The libraries needed to use raylib
+# raylib_LDFLAGS - The linker flags needed with raylib
+# raylib_DEFINITIONS - Compiler switches required for using raylib
+
+set(XPREFIX PC_RAYLIB)
+if (raylib_USE_STATIC_LIBS)
+ set(XPREFIX ${XPREFIX}_STATIC)
+endif()
+
+find_package(PkgConfig)
+pkg_check_modules(${XPREFIX} REQUIRED raylib)
+set(raylib_DEFINITIONS ${${XPREFIX}_CFLAGS})
+
+find_path(raylib_INCLUDE_DIR
+ NAMES raylib.h
+ HINTS ${${XPREFIX}_INCLUDE_DIRS}
+)
+
+find_library(raylib_LIBRARY
+ NAMES raylib
+ HINTS ${${XPREFIX}_LIBRARY_DIRS}
+)
+
+set(raylib_LIBRARIES ${raylib_LIBRARY})
+set(raylib_LIBRARY_DIRS ${${XPREFIX}_LIBRARY_DIRS})
+set(raylib_LIBRARY_DIR ${raylib_LIBRARY_DIRS})
+set(raylib_INCLUDE_DIRS ${raylib_INCLUDE_DIR})
+set(raylib_LDFLAGS ${${XPREFIX}_LDFLAGS})
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(raylib DEFAULT_MSG
+ raylib_LIBRARY
+ raylib_INCLUDE_DIR
+)
+
+mark_as_advanced(raylib_LIBRARY raylib_INCLUDE_DIR)
+
+if (raylib_USE_STATIC_LIBS)
+ add_library(raylib STATIC IMPORTED GLOBAL)
+else()
+ add_library(raylib SHARED IMPORTED GLOBAL)
+endif()
+string (REPLACE ";" " " raylib_LDFLAGS "${raylib_LDFLAGS}")
+
+set_target_properties(raylib
+ PROPERTIES
+ IMPORTED_LOCATION "${raylib_LIBRARIES}"
+ INTERFACE_INCLUDE_DIRECTORIES "${raylib_INCLUDE_DIRS}"
+ INTERFACE_LINK_LIBRARIES "${raylib_LDFLAGS}"
+ INTERFACE_COMPILE_OPTIONS "${raylib_DEFINITIONS}"
+)
+
+if (raylib_VERBOSE)
+ message(STATUS "raylib_FOUND: ${raylib_FOUND}")
+ message(STATUS "raylib_INCLUDE_DIRS: ${raylib_INCLUDE_DIRS}")
+ message(STATUS "raylib_LIBRARIES: ${raylib_LIBRARIES}")
+ message(STATUS "raylib_LDFLAGS: ${raylib_LDFLAGS}")
+ message(STATUS "raylib_DEFINITIONS: ${raylib_DEFINITIONS}")
+endif()
diff --git a/cmake/utils.cmake b/cmake/utils.cmake
deleted file mode 100644
index 417384ad..00000000
--- a/cmake/utils.cmake
+++ /dev/null
@@ -1,85 +0,0 @@
-# All sorts of things that we need cross project
-cmake_minimum_required(VERSION 2.8.0)
-
-add_definitions("-DRAYLIB_CMAKE=1")
-
-# Linking for OS X -framework options
-# Will do nothing on other OSes
-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)
- find_library(OPENGL_LIBRARY OpenGL)
-
- set(LIBS_PRIVATE ${OPENGL_LIBRARY})
-elseif(WIN32)
- # no pkg-config --static on Windows yet...
-else()
- find_library(pthread NAMES pthread)
- find_package(OpenGL QUIET)
- if ("${OPENGL_LIBRARIES}" STREQUAL "")
- set(OPENGL_LIBRARIES "GL")
- 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} ${OSS_LIBRARY})
-endif()
-
-if(${PLATFORM} MATCHES "Desktop")
- 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 QUIET)
- endif()
- if (glfw3_FOUND)
- set(LIBS_PRIVATE ${LIBS_PRIVATE} glfw)
- endif()
-endif()
-
-if(CMAKE_SYSTEM_NAME STREQUAL Linux)
- set(LINUX TRUE)
-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)
- # Link raylib
- if (TARGET raylib_shared)
- target_link_libraries(${executable} raylib_shared)
- elseif(${PLATFORM} MATCHES "Web")
- target_link_libraries(${executable} ${__PKG_CONFIG_LIBS_PRIVATE})
- target_link_libraries(${executable} raylib)
- else()
- target_link_libraries(${executable} raylib ${__PKG_CONFIG_LIBS_PRIVATE})
- endif()
-endfunction()
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index a214c171..90a1e902 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -1,15 +1,6 @@
# Setup the project and settings
project(examples)
-include("../cmake/utils.cmake")
-
-# Make sure raylib has been built
-# 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 shaders shapes text textures)
set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=199309L)
@@ -34,12 +25,12 @@ foreach(example_dir ${example_dirs})
endforeach()
include(CheckIncludeFiles)
-list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/standard_lighting.c)
-list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/rlgl_standalone.c) # see #588
set(OUTPUT_EXT)
+list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/rlgl_standalone.c)
if(${PLATFORM} MATCHES "Android")
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/rlgl_standalone.c)
+ list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/standard_lighting.c)
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_3d_picking.c)
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_vr_simulator.c)
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_3d_camera_free.c)
@@ -58,12 +49,19 @@ if(${PLATFORM} MATCHES "Android")
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_custom_uniform.c)
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_model_shader.c)
list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_postprocessing.c)
+
elseif(${PLATFORM} MATCHES "Web")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Os -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --shell-file ${CMAKE_SOURCE_DIR}/templates/web_shell/shell.html")
set(OUTPUT_EXT ".html")
+
endif()
+include_directories(BEFORE SYSTEM others/external/include)
+
+if (NOT TARGET raylib)
+ find_package(raylib 2.0 REQUIRED)
+endif()
# Do each example
foreach(example_source ${example_sources})
@@ -74,9 +72,22 @@ foreach(example_source ${example_sources})
# Setup the example
add_executable(${example_name} ${example_source})
- # Link the libraries
- link_libraries_to_executable(${example_name})
+ target_link_libraries(${example_name} raylib)
endforeach()
+if (${PLATFORM} MATCHES "Desktop")
+ # rlgl_standalone can't be linked with raylib because of duplicate rlgl symbols
+ foreach (example_source "others/rlgl_standalone.c")
+ # Create the basename for the example
+ get_filename_component(example_name ${example_source} NAME)
+ string(REPLACE ".c" "${OUTPUT_EXT}" example_name ${example_name})
+ add_executable(${example_name} ${example_source})
+ add_dependencies(${example_name} raylib)
+ target_link_libraries(${example_name} ${raylib_LDFLAGS})
+ target_include_directories(${example_name} PRIVATE ${raylib_INCLUDE_DIRS})
+
+ endforeach()
+endif()
+
# Copy all of the resource files to the destination
file(COPY ${example_resources} DESTINATION "resources/")
diff --git a/games/CMakeLists.txt b/games/CMakeLists.txt
index 563dbb61..d3f9d9fc 100644
--- a/games/CMakeLists.txt
+++ b/games/CMakeLists.txt
@@ -1,17 +1,9 @@
# Setup the project and settings
project(games)
-include("../cmake/utils.cmake")
-
-# Make sure raylib has been built
-# TODO `build` directory should maybe be something else...
-# TODO place somewhere else?
-include_directories("../build/release")
-
# Get the source toegher
file(GLOB sources *.c)
-message("PLATFORM = ${PLATFORM}")
set(OUTPUT_EXT)
if(${PLATFORM} MATCHES "Web")
@@ -20,18 +12,21 @@ if(${PLATFORM} MATCHES "Web")
set(OUTPUT_EXT ".html")
endif()
+if (NOT TARGET raylib)
+ find_package(raylib 2.0 REQUIRED)
+endif()
# Do each game
foreach(game_source ${sources})
# Create the basename for the game
get_filename_component(game_name ${game_source} NAME)
string(REPLACE ".c" "${OUTPUT_EXT}" game_name ${game_name})
-
+
# Setup the game
add_executable(${game_name} ${game_source})
# Link the libraries
- link_libraries_to_executable(${game_name})
+ target_link_libraries(${game_name} raylib)
endforeach()
# Do the games with subdirectories
diff --git a/games/drturtle/CMakeLists.txt b/games/drturtle/CMakeLists.txt
index bdd91970..f5778d9c 100644
--- a/games/drturtle/CMakeLists.txt
+++ b/games/drturtle/CMakeLists.txt
@@ -1,18 +1,13 @@
-# Setup the project and settings
+cmake_minimum_required(VERSION 2.6)
project(drturtle)
-include("../../cmake/utils.cmake")
-
-
-# Make sure raylib has been built
-# TODO `build` directory should maybe be something else...
-include_directories("../../build/release")
-
# Executable & linking
-add_executable(drturtle 06_drturtle_final.c)
-link_libraries_to_executable(drturtle)
+add_executable(${PROJECT_NAME} 06_drturtle_final.c)
+if (NOT TARGET raylib)
+ find_package(raylib 2.0 REQUIRED)
+endif()
+target_link_libraries(${PROJECT_NAME} raylib)
# Resources
# Copy all of the resource files to the destination
file(COPY "resources/" DESTINATION "resources/")
-
diff --git a/games/just_do/CMakeLists.txt b/games/just_do/CMakeLists.txt
index 4c5e1ee4..f25b6e37 100644
--- a/games/just_do/CMakeLists.txt
+++ b/games/just_do/CMakeLists.txt
@@ -1,21 +1,16 @@
-# Setup the project and settings
+cmake_minimum_required(VERSION 2.6)
project(just_do)
-include("../../cmake/utils.cmake")
-
-
-# Make sure raylib has been built
-# TODO `build` directory should maybe be something else...
-include_directories("../../build/release")
-
# Grab the screens
file(GLOB screen_sources "screens/*.c")
# Executable & linking
-add_executable(just_do just_do.c ${screen_sources})
-link_libraries_to_executable(just_do)
+add_executable(${PROJECT_NAME} ${PROJECT_NAME}.c ${screen_sources})
+if (NOT TARGET raylib)
+ find_package(raylib 2.0 REQUIRED)
+endif()
+target_link_libraries(${PROJECT_NAME} raylib)
# Resources
# Copy all of the resource files to the destination
file(COPY "resources/" DESTINATION "resources/")
-
diff --git a/games/koala_seasons/CMakeLists.txt b/games/koala_seasons/CMakeLists.txt
index f79ab911..7e500d1e 100644
--- a/games/koala_seasons/CMakeLists.txt
+++ b/games/koala_seasons/CMakeLists.txt
@@ -1,21 +1,16 @@
-# Setup the project and settings
+cmake_minimum_required(VERSION 2.6)
project(koala_seasons)
-include("../../cmake/utils.cmake")
-
-
-# Make sure raylib has been built
-# TODO `build` directory should maybe be something else...
-include_directories("../../build/release")
-
# Grab the screens
file(GLOB screen_sources "screens/*.c")
# Executable & linking
-add_executable(koala_seasons koala_seasons.c ${screen_sources})
-link_libraries_to_executable(koala_seasons)
+add_executable(${PROJECT_NAME} ${PROJECT_NAME}.c ${screen_sources})
+if (NOT TARGET raylib)
+ find_package(raylib 2.0 REQUIRED)
+endif()
+target_link_libraries(${PROJECT_NAME} raylib)
# Resources
# Copy all of the resource files to the destination
file(COPY "resources/" DESTINATION "resources/")
-
diff --git a/games/light_my_ritual/CMakeLists.txt b/games/light_my_ritual/CMakeLists.txt
index 11d2e4f4..a35a34e0 100644
--- a/games/light_my_ritual/CMakeLists.txt
+++ b/games/light_my_ritual/CMakeLists.txt
@@ -1,21 +1,16 @@
-# Setup the project and settings
+cmake_minimum_required(VERSION 2.6)
project(light_my_ritual)
-include("../../cmake/utils.cmake")
-
-
-# Make sure raylib has been built
-# TODO `build` directory should maybe be something else...
-include_directories("../../build/release")
-
# Grab the screens
file(GLOB screen_sources "screens/*.c")
# Executable & linking
-add_executable(light_my_ritual light_my_ritual.c ${screen_sources})
-link_libraries_to_executable(light_my_ritual)
+add_executable(${PROJECT_NAME} ${PROJECT_NAME}.c ${screen_sources})
+if (NOT TARGET raylib)
+ find_package(raylib 2.0 REQUIRED)
+endif()
+target_link_libraries(${PROJECT_NAME} raylib)
# Resources
# Copy all of the resource files to the destination
file(COPY "resources/" DESTINATION "resources/")
-
diff --git a/games/skully_escape/CMakeLists.txt b/games/skully_escape/CMakeLists.txt
index 337e1db5..51047ca1 100644
--- a/games/skully_escape/CMakeLists.txt
+++ b/games/skully_escape/CMakeLists.txt
@@ -1,21 +1,16 @@
-# Setup the project and settings
+cmake_minimum_required(VERSION 2.6)
project(skully_escape)
-include("../../cmake/utils.cmake")
-
-
-# Make sure raylib has been built
-# TODO `build` directory should maybe be something else...
-include_directories("../../build/release")
-
# Grab the screens
file(GLOB screen_sources "screens/*.c")
# Executable & linking
-add_executable(skully_escape skully_escape.c player.c monster.c ${screen_sources})
-link_libraries_to_executable(skully_escape)
+add_executable(${PROJECT_NAME} skully_escape.c player.c monster.c ${screen_sources})
+if (NOT TARGET raylib)
+ find_package(raylib 2.0 REQUIRED)
+endif()
+target_link_libraries(${PROJECT_NAME} raylib)
# Resources
# Copy all of the resource files to the destination
file(COPY "resources/" DESTINATION "resources/")
-
diff --git a/games/wave_collector/CMakeLists.txt b/games/wave_collector/CMakeLists.txt
index ca6c37b8..a87dbeda 100644
--- a/games/wave_collector/CMakeLists.txt
+++ b/games/wave_collector/CMakeLists.txt
@@ -1,21 +1,16 @@
-# Setup the project and settings
+cmake_minimum_required(VERSION 2.6)
project(wave_collector)
-include("../../cmake/utils.cmake")
-
-
-# Make sure raylib has been built
-# TODO `build` directory should maybe be something else...
-include_directories("../../build/release")
-
# Grab the screens
file(GLOB screen_sources "screens/*.c")
# Executable & linking
-add_executable(wave_collector wave_collector.c ${screen_sources})
-link_libraries_to_executable(wave_collector)
+add_executable(${PROJECT_NAME} ${PROJECT_NAME}.c ${screen_sources})
+if (NOT TARGET raylib)
+ find_package(raylib 2.0 REQUIRED)
+endif()
+target_link_libraries(${PROJECT_NAME} raylib)
# Resources
# Copy all of the resource files to the destination
file(COPY "resources/" DESTINATION "resources/")
-
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 05e3c0d2..ceee761f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -5,20 +5,28 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")
set(PROJECT_VERSION 2.0.0)
set(API_VERSION 2)
-set(RAYLIB raylib) # Name of the generated library
include("CMakeOptions.txt")
include(BuildType)
configure_file(config.h.in ${CMAKE_BINARY_DIR}/cmake/config.h)
-include_directories(${CMAKE_BINARY_DIR})
-include_directories(SYSTEM .)
+include_directories(${CMAKE_BINARY_DIR} .)
# Get the sources together
file(GLOB raylib_sources *.c)
list(REMOVE_ITEM raylib_sources ${CMAKE_CURRENT_SOURCE_DIR}/rglfw.c)
+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 QUIET)
+endif()
+if (glfw3_FOUND)
+ set(LIBS_PRIVATE ${LIBS_PRIVATE} glfw)
+endif()
+
# Explicitly check against "ON", because USE_EXTERNAL_GLFW is a tristate option
if(NOT glfw3_FOUND AND NOT USE_EXTERNAL_GLFW STREQUAL "ON" AND "${PLATFORM}" MATCHES "Desktop")
+ MESSAGE(STATUS "Using raylib's GLFW")
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
@@ -30,54 +38,63 @@ if(NOT glfw3_FOUND AND NOT USE_EXTERNAL_GLFW STREQUAL "ON" AND "${PLATFORM}" MAT
endif()
add_subdirectory(external/glfw)
- include_directories(external/glfw/include)
+ include_directories(BEFORE SYSTEM external/glfw/include)
list(APPEND raylib_sources $<TARGET_OBJECTS:glfw_objlib>)
else()
+ MESSAGE(STATUS "Using external GLFW")
set(GLFW_PKG_DEPS glfw)
endif()
-include(utils)
+add_definitions("-DRAYLIB_CMAKE=1")
if(USE_AUDIO)
+ if (NOT USE_OPENAL_BACKEND)
+ file(GLOB mini_al external/mini_al.c)
+ MESSAGE(STATUS "Audio Backend: mini_al")
+ else()
+ find_package(OpenAL REQUIRED)
+ MESSAGE(STATUS "Audio Backend: OpenAL")
+ 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})
+ set(sources ${raylib_sources} ${mini_al} ${stb_vorbis})
else()
+ MESSAGE(STATUS "Audio Backend: None (-DUSE_AUDIO=OFF)")
set(INCLUDE_AUDIO_MODULE 0)
list(REMOVE_ITEM raylib_sources ${CMAKE_CURRENT_SOURCE_DIR}/audio.c)
set(sources ${raylib_sources})
endif()
-include(AddIfFlagCompiles)
-
### Config options ###
# Translate the config options to what raylib wants
if(${PLATFORM} MATCHES "Desktop")
- set(PLATFORM "PLATFORM_DESKTOP")
-
- # OpenGL version
- if (${OPENGL_VERSION} MATCHES "3.3")
- set(GRAPHICS "GRAPHICS_API_OPENGL_33")
- elseif (${OPENGL_VERSION} MATCHES "2.1")
- set(GRAPHICS "GRAPHICS_API_OPENGL_21")
- elseif (${OPENGL_VERSION} MATCHES "1.1")
- set(GRAPHICS "GRAPHICS_API_OPENGL_11")
- elseif (${OPENGL_VERSION} MATCHES "ES 2.0")
- set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
- endif()
+ set(PLATFORM_CPP "PLATFORM_DESKTOP")
if(APPLE)
# Need to force OpenGL 3.3 on OS X
# See: https://github.com/raysan5/raylib/issues/341
set(GRAPHICS "GRAPHICS_API_OPENGL_33")
+ find_library(OPENGL_LIBRARY OpenGL)
+ set(LIBS_PRIVATE ${OPENGL_LIBRARY})
link_libraries("${LIBS_PRIVATE}")
elseif(WIN32)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
+ else()
+ find_library(pthread NAMES pthread)
+ find_package(OpenGL QUIET)
+ if ("${OPENGL_LIBRARIES}" STREQUAL "")
+ set(OPENGL_LIBRARIES "GL")
+ endif()
+
+ if ("${CMAKE_SYSTEM_NAME}" MATCHES "(Net|Open)BSD")
+ find_library(OSS_LIBRARY ossaudio)
+ endif()
+
+ set(LIBS_PRIVATE m pthread ${OPENGL_LIBRARIES} ${OSS_LIBRARY})
endif()
elseif(${PLATFORM} MATCHES "Web")
- set(PLATFORM "PLATFORM_WEB")
+ set(PLATFORM_CPP "PLATFORM_WEB")
set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
set(CMAKE_C_FLAGS "-s USE_GLFW=3 -s ASSERTIONS=1 --profiling")
@@ -85,8 +102,9 @@ elseif(${PLATFORM} MATCHES "Web")
# Change the name of the output library
elseif(${PLATFORM} MATCHES "Android")
- set(PLATFORM "PLATFORM_ANDROID")
+ set(PLATFORM_CPP "PLATFORM_ANDROID")
set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
+ include(AddIfFlagCompiles)
add_if_flag_compiles(-ffunction-sections CMAKE_C_FLAGS)
add_if_flag_compiles(-funwind-tables CMAKE_C_FLAGS)
add_if_flag_compiles(-fstack-protector-strong CMAKE_C_FLAGS)
@@ -97,94 +115,139 @@ elseif(${PLATFORM} MATCHES "Android")
include_directories(external/android/native_app_glue)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--exclude-libs,libatomic.a -Wl,--build-id -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings -uANativeActivity_onCreate")
+ find_library(OPENGL_LIBRARY OpenGL)
+ set(LIBS_PRIVATE m log android EGL GLESv2 OpenSLES atomic c)
+
elseif(${PLATFORM} MATCHES "Raspberry Pi")
- set(PLATFORM "PLATFORM_RPI")
+ set(PLATFORM_CPP "PLATFORM_RPI")
set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
+
endif()
-if(${SHARED})
- add_library(${RAYLIB}_shared SHARED ${sources})
+if (${OPENGL_VERSION})
+ set(${SUGGESTED_GRAPHICS} "${GRAPHICS}")
+ if (${OPENGL_VERSION} MATCHES "3.3")
+ set(GRAPHICS "GRAPHICS_API_OPENGL_33")
+ elseif (${OPENGL_VERSION} MATCHES "2.1")
+ set(GRAPHICS "GRAPHICS_API_OPENGL_21")
+ elseif (${OPENGL_VERSION} MATCHES "1.1")
+ set(GRAPHICS "GRAPHICS_API_OPENGL_11")
+ elseif (${OPENGL_VERSION} MATCHES "ES 2.0")
+ set(GRAPHICS "GRAPHICS_API_OPENGL_ES2")
+ endif()
+ if (${SUGGESTED_GRAPHICS} AND NOT "${SUGGESTED_GRAPHICS}" STREQUAL "${GRAPHICS}")
+ message(WARNING "You are overriding the suggested GRAPHICS=${SUGGESTED_GRAPHICS} with ${GRAPHICS}! This may fail")
+ endif()
+endif()
+
+if(NOT GRAPHICS)
+ set(GRAPHICS "GRAPHICS_API_OPENGL_33")
+endif()
+
+include_directories(${OPENGL_INCLUDE_DIR} ${OPENAL_INCLUDE_DIR})
+set(LIBS_PRIVATE ${LIBS_PRIVATE} ${OPENAL_LIBRARY})
+include(LibraryPathToLinkerFlags)
+library_path_to_linker_flags(__PKG_CONFIG_LIBS_PRIVATE "${LIBS_PRIVATE}")
+
+if(STATIC)
+ if(${PLATFORM} MATCHES "Web")
+ set(CMAKE_STATIC_LIBRARY_SUFFIX ".bc")
+ endif()
+
+ add_library(raylib_static STATIC ${sources})
- target_compile_definitions(${RAYLIB}_shared
- PUBLIC ${PLATFORM}
+ target_compile_definitions(raylib_static
+ PUBLIC ${PLATFORM_CPP}
+ PUBLIC ${GRAPHICS}
+ )
+
+ set(PKG_CONFIG_LIBS_PRIVATE ${__PKG_CONFIG_LIBS_PRIVATE} ${GLFW_PKG_LIBS})
+ string (REPLACE ";" " " PKG_CONFIG_LIBS_PRIVATE "${PKG_CONFIG_LIBS_PRIVATE}")
+ if (${PLATFORM} MATCHES "Desktop")
+ target_link_libraries(raylib_static glfw ${GLFW_LIBRARIES} ${LIBS_PRIVATE})
+ endif()
+
+ if (WITH_PIC)
+ set_property(TARGET raylib_static PROPERTY POSITION_INDEPENDENT_CODE ON)
+ endif()
+ set_target_properties(raylib_static PROPERTIES PUBLIC_HEADER "raylib.h")
+ if(NOT WIN32) # Keep lib*.(a|dll) name, but avoid *.lib files overwriting each other on Windows
+ set_target_properties(raylib_static PROPERTIES OUTPUT_NAME raylib)
+ endif()
+ install(
+ TARGETS raylib_static
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+ PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
+ )
+set_target_properties(raylib_static PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_BINARY_DIR}/release")
+
+ add_test("pkg-config--static" ${PROJECT_SOURCE_DIR}/../cmake/test-pkgconfig.sh --static)
+endif(STATIC)
+
+
+if(SHARED)
+ add_library(raylib SHARED ${sources})
+
+ target_compile_definitions(raylib
+ PUBLIC ${PLATFORM_CPP}
PUBLIC ${GRAPHICS}
)
set(PKG_CONFIG_LIBS_EXTRA "")
- set_property(TARGET ${RAYLIB}_shared PROPERTY POSITION_INDEPENDENT_CODE ON)
+ set_property(TARGET raylib PROPERTY POSITION_INDEPENDENT_CODE ON)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_LIBDIR}")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(CMAKE_MACOSX_RPATH ON)
- target_link_libraries(${RAYLIB}_shared ${LIBS_PRIVATE})
- if (${PLATFORM} MATCHES "PLATFORM_DESKTOP")
- target_link_libraries(${RAYLIB}_shared glfw)
+ target_link_libraries(raylib ${LIBS_PRIVATE})
+ if (${PLATFORM} MATCHES "Desktop")
+ target_link_libraries(raylib glfw)
endif()
if (UNIX AND ${FILESYSTEM_LACKS_SYMLINKS})
MESSAGE(WARNING "Can't version UNIX shared library on file system without symlink support")
else()
- set_target_properties(${RAYLIB}_shared PROPERTIES
+ set_target_properties(raylib PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${API_VERSION}
)
endif()
- set_target_properties(${RAYLIB}_shared PROPERTIES
+ set_target_properties(raylib PROPERTIES
PUBLIC_HEADER "raylib.h"
)
- if(WIN32)
+
+ if (WIN32)
install(
- TARGETS ${RAYLIB}_shared
- RUNTIME DESTINATION lib
- PUBLIC_HEADER DESTINATION include
+ TARGETS raylib
+ 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})
+ else()
install(
- TARGETS ${RAYLIB}_shared
- LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
- PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
+ TARGETS raylib
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+ PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
endif()
+ set_target_properties(raylib PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_BINARY_DIR}/release")
add_test("pkg-config" ${PROJECT_SOURCE_DIR}/../cmake/test-pkgconfig.sh)
-endif(${SHARED})
-
-if(${STATIC})
- if(${PLATFORM} MATCHES "PLATFORM_WEB")
- set(CMAKE_STATIC_LIBRARY_SUFFIX ".bc")
- endif()
-
- add_library(${RAYLIB} STATIC ${sources})
-
- target_compile_definitions(${RAYLIB}
- PUBLIC ${PLATFORM}
- PUBLIC ${GRAPHICS}
- )
-
- set(PKG_CONFIG_LIBS_PRIVATE ${__PKG_CONFIG_LIBS_PRIVATE} ${GLFW_PKG_LIBS})
- string (REPLACE ";" " " PKG_CONFIG_LIBS_PRIVATE "${PKG_CONFIG_LIBS_PRIVATE}")
- if (${PLATFORM} MATCHES "PLATFORM_DESKTOP")
- target_link_libraries(${RAYLIB} glfw ${GLFW_LIBRARIES})
- endif()
-
- 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 "${CMAKE_INSTALL_LIBDIR}"
- PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
- )
-
- add_test("pkg-config--static" ${PROJECT_SOURCE_DIR}/../cmake/test-pkgconfig.sh --static)
-endif(${STATIC})
+else(SHARED)
+ add_library(raylib ALIAS raylib_static)
+endif(SHARED)
if (NOT DEFINED PKG_CONFIG_LIBS_EXTRA)
set(PKG_CONFIG_LIBS_EXTRA "${PKG_CONFIG_LIBS_PRIVATE}")
endif()
configure_file(../raylib.pc.in raylib.pc @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/release/raylib.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
+configure_file(../cmake/raylib-config-version.cmake raylib-config-version.cmake @ONLY)
+install(FILES ${CMAKE_BINARY_DIR}/release/raylib-config-version.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/raylib")
+install(FILES ${PROJECT_SOURCE_DIR}/../cmake/raylib-config.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/raylib")
+
+# populates raylib_{FOUND, INCLUDE_DIRS, LIBRARIES, LDFLAGS, DEFINITIONS}
+include(PopulateConfigVariablesLocally)
+populate_config_variables_locally(raylib)
# Copy the header files to the build directory
file(COPY "raylib.h" DESTINATION ".")
@@ -195,7 +258,7 @@ file(COPY "audio.h" DESTINATION ".")
# Print the flags for the user
message(STATUS "Compiling with the flags:")
-message(STATUS " PLATFORM=" ${PLATFORM})
+message(STATUS " PLATFORM=" ${PLATFORM_CPP})
message(STATUS " GRAPHICS=" ${GRAPHICS})
# Packaging
diff --git a/src/CMakeOptions.txt b/src/CMakeOptions.txt
index a9cd4354..79f09414 100644
--- a/src/CMakeOptions.txt
+++ b/src/CMakeOptions.txt
@@ -4,13 +4,13 @@ include(EnumOption)
enum_option(PLATFORM "Desktop;Web;Android;Raspberry Pi" "Platform to build for.")
-enum_option(OPENGL_VERSION "3.3;2.1;1.1;ES 2.0" "OpenGL Version to build raylib with")
+enum_option(OPENGL_VERSION "OFF;3.3;2.1;1.1;ES 2.0" "Force a specific OpenGL Version?")
# 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(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" OFF)
option(USE_AUDIO "Build raylib with audio module" ON)
if(${PLATFORM} MATCHES "Web")
cmake_dependent_option(USE_OPENAL_BACKEND "Link raylib with openAL instead of mini-al" ON "USE_AUDIO" OFF)
@@ -23,6 +23,9 @@ if(UNIX AND NOT APPLE)
option(USE_WAYLAND "Use Wayland for window creation" OFF)
endif()
+option(INCLUDE_EVERYTHING "Include everything disabled by default (for CI usage" OFF)
+set(OFF ${INCLUDE_EVERYTHING} CACHE INTERNAL "Replace any OFF by default with \${OFF} to have it covered by this option")
+
# core.c
option(SUPPORT_BUSY_WAIT_LOOP "Use busy wait loop for timing sync instead of a high-resolution timer" ON)
@@ -48,13 +51,13 @@ 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)
+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})
# models.c
option(SUPPORT_FILEFORMAT_OBJ "Support loading OBJ file format" ON)
@@ -66,11 +69,11 @@ 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)
+option(SUPPORT_FILEFORMAT_FLAC "Support loading FLAC for sound" ${OFF})
# 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_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)
diff --git a/src/core.c b/src/core.c
index 6939b844..aa76e88c 100644
--- a/src/core.c
+++ b/src/core.c
@@ -1915,14 +1915,14 @@ static bool InitGraphicsDevice(int width, int height)
if (configFlags & FLAG_WINDOW_UNDECORATED) glfwWindowHint(GLFW_DECORATED, GL_FALSE); // Border and buttons on Window
else glfwWindowHint(GLFW_DECORATED, GL_TRUE); // Decorated window
-
-#if !defined(PLATFORM_WEB) // FLAG_WINDOW_TRANSPARENT not supported on HTML5
+ // FLAG_WINDOW_TRANSPARENT not supported on HTML5 and not included in any released GLFW version yet
+#if defined(GLFW_TRANSPARENT_FRAMEBUFFER)
if (configFlags & FLAG_WINDOW_TRANSPARENT) glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE); // Transparent framebuffer
else glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_FALSE); // Opaque framebuffer
#endif
if (configFlags & FLAG_MSAA_4X_HINT) glfwWindowHint(GLFW_SAMPLES, 4); // Tries to enable multisampling x4 (MSAA), default is 0
-
+
// NOTE: When asking for an OpenGL context version, most drivers provide highest supported version
// with forward compatibility to older OpenGL versions.
// For example, if using OpenGL 1.1, driver can provide a 4.3 context forward compatible.