-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
65 lines (53 loc) · 1.44 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
65
cmake_minimum_required(VERSION 3.14)
project(chip-8)
# Specify C++ standard
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# Set default build type if not specified
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
# Add the FetchContent module
include(FetchContent)
# Fetch and install Raylib
FetchContent_Declare(
raylib
GIT_REPOSITORY https://github.com/raysan5/raylib.git
GIT_TAG 5.0 # You can specify the version here
)
FetchContent_MakeAvailable(raylib)
# Fetch and install Glad
FetchContent_Declare(
glad
GIT_REPOSITORY https://github.com/Dav1dde/glad.git
GIT_TAG v0.1.36 # You can specify the version here
)
FetchContent_MakeAvailable(glad)
# Add executable
add_executable(chip-8
src/main.cpp
src/chip8.cpp
)
# Include directories
target_include_directories(chip-8 PRIVATE
include
${raylib_SOURCE_DIR}/src
${glad_SOURCE_DIR}/include
${raylib_BINARY_DIR}
)
# Link libraries
target_link_libraries(chip-8 raylib glad)
# Platform-specific configurations
if (WIN32)
target_link_libraries(chip-8 opengl32)
elseif (APPLE)
target_link_libraries(chip-8 "-framework OpenGL" "-framework Cocoa" "-framework IOKit" "-framework CoreVideo")
elseif (UNIX)
target_link_libraries(chip-8 GL dl pthread)
endif()
# Enable compiler warnings
if(MSVC)
target_compile_options(chip-8 PRIVATE /W4 /WX)
else()
target_compile_options(chip-8 PRIVATE -Wall -Wextra -Wpedantic -Werror)
endif()