Skip to content

Commit 44ff1db

Browse files
authored
Merge pull request #84357 from alef/fix-c-make
Fix MSYS2/UCRT64 build
2 parents 0642c36 + bc67465 commit 44ff1db

File tree

8 files changed

+50
-27
lines changed

8 files changed

+50
-27
lines changed

CMakeModules/Find/FindSDL2_mixer.cmake

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,21 @@ if(PKG_CONFIG_FOUND)
133133
PkgConfig::libmpg123
134134
PkgConfig::opusfile
135135
)
136+
if (NOT DYNAMIC_LINKING)
137+
pkg_check_modules(vorbis REQUIRED IMPORTED_TARGET vorbis)
138+
pkg_check_modules(vorbisenc REQUIRED IMPORTED_TARGET vorbisenc)
139+
pkg_check_modules(vorbisfile REQUIRED IMPORTED_TARGET vorbisfile)
140+
pkg_check_modules(wavpack REQUIRED IMPORTED_TARGET wavpack)
141+
pkg_check_modules(libxmp REQUIRED IMPORTED_TARGET libxmp)
142+
target_link_libraries(SDL2_mixer::SDL2_mixer-static INTERFACE
143+
PkgConfig::vorbisfile
144+
PkgConfig::vorbis
145+
PkgConfig::ogg
146+
PkgConfig::vorbisenc
147+
PkgConfig::wavpack
148+
PkgConfig::libxmp
149+
)
150+
endif()
136151
endif()
137152
elseif(TARGET SDL2_mixer::SDL2_mixer)
138153
pkg_check_modules(FLAC REQUIRED IMPORTED_TARGET flac)

Makefile

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -381,11 +381,14 @@ ifneq ($(CLANG), 0)
381381
ifeq ($(CCACHE), 1)
382382
CXX = CCACHE_CPP2=1 $(CCACHEBIN) $(CROSS)$(CLANGCMD)
383383
LD = CCACHE_CPP2=1 $(CCACHEBIN) $(CROSS)$(CLANGCMD)
384+
CC = CCACHE_CPP2=1 $(CCACHEBIN) $(CROSS)$(subst ++,,$(CLANGCMD))
384385
else
385386
CXX = $(CROSS)$(CLANGCMD)
386387
LD = $(CROSS)$(CLANGCMD)
388+
CC = $(CROSS)$(subst ++,,$(CLANGCMD))
387389
endif
388390
CXX_WARNINGS += -Wno-unknown-warning-option
391+
WARNINGS += -Wno-unknown-warning-option
389392
else
390393
# Compiler version & target machine - used later for MXE ICE workaround
391394
ifdef CROSS
@@ -410,6 +413,7 @@ else
410413
LD = $(CROSS)$(OS_LINKER)
411414
endif
412415
CXX_WARNINGS += -Wno-unknown-warning
416+
WARNINGS += -Wno-unknown-warning
413417
endif
414418

415419
STRIP = $(CROSS)strip
@@ -531,9 +535,9 @@ ifeq ($(PCH), 1)
531535

532536
ifeq ($(CLANG), 0)
533537
PCHFLAGS += -include pch/main-pch.hpp
534-
PCH_P = $(PCH_H).gch
538+
PCH_P = $(ODIR)/$(PCH_H).gch
535539
else
536-
PCH_P = $(PCH_H).pch
540+
PCH_P = $(ODIR)/$(PCH_H).pch
537541
PCHFLAGS += -include-pch $(PCH_P)
538542

539543
# FIXME: dirty hack ahead
@@ -612,11 +616,13 @@ endif
612616
ifeq ($(NATIVE), osx)
613617
DEFINES += -DMACOSX
614618
CXXFLAGS += -mmacosx-version-min=10.15
619+
CFLAGS += -mmacosx-version-min=10.15
615620
LDFLAGS += -mmacosx-version-min=10.15 -framework CoreFoundation -Wl,-headerpad_max_install_names
616621
# doesn't use GNU ar
617622
THIN_AR=0
618623
ifeq ($(UNIVERSAL_BINARY), 1)
619624
CXXFLAGS += -arch x86_64 -arch arm64
625+
CFLAGS += -arch x86_64 -arch arm64
620626
LDFLAGS += -arch x86_64 -arch arm64
621627
endif
622628
ifdef FRAMEWORK
@@ -964,8 +970,7 @@ ifeq ($(MSYS2),1)
964970
DEFINES += -DMSYS2 -D_GLIBCXX_USE_C99_MATH_TR1
965971
endif
966972

967-
CFLAGS := $(CXXFLAGS)
968-
CFLAGS += $(C_STD)
973+
CFLAGS += $(C_STD) $(WARNINGS)
969974
CXXFLAGS += $(CXX_STD) $(CXX_WARNINGS)
970975

971976
# Enumerations of all the source files and headers.
@@ -1130,14 +1135,14 @@ prefix:
11301135
)
11311136

11321137
# Unconditionally create the object dirs on every invocation.
1133-
DIRS = $(sort $(dir $(OBJS)))
1138+
DIRS = $(sort $(dir $(OBJS) $(PCH_P)))
11341139
$(shell mkdir -p $(DIRS))
11351140

11361141
$(ODIR)/%.inc: $(SRC_DIR)/%.cpp
11371142
$(COMPILE.cc) -o /dev/null -Wno-error -H -E $< 2> $@
11381143

11391144
$(ODIR)/%.inc: $(SRC_DIR)/%.c
1140-
$(CXX) -x c $(CPPFLAGS) $(DEFINES) $(CFLAGS) -Wno-error -H -E $< -o /dev/null 2> $@
1145+
$(COMPILE.c) -o /dev/null -Wno-error -H -E $< 2> $@
11411146

11421147
.PHONY: includes
11431148
includes: $(OBJS:.o=.inc)
@@ -1147,7 +1152,7 @@ $(ODIR)/third-party/%.o: $(SRC_DIR)/third-party/%.cpp
11471152
$(COMPILE.cc) $(OUTPUT_OPTION) -w -MMD -MP $<
11481153

11491154
$(ODIR)/third-party/%.o: $(SRC_DIR)/third-party/%.c
1150-
$(COMPILE.cc) $(OUTPUT_OPTION) -x c $(CFLAGS) -w -MMD -MP -c $<
1155+
$(COMPILE.c) $(OUTPUT_OPTION) -x c $(CFLAGS) -w -MMD -MP $<
11511156

11521157
$(ODIR)/%.o: $(SRC_DIR)/%.cpp $(PCH_P)
11531158
$(COMPILE.cc) $(OUTPUT_OPTION) $(PCHFLAGS) -MMD -MP $<
@@ -1183,7 +1188,7 @@ $(CHKJSON_BIN): $(CHKJSON_SOURCES)
11831188
json-check: $(CHKJSON_BIN)
11841189
./$(CHKJSON_BIN)
11851190

1186-
clean: clean-tests clean-pch clean-lang
1191+
clean: clean-tests clean-lang
11871192
rm -rf *$(TARGET_NAME) *$(TILES_TARGET_NAME)
11881193
rm -rf *$(TILES_TARGET_NAME).exe *$(TARGET_NAME).exe *$(TARGET_NAME).a
11891194
rm -rf *obj *objwin
@@ -1441,7 +1446,8 @@ $(BUILD_PREFIX)zstd.a: $(filter $(ODIR)/third-party/zstd/%.o,$(OBJS))
14411446
$(AR) rcs $(AR_FLAGS) $(BUILD_PREFIX)zstd.a $^
14421447

14431448
$(ZZIP_BIN): $(ZZIP_SOURCES) $(BUILD_PREFIX)zstd.a
1444-
$(LINK.cc) $(OUTPUT_OPTION) -MMD -MP -isystem src/third-party $^
1449+
# Remove SDL libraries used by cataclysm
1450+
$(subst $(LDFLAGS),,$(LINK.cc)) $(OUTPUT_OPTION) -MMD -MP -isystem src/third-party $^
14451451

14461452
python-check:
14471453
flake8
@@ -1455,19 +1461,15 @@ check: version $(BUILD_PREFIX)cataclysm.a $(LOCALIZE_TEST_DEPS)
14551461
clean-tests:
14561462
$(MAKE) -C tests clean
14571463

1458-
clean-pch:
1459-
rm -f pch/*pch.hpp.gch
1460-
rm -f pch/*pch.hpp.pch
1461-
rm -f pch/*pch.hpp.d
1462-
$(MAKE) -C tests clean-pch
1463-
14641464
clean-lang:
14651465
$(MAKE) -C lang clean
14661466

1467-
.PHONY: tests check ctags etags clean-tests clean-pch clean-lang install lint
1467+
.PHONY: tests check ctags etags clean-tests clean-lang install lint
14681468

14691469
compile_commands.txt:
14701470
@echo 'COMPILE.cc := $(COMPILE.cc)' > $@
14711471
@echo 'LINK.cc := $(LINK.cc)' >> $@
1472+
@echo 'COMPILE.c := $(COMPILE.c)' >> $@
1473+
@echo 'LINK.c := $(LINK.c)' >> $@
14721474

14731475
-include ${OBJS:.o=.d}

doc/c++/COMPILING-MSYS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ pacman -S git make ncurses-devel gettext-devel mingw-w64-x86_64-{astyle,ccache,c
7373

7474
-> Windows 10 and later
7575
```bash
76-
pacman -S git make ncurses-devel gettext-devel mingw-w64-ucrt-x86_64-{astyle,ccache,cmake,gcc,libmad,libwebp,pkgconf,SDL2,libzip,libavif} mingw-w64-ucrt-x86_64-SDL2_{image,mixer,ttf}
76+
pacman -S git make ncurses-devel gettext-devel mingw-w64-ucrt-x86_64-{astyle,ccache,cmake,freetype,gcc,libmad,libwebp,pkgconf,SDL2,libzip,libavif} mingw-w64-ucrt-x86_64-SDL2_{image,mixer,ttf} zlib-devel
7777
```
7878

7979
5. Close MSYS2.

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ if (TILES)
137137
target_link_libraries(cataclysm-tiles-common PUBLIC setupapi.lib)
138138
if (SOUND)
139139
target_link_libraries(cataclysm-tiles-common PUBLIC shlwapi.lib)
140+
target_link_libraries(cataclysm-tiles-common PUBLIC dwrite.lib)
140141
endif()
141142
if (BACKTRACE)
142143
target_link_libraries(cataclysm-tiles-common PUBLIC dbghelp.lib)

src/character.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,10 +407,13 @@ void Character::queue_effects( const std::vector<effect_on_condition_id> &effect
407407
void Character::queue_effect( const std::string &name, const time_duration &delay,
408408
const time_duration &effect_duration )
409409
{
410+
#pragma GCC diagnostic push
411+
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
410412
global_variables::impl_t ctx = {
411413
{ "effect", diag_value{ name } },
412414
{ "duration", diag_value{ to_turns<int>( effect_duration ) } }
413415
};
416+
#pragma GCC diagnostic pop
414417

415418
effect_on_conditions::queue_effect_on_condition( delay, effect_on_condition_add_effect, *this,
416419
ctx );

src/third-party/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ if (TILES)
110110
if (NOT DYNAMIC_LINKING)
111111
target_link_libraries(imgui PUBLIC
112112
SDL2::SDL2-static
113+
$<TARGET_NAME_IF_EXISTS:PkgConfig::Freetype>
113114
)
114115
else()
115116
target_link_libraries(imgui PUBLIC

src/vpart_range.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ class vehicle_part_iterator
5959

6060
vehicle_part_iterator &operator++() {
6161
cata_assert( vp_ );
62+
#pragma GCC diagnostic push
63+
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
6264
skip_to_next_valid( vp_->part_index() + 1 );
65+
#pragma GCC diagnostic pop
6366
return *this;
6467
}
6568

@@ -70,7 +73,10 @@ class vehicle_part_iterator
7073
if( !vp_.has_value() ) {
7174
return true;
7275
}
76+
#pragma GCC diagnostic push
77+
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
7378
return &vp_->vehicle() == &rhs.vp_->vehicle() && vp_->part_index() == rhs.vp_->part_index();
79+
#pragma GCC diagnostic pop
7480
}
7581
bool operator!=( const vehicle_part_iterator &rhs ) const {
7682
return !operator==( rhs );

tests/Makefile

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ ifeq ($(PCH), 1)
3939
PCHFLAGS += -DCATA_CATCH_PCH
4040
PCH_H = pch/tests-pch.hpp
4141
ifeq ($(CLANG), 0)
42-
PCH_P = $(PCH_H).gch
42+
PCH_P = $(ODIR)/$(PCH_H).gch
4343
else
44-
PCH_P = $(PCH_H).pch
44+
PCH_P = $(ODIR)/$(PCH_H).pch
4545
CXXFLAGS += -Wno-unused-macros
4646
endif
4747
endif
@@ -70,17 +70,12 @@ check: $(TEST_TARGET) $(TEST_BATCHES)
7070
check-single: $(TEST_TARGET)
7171
cd .. && tests/$(TEST_TARGET) --min-duration 0.2 --rng-seed time --order lex
7272

73-
clean: clean-pch
73+
clean:
7474
rm -rf *obj *objwin
7575
rm -f *cata_test
7676

77-
clean-pch:
78-
rm -f pch/*pch.hpp.gch
79-
rm -f pch/*pch.hpp.pch
80-
rm -f pch/*pch.hpp.d
81-
8277
#Unconditionally create object directory on invocation.
83-
$(shell mkdir -p $(ODIR))
78+
$(shell mkdir -p $(ODIR) $(dir $(PCH_P)))
8479

8580
# Adding ../tests/ so that the directory appears in __FILE__ for log messages
8681
$(ODIR)/%.o: %.cpp $(PCH_P)
@@ -92,7 +87,7 @@ $(ODIR)/%.inc: %.cpp
9287
.PHONY: includes
9388
includes: $(OBJS:.o=.inc)
9489

95-
.PHONY: clean clean-pch check check-single tests precompile_header
90+
.PHONY: clean check check-single tests precompile_header
9691

9792
.SECONDARY: $(OBJS)
9893

0 commit comments

Comments
 (0)