Skip to content

Commit

Permalink
Major CMakeLists.txt update.
Browse files Browse the repository at this point in the history
This update includes a bump to the required CMake version, as well
as a number of stylistic changes that hopefully bring this more in
line with the standards of good practice for CMake.

Also, the --version command line option now outputs more verbose
version information.
  • Loading branch information
Kestrel Gregorich-Trevor committed Jan 18, 2024
1 parent 10e5378 commit fa62413
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 21 deletions.
66 changes: 58 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set(ZZZZZZ_DESKTOP_DIR /usr/share/applications)
set(VERSION_MAJOR 0)
set(VERSION_MINOR 1)
SET(VERSION_PATCH 0)
SET(RELEASE_TYPE "alpha")
SET(RELEASE_STATE "alpha")

# Generate files
configure_file (
Expand All @@ -30,15 +30,64 @@ project(${PROJECT_NAME} VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATC
##########################Compile##########################
# Find required packages
set(CURSES_NEED_WIDE TRUE)
set(CURSES_NEED_NCURSES TRUE)
find_package(Curses REQUIRED)
find_package(cJSON REQUIRED)

#TODO: I know globbing c files is bad practice, but when we're this early in development, it's just plain easier.
file(GLOB SRCS "src/*.c")
add_executable(${PROJECT_NAME} ${SRCS} windows/curses/windows.c windows/curses/menu.c)
#TODO: Inclusion directories in this way is also considered bad practice.
target_include_directories(${PROJECT_NAME} PUBLIC include ${CJSON_INCLUDE_DIR} ${CURSES_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} PUBLIC ${CJSON_LIBRARIES} ${CURSES_LIBRARIES} -lpanel)
# Source files
set (SOURCES
src/action.c
src/actor.c
src/ai.c
src/combat.c
src/fov.c
src/gameover.c
src/invent.c
src/main.c
src/map.c
src/mapgen.c
src/message.c
src/parser.c
src/pqueue.c
src/random.c
src/register.c
src/render.c
src/save.c
src/spawn.c
src/tile.c
windows/curses/windows.c
windows/curses/menu.c)
set (HEADERS
include/action.h
include/actor.h
include/ai.h
include/color.h
include/combat.h
include/fov.h
include/gameover.h
include/invent.h
include/map.h
include/mapgen.h
include/menu.h
include/message.h
include/parser.h
include/pqueue.h
include/random.h
include/register.h
include/render.h
include/save.h
include/spawn.h
include/tactics.h
include/tile.h
include/version.h
include/wfc.h
include/windows.h)
set (INCLUDE_DIR include)

# Create executable
add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS})
target_include_directories(${PROJECT_NAME} PUBLIC ${INCLUDE_DIR} ${CJSON_INCLUDE_DIR} ${CURSES_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} PUBLIC ${CJSON_LIBRARIES} -lpanelw ${CURSES_LIBRARIES})
set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")

# Copy data files
Expand All @@ -48,7 +97,8 @@ add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
${CMAKE_SOURCE_DIR}/data $<TARGET_FILE_DIR:${PROJECT_NAME}>/data
COMMENT "Copying data folder to output dir.")

message(STATUS "Configuring CMake for ${PROJECT_NAME} v${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${RELEASE_TYPE}")
message(STATUS "Configuring CMake for ${PROJECT_NAME} v${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${RELEASE_STATE}")
message(STATUS "Release Type: ${CMAKE_BUILD_TYPE}")
##########################Install##########################
install(TARGETS ${PROJECT_NAME} DESTINATION .)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/data/ DESTINATION data)
Expand Down
2 changes: 1 addition & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"version": 4,
"cmakeMinimumRequired": {
"major": 3,
"minor": 23,
"minor": 28,
"patch": 0
},
"configurePresets": [
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ An attack can be one or more of four types: Low, Mid, High, or Grab. Conversely,

If an attack hits, the target takes full damage and enters a stunned state. If an attack is blocked, the target takes only partial damage and is not stunned.

## System Requirements

This is a console-based roguelike written in plain C. A moldering potato can probably run this game. The potato, however, must be equipped with the following:

- Ncurses

## Building from Source
Zenzizenzizenzic is built using CMake.

Expand All @@ -38,12 +44,6 @@ directory.
While both the win and lose state are reachable, the game is still very far from what
I would consider playable.

### Can My Computer Run It?
This is a console-based roguelike written in plain C. A potato can probably run this game.

In all seriousness, your computer can almost certainly run this. At worst, using
autoexplore might eat up some RAM in a low memory environment.

### Why C?

This is a traditional roguelike, and follows the Berlin Interpretation
Expand Down
12 changes: 8 additions & 4 deletions include/version.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
#define VERSION_MINOR ${VERSION_MINOR}
/* 0.0.x */
#define VERSION_PATCH ${VERSION_PATCH}
/* Alpha, Beta, Release */
#define RELEASE_STATE "${RELEASE_STATE}"
/* Release, Debug, Test, etc. */
#define RELEASE_TYPE "${RELEASE_TYPE}"
/* Report Repo */
#define REPO_URL "https://github.com/NullCGT/Zenzizenzizenzic-RL"
#define RELEASE_TYPE "${CMAKE_BUILD_TYPE}"
/* Short Description */
#define SHORT_DESC "${PROJECT_DESCRIPTION}"
#define SHORT_DESC "${PROJECT_DESCRIPTION}"
/* Author */
#define AUTHOR "${PROJECT_VENDOR}"
/* Report Repo */
#define REPO_URL "https://github.com/NullCGT/Zenzizenzizenzic-RL"
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ error_t parse_args(int key, char *arg, struct argp_state *state) {
g.practice = 1;
break;
case 'v':
printf("v%d.%d.%d-%s\n", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, RELEASE_TYPE);
printf("v%d.%d.%d-%s (%s)\n", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, RELEASE_STATE, RELEASE_TYPE);
exit(0);
break;
case 't':
Expand Down
2 changes: 1 addition & 1 deletion windows/curses/windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void title_screen(void) {
box(background, 0, 0);

snprintf(buf, sizeof(buf), "Zenzizenzizenzic v%d.%d.%d-%s",
VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, RELEASE_TYPE);
VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, RELEASE_STATE);
selector = menu_new(buf, 1, 1, 35, 8);

menu_add_item(selector, 'p', "Play");
Expand Down

0 comments on commit fa62413

Please sign in to comment.