Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
/objwin/
/save/
/src/version.h
/src/prefix.h
/sound/
/templates/
/tools/format/json_formatter.cgi
Expand Down
14 changes: 12 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ else ()
# Use CMAKE_INSTALL_PREFIX as storage of data,gfx, etc.. Useful only on *nix OS.
if (CMAKE_INSTALL_PREFIX AND NOT WIN32 AND USE_PREFIX_DATA_DIR)
add_definitions(-DPREFIX=${CMAKE_INSTALL_PREFIX})
configure_file(
"${CMAKE_SOURCE_DIR}/src/prefix.h.in"
"${CMAKE_SOURCE_DIR}/src/prefix.h"
@ONLY)
add_definitions(-DDATA_DIR_PREFIX)
endif ()
endif ()
Expand Down Expand Up @@ -221,8 +225,12 @@ else ()
-Wpedantic \
-Wsuggest-override \
-Wunused-macros \
-Wzero-as-null-pointer-constant \
-Wno-unknown-warning-option")
-Wzero-as-null-pointer-constant")
if(Clang STREQUAL ${CMAKE_CXX_COMPILER_ID})
set(CATA_WARNINGS "${CATA_WARNINGS} -Wno-unknown-warning-option")
else()
set(CATA_WARNINGS "${CATA_WARNINGS} -Wno-unknown-warning")
endif()
if (NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Windows")
set(CATA_WARNINGS "${CATA_WARNINGS} -Wredundant-decls")
endif ()
Expand All @@ -234,6 +242,8 @@ else ()
endif ()

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
Comment on lines +245 to +246
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to break ncurses build on msys2 by causing the ghc filesystem files to give undefined symbol errors. Since this is a very edge case I'm not sure whether it's a problem with msys2, ghc filesystem, or cmake.


# Force out-of-source build
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
Expand Down
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ endif

LDFLAGS += -lz

all: version $(CHECKS) $(TARGET) $(L10N) $(TESTS)
all: version prefix $(CHECKS) $(TARGET) $(L10N) $(TESTS)
@

$(TARGET): $(OBJS)
Expand All @@ -928,14 +928,20 @@ $(PCH_P): $(PCH_H)
$(BUILD_PREFIX)$(TARGET_NAME).a: $(OBJS)
$(AR) rcs $(BUILD_PREFIX)$(TARGET_NAME).a $(filter-out $(ODIR)/main.o $(ODIR)/messages.o,$(OBJS))

.PHONY: version
.PHONY: version prefix
version:
@( VERSION_STRING=$(VERSION) ; \
[ -e ".git" ] && GITVERSION=$$( git describe --tags --always --match "[0-9A-Z]*.[0-9A-Z]*" ) && DIRTYFLAG=$$( [ -z "$$(git diff --numstat | grep -v lang/po/)" ] || echo "-dirty") && VERSION_STRING=$$GITVERSION$$DIRTYFLAG ; \
[ -e "$(SRC_DIR)/version.h" ] && OLDVERSION=$$(grep VERSION $(SRC_DIR)/version.h|cut -d '"' -f2) ; \
if [ "x$$VERSION_STRING" != "x$$OLDVERSION" ]; then printf '// NOLINT(cata-header-guard)\n#define VERSION "%s"\n' "$$VERSION_STRING" | tee $(SRC_DIR)/version.h ; fi \
)

prefix:
@( PREFIX_STRING=$(PREFIX) ; \
[ -e "$(SRC_DIR)/prefix.h" ] && OLDPREFIX=$$(grep PREFIX $(SRC_DIR)/PREFIX.h|cut -d '"' -f2) ; \
if [ "x$$PREFIX_STRING" != "x$$OLDPREFIX" ]; then printf '// NOLINT(cata-header-guard)\n#define PREFIX "%s"\n' "$$PREFIX_STRING" | tee $(SRC_DIR)/prefix.h ; fi \
)

# Unconditionally create the object dir on every invocation.
$(shell mkdir -p $(ODIR))

Expand Down
9 changes: 6 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
#include "type_id.h"
#include "ui_manager.h"

#if defined(PREFIX)
# undef PREFIX
# include "prefix.h"
#endif

class ui_adaptor;

#if defined(TILES)
Expand Down Expand Up @@ -590,9 +595,7 @@ int main( int argc, const char *argv[] )
#else
// Set default file paths
#if defined(PREFIX)
#define Q(STR) #STR
#define QUOTE(STR) Q(STR)
PATH_INFO::init_base_path( std::string( QUOTE( PREFIX ) ) );
PATH_INFO::init_base_path( std::string( PREFIX ) );
#else
PATH_INFO::init_base_path( "" );
#endif
Expand Down
1 change: 1 addition & 0 deletions src/prefix.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#define PREFIX "@PREFIX@"