csnake/CMakeLists.txt

39 lines
1015 B
CMake
Raw Normal View History

2023-10-31 06:07:03 +03:00
cmake_minimum_required(VERSION 3.5)
2023-11-25 20:55:57 +03:00
project(csnake VERSION 1.1 LANGUAGES C)
2023-10-31 06:07:03 +03:00
if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
message(FATAL_ERROR "In-source builds are not allowed.")
endif()
add_executable(csnake
src/main.c
src/screen.c
src/input.c
src/player.c
src/sleep.c
src/platform/getch.c
2023-12-17 03:07:48 +03:00
src/platform/game.c
2023-10-31 06:07:03 +03:00
)
set_target_properties(csnake PROPERTIES C_STANDARD 11)
2023-10-31 06:07:03 +03:00
set_target_properties(csnake PROPERTIES C_EXTENSIONS FALSE)
2024-02-23 17:11:50 +03:00
2023-11-25 20:55:57 +03:00
if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
target_link_libraries(csnake pthread)
2024-02-23 17:11:50 +03:00
elseif(${MINGW})
set(CMAKE_C_FLAGS "-D_UCRT")
target_link_libraries(csnake ucrt)
2023-11-25 20:55:57 +03:00
endif()
2024-02-23 17:11:50 +03:00
2023-10-31 06:07:03 +03:00
target_include_directories(csnake PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
2024-03-06 23:50:27 +03:00
set(FIELD_SIZE 10 CACHE STRING "Size of game field")
2023-10-31 06:07:03 +03:00
set(DEFX 0 CACHE STRING "Start x")
set(DEFY 0 CACHE STRING "Start y")
2023-11-30 18:05:51 +03:00
set(SLEEP 1000 CACHE STRING "Sleep between frames (ms)")
2023-10-31 06:07:03 +03:00
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/templates/config.h.in
${CMAKE_CURRENT_SOURCE_DIR}/include/config.h
)