2018-07-29 19:23:23 +03:00
|
|
|
cmake_minimum_required(VERSION 3.11) # FetchContent is available in 3.11+
|
|
|
|
project(example)
|
|
|
|
|
2019-10-29 17:56:14 +03:00
|
|
|
# Set this to the minimal version you want to support
|
2020-04-13 16:10:42 +03:00
|
|
|
find_package(raylib 3.0 QUIET) # Let CMake search for a raylib-config.cmake
|
2018-07-29 19:23:23 +03:00
|
|
|
|
|
|
|
# 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)
|
|
|
|
|
2018-07-29 22:25:42 +03:00
|
|
|
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) # don't build the supplied examples
|
2018-07-29 19:23:23 +03:00
|
|
|
|
|
|
|
# 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)
|
|
|
|
|
2021-05-24 12:05:08 +03:00
|
|
|
# Checks if OSX and links appropriate frameworks (Only required on MacOS)
|
|
|
|
if (APPLE)
|
|
|
|
target_link_libraries(${PROJECT_NAME} "-framework IOKit")
|
|
|
|
target_link_libraries(${PROJECT_NAME} "-framework Cocoa")
|
|
|
|
target_link_libraries(${PROJECT_NAME} "-framework OpenGL")
|
|
|
|
endif()
|
|
|
|
|
2018-07-29 19:23:23 +03:00
|
|
|
# That's it! You should have an example executable that you can run. Have fun!
|