-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
51 lines (43 loc) · 1.26 KB
/
CMakeLists.txt
File metadata and controls
51 lines (43 loc) · 1.26 KB
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
cmake_minimum_required(VERSION 3.10)
project(GreedySnakeC C)
set(CMAKE_C_STANDARD 99)
# Add compiler flags to ignore warnings
if(MSVC)
add_compile_options(/W0)
endif()
# Windows specific configuration
if(WIN32)
# For Windows, we'll use PDCurses
set(PDCURSES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/PDCurses)
set(PDCURSES_INCLUDE_DIR ${PDCURSES_DIR})
# Add PDCurses source files (pdcurses and wincon)
file(GLOB PDCURSES_SOURCES
"${PDCURSES_DIR}/pdcurses/*.c"
"${PDCURSES_DIR}/wincon/*.c"
)
# Create PDCurses library
add_library(pdcurses STATIC ${PDCURSES_SOURCES})
target_include_directories(pdcurses PUBLIC ${PDCURSES_INCLUDE_DIR})
target_compile_definitions(pdcurses PRIVATE PDC_WIDE)
set(CURSES_LIBRARIES pdcurses)
set(CURSES_INCLUDE_DIRS ${PDCURSES_INCLUDE_DIR})
else()
# For Unix-like systems
find_package(Curses REQUIRED)
endif()
# Add your source files
add_executable(GreedySnake
src/main.c
src/snake.c
src/food.c
src/game.c
src/ui.c
src/input.c
)
# Link ncurses to your executable
target_link_libraries(GreedySnake ${CURSES_LIBRARIES})
# Include header directory
target_include_directories(GreedySnake PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/src
${CURSES_INCLUDE_DIRS}
)