-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
65 lines (46 loc) · 1.81 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
cmake_minimum_required(VERSION 3.12) # CONFIGURE_DEPENDS is available in 3.12+
project(ray_pong_c C)
set(C_STANDARD C89)
if (UNIX)
set(OpenGL_GL_PREFERENCE GLVND)
endif()
# set linker flags on Windows to void console in background in release (must be done before compiling raylib)
if (WIN32 AND CMAKE_BUILD_TYPE STREQUAL Release)
if (MINGW)
add_link_options(-mwindows)
endif()
if(MSVC)
add_link_options(/subsystem:windows /entry:mainCRTStartup)
endif()
endif()
# RAYLIB ---------------
# Set this to the exact desired version, leave empty to use latest
set(RAYLIB_VERSION)
find_package(raylib ${RAYLIB_VERSION} 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)
if(NOT RAYLIB_VERSION)
set(RAYLIB_VERSION master)
endif()
FetchContent_Declare(
raylib
URL https://github.com/raysan5/raylib/archive/${RAYLIB_VERSION}.tar.gz
)
unset(RAYLIB_VERSION)
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) # don't build the supplied games
# build raylib
add_subdirectory(${raylib_SOURCE_DIR} ${raylib_BINARY_DIR})
endif()
endif()
# END RAYLIB ---------------
# add source code
file(GLOB SOURCES CONFIGURE_DEPENDS "src/*.c" "src/game/*.c")
add_executable(${PROJECT_NAME} ${SOURCES})
target_link_libraries(${PROJECT_NAME} raylib)