raylib/projects/CMake/CMakeLists.txt
Ahmad Fatoum 78487f7521
CMake: Make the raylib project as a whole embeddable
So user code can use add_subdirectory to build it (similar to what we do
with GLFW or what the projects/CMake/CMakeLists.txt can do).
2018-07-29 21:28:23 +02:00

38 lines
1.1 KiB
CMake

cmake_minimum_required(VERSION 3.11) # FetchContent is available in 3.11+
project(example)
find_package(raylib 2.0 QUIET) # Let CMake search for a raylib-config.cmake
# You could change the QUIET above to REQUIRED and remove this if() clause
# This part downloads raylib and builds it if it's not installed on your system
if (NOT raylib_FOUND) # If there's none, fetch and build raylib
include(FetchContent)
FetchContent_Declare(
raylib
URL https://github.com/raysan5/raylib/archive/master.tar.gz
)
FetchContent_GetProperties(raylib)
if (NOT raylib_POPULATED) # Have we downloaded raylib yet?
set(FETCHCONTENT_QUIET NO)
FetchContent_Populate(raylib)
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) # don't build the supplied examples
set(BUILD_GAMES OFF CACHE BOOL "" FORCE) # or games
# build raylib
add_subdirectory(${raylib_SOURCE_DIR} ${raylib_BINARY_DIR})
endif()
endif()
# This is the main part:
add_executable(${PROJECT_NAME} core_basic_window.c)
#set(raylib_VERBOSE 1)
target_link_libraries(${PROJECT_NAME} raylib)
# That's it! You should have an example executable that you can run. Have fun!