Skip to content

Commit 27f63a3

Browse files
Merge pull request aburch#11 from Roboron3042/master
Finally fix zstd static build aburch#4 and other build systems
2 parents 38c5847 + 4b924ad commit 27f63a3

7 files changed

Lines changed: 60 additions & 56 deletions

File tree

.github/workflows/ci.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -460,19 +460,18 @@ jobs:
460460
name: Windows (MSVC, headless, zstd, UPNP)
461461
runs-on: windows-latest
462462
needs: check-code-formatting
463-
if: ${{ false }} #Disabled as not working
463+
if: always()
464464
steps:
465465
- name: Checkout
466466
uses: actions/checkout@v2
467467
- name: Set up build dir
468468
run: mkdir ${{ github.workspace }}/build
469469
- name: Install dependencies using vcpkg
470-
uses: lukka/run-vcpkg@v4.1
471-
with:
472-
vcpkgDirectory: '${{ github.workspace }}/build/vcpkg'
473-
vcpkgArguments: '--disable-metrics zlib bzip2 miniupnpc zstd libpng'
474-
vcpkgGitCommitId: 6185aa76504a5025f36754324abf307cc776f3da
475-
vcpkgTriplet: x64-windows-static
470+
run: |
471+
cd ${{ github.workspace }}/build
472+
git clone https://github.com/Microsoft/vcpkg
473+
./vcpkg/bootstrap-vcpkg.bat
474+
./vcpkg/vcpkg --triplet x64-windows-static install zlib bzip2 libpng zstd sdl2 freetype miniupnpc
476475
- name: Add msbuild to PATH
477476
uses: microsoft/setup-msbuild@v1.0.2
478477
- name: Configure

CMakeLists.txt

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,6 @@ if (NOT MSVC)
7979
endif (NOT MSVC)
8080

8181

82-
#
83-
# output directory
84-
#
85-
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/simutrans)
86-
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/simutrans)
87-
8882
#
8983
# sources
9084
#
@@ -95,6 +89,14 @@ endif ()
9589

9690
include(SimutransSourceList)
9791

92+
93+
#
94+
# output directory
95+
#
96+
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/simutrans)
97+
set_target_properties( simutrans-extended PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/simutrans/$<0:> )
98+
99+
98100
#
99101
# Libraries
100102
#
@@ -107,8 +109,11 @@ if (WIN32)
107109
target_link_libraries(simutrans-extended PRIVATE ws2_32 winmm)
108110

109111
# Backup sound and music routines if the selected backend does not provide any routines
110-
#set(BACKUP_SOUND sound/win32_sound_xa.cc)
111-
set(BACKUP_SOUND sound/win32_sound.cc)
112+
if (MINGW)
113+
set(BACKUP_SOUND sound/win32_sound.cc)
114+
else ()
115+
set(BACKUP_SOUND sound/win32_sound_xa.cc)
116+
endif ()
112117
set(BACKUP_MUSIC music/w32_midi.cc)
113118
else ()
114119
if (SIMUTRANS_BACKEND STREQUAL "sdl2")
@@ -197,7 +202,7 @@ if (SIMUTRANS_USE_ZSTD)
197202
target_include_directories(simutrans-extended PRIVATE ${ZSTD_INCLUDE_DIRS})
198203
target_compile_definitions(simutrans-extended PRIVATE USE_ZSTD=1)
199204
if (MSVC)
200-
target_link_libraries(simutrans-extended PRIVATE ZSTD::libzstd_static)
205+
target_link_libraries(simutrans-extended PRIVATE zstd::libzstd_static)
201206
elseif (MINGW)
202207
# only 64 bit cmake, 32 bit is broken
203208
target_link_libraries(simutrans-extended PRIVATE -lzstd)

Makefile

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ else
5050
LIBS += -lmingw32
5151
endif
5252
endif
53-
SOURCES += sys/simsys_w32_png.cc
5453
CFLAGS += -DNOMINMAX -DWIN32_LEAN_AND_MEAN -DWINVER=0x0501 -D_WIN32_IE=0x0500
5554
LIBS += -lgdi32 -lwinmm -lws2_32 -limm32
5655
# Disable the console on Windows unless WIN32_CONSOLE is set or graphics are disabled
@@ -77,14 +76,12 @@ ifeq ($(OSTYPE),mac)
7776
LDFLAGS += -stdlib=libc++
7877
endif
7978

80-
ifeq ($(OSTYPE), mingw64)
79+
ifeq ($(BACKEND),sdl2)
80+
SOURCES += sys/clipboard_s2.cc
81+
else ifeq ($(OSTYPE),mingw)
8182
SOURCES += sys/clipboard_w32.cc
8283
else
83-
ifeq ($(OSTYPE),mingw32)
84-
SOURCES += sys/clipboard_w32.cc
85-
else
86-
SOURCES += sys/clipboard_internal.cc
87-
endif
84+
SOURCES += sys/clipboard_internal.cc
8885
endif
8986

9087
ifeq ($(OSTYPE),openbsd)
@@ -121,7 +118,7 @@ ifneq ($(TUNE_NATIVE),)
121118
CFLAGS += -march=native -mtune=native
122119
LDFLAGS += -march=native -mtune=native
123120
ifneq ($(GCC_POPCOUNT),)
124-
CFLAGS += -DUSE_GCC_POPCOUNT
121+
CFLAGS += -DUSE_GCC_POPCOUNT
125122
endif
126123
endif
127124

@@ -492,6 +489,10 @@ SOURCES += gui/welt.cc
492489
SOURCES += io/classify_file.cc
493490
SOURCES += io/rdwr/bzip2_file_rdwr_stream.cc
494491
SOURCES += io/rdwr/raw_file_rdwr_stream.cc
492+
SOURCES += io/raw_image.cc
493+
SOURCES += io/raw_image_bmp.cc
494+
SOURCES += io/raw_image_png.cc
495+
SOURCES += io/raw_image_ppm.cc
495496
SOURCES += io/rdwr/rdwr_stream.cc
496497
SOURCES += io/rdwr/zlib_file_rdwr_stream.cc
497498
SOURCES += network/checksum.cc
@@ -625,7 +626,7 @@ ifeq ($(BACKEND),posix)
625626

626627
else ifeq ($(BACKEND),gdi)
627628
SOURCES += sys/simsys_w.cc
628-
SOURCES += sound/win32_sound.cc
629+
SOURCES += sound/win32_sound_xa.cc
629630
CFLAGS += -DGDI_SOUND
630631
ifneq ($(shell expr $(USE_FLUIDSYNTH_MIDI) \>= 1), 1)
631632
SOURCES += music/w32_midi.cc

Simutrans-Extended.vcxproj

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1934,6 +1934,10 @@
19341934
<ClCompile Include="descriptor\vehicle_desc.cc" />
19351935
<ClCompile Include="descriptor\way_desc.cc" />
19361936
<ClCompile Include="io\classify_file.cc" />
1937+
<ClCompile Include="io\raw_image.cc" />
1938+
<ClCompile Include="io\raw_image_bmp.cc" />
1939+
<ClCompile Include="io\raw_image_png.cc" />
1940+
<ClCompile Include="io\raw_image_ppm.cc" />
19371941
<ClCompile Include="io\rdwr\bzip2_file_rdwr_stream.cc" />
19381942
<ClCompile Include="io\rdwr\raw_file_rdwr_stream.cc" />
19391943
<ClCompile Include="io\rdwr\rdwr_stream.cc" />
@@ -2165,9 +2169,6 @@
21652169
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
21662170
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Optimised debug|x64'">false</ExcludedFromBuild>
21672171
</ClCompile>
2168-
<ClCompile Include="sys\simsys_w32_png.cc">
2169-
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release (command-line server)|Win32'">false</ExcludedFromBuild>
2170-
</ClCompile>
21712172
<ClCompile Include="simunits.cc" />
21722173
<ClCompile Include="sound\no_sound.cc">
21732174
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug-64|Win32'">true</ExcludedFromBuild>
@@ -2326,17 +2327,6 @@
23262327
<ClCompile Include="dataobj\loadsave.cc" />
23272328
<ClCompile Include="gui\loadsave_frame.cc" />
23282329
<ClCompile Include="utils\csv.cc" />
2329-
<ClCompile Include="utils\dr_rdpng.cc">
2330-
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
2331-
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Optimised debug|Win32'">true</ExcludedFromBuild>
2332-
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug (no randomness)|Win32'">true</ExcludedFromBuild>
2333-
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug (single threaded new)|Win32'">true</ExcludedFromBuild>
2334-
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug (graphical server)|Win32'">true</ExcludedFromBuild>
2335-
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug (non-graphical server)|Win32'">true</ExcludedFromBuild>
2336-
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
2337-
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release (command-line server)|Win32'">true</ExcludedFromBuild>
2338-
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug (command-line server)|Win32'">true</ExcludedFromBuild>
2339-
</ClCompile>
23402330
<ClCompile Include="utils\float32e8_t.cc" />
23412331
<ClCompile Include="utils\log.cc" />
23422332
<ClCompile Include="boden\wege\maglev.cc" />
@@ -2528,7 +2518,7 @@
25282518
<ClCompile Include="bauer\wegbauer.cc" />
25292519
<ClCompile Include="gui\welt.cc" />
25302520
<ClCompile Include="gui\tool_selector.cc" />
2531-
<ClCompile Include="sound\win32_sound.cc">
2521+
<ClCompile Include="sound\win32_sound_xa.cc">
25322522
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug (SDL 2)|Win32'">true</ExcludedFromBuild>
25332523
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug (non-graphical server)|x64'">true</ExcludedFromBuild>
25342524
</ClCompile>
@@ -2590,6 +2580,7 @@
25902580
<ClInclude Include="gui\times_history_container.h" />
25912581
<ClInclude Include="gui\vehicle_class_manager.h" />
25922582
<ClInclude Include="io\classify_file.h" />
2583+
<ClCompile Include="io\raw_image.h" />
25932584
<ClInclude Include="io\rdwr\bzip2_file_rdwr_stream.h" />
25942585
<ClInclude Include="io\rdwr\raw_file_rdwr_stream.h" />
25952586
<ClInclude Include="io\rdwr\rdwr_stream.h" />
@@ -2719,7 +2710,6 @@
27192710
<ClInclude Include="gui\depotlist_frame.h" />
27202711
<ClInclude Include="utils\csv.h" />
27212712
<ClInclude Include="utils\dr_rdgif.h" />
2722-
<ClInclude Include="utils\dr_rdpng.h" />
27232713
<ClInclude Include="utils\dr_rdppm.h" />
27242714
<ClInclude Include="gui\enlarge_map_frame_t.h" />
27252715
<ClInclude Include="gui\extend_edit.h" />
@@ -3142,4 +3132,4 @@
31423132
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
31433133
<ImportGroup Label="ExtensionTargets">
31443134
</ImportGroup>
3145-
</Project>
3135+
</Project>

cmake/SimutransVcpkgTriplet.cmake

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@
55
# set the correct triplet when compiling on MSVC using VCPKG
66
#
77

8-
if (MSVC AND DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
9-
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "")
8+
# MSVC variable is not defined until the first call to project
9+
if (CMAKE_GENERATOR MATCHES "Visual Studio.*" OR CMAKE_GENERATOR MATCHES "Ninja" AND WIN32)
10+
if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
11+
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "CMAKE_TOOLCHAIN_FILE")
12+
elseif (NOT DEFINED CMAKE_TOOLCHAIN_FILE)
13+
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/build/vcpkg/scripts/buildsystems/vcpkg.cmake" CACHE STRING "CMAKE_TOOLCHAIN_FILE")
14+
endif ()
1015
endif ()
1116

1217

@@ -23,7 +28,7 @@ if (CMAKE_TOOLCHAIN_FILE_LC MATCHES ".*vcpkg.cmake")
2328
if (DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET)
2429
set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}" CACHE STRING "")
2530
endif ()
26-
31+
2732
# if not defined, then guess
2833
if (NOT DEFINED VCPKG_TARGET_TRIPLET)
2934
if (DEFINED CMAKE_INSTALL_PREFIX)
@@ -54,9 +59,9 @@ if (CMAKE_TOOLCHAIN_FILE_LC MATCHES ".*vcpkg.cmake")
5459
message( WARNING "Static build preferred on windows => make static target " ${STATIC_TRIPLET} )
5560
endif ()
5661
endif ()
57-
message( "-- VCPKG: triplet=" ${VCPKG_TARGET_TRIPLET} " platform=" ${CMAKE_GENERATOR_PLATFORM})
62+
message( "-- VCPKG: triplet=" ${VCPKG_TARGET_TRIPLET} " platform=" ${CMAKE_GENERATOR_PLATFORM})
5863
else ()
59-
if (MSVC)
64+
if (CMAKE_GENERATOR MATCHES "Visual Studio.*" OR CMAKE_GENERATOR MATCHES "Ninja" AND WIN32)
6065
message(WARNING "CMake will fail without setting CMAKE_TOOLCHAIN_FILE!")
6166
endif ()
6267
endif ()

io/raw_image_bmp.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,18 @@ struct bitmap_info_header_t
5454

5555
enum compression_method_t
5656
{
57-
BI_RGB = 0,
58-
BI_RLE8 = 1,
59-
BI_RLE4 = 2
57+
BIRGB = 0,
58+
BIRLE8 = 1,
59+
BIRLE4 = 2
6060
};
6161

6262

6363
static bool is_format_supported(uint16 bpp, uint32 compression)
6464
{
65-
if (compression == BI_RGB) {
65+
if (compression == BIRGB) {
6666
return bpp == 8 || bpp == 24;
6767
}
68-
else if (compression == BI_RLE8) {
68+
else if (compression == BIRLE8) {
6969
return bpp == 8;
7070
}
7171
else {
@@ -120,7 +120,7 @@ bool raw_image_t::read_bmp(const char *filename)
120120

121121
// We only allow the following image formats:
122122
// 8 bit: BI_RGB (uncompressed)
123-
// BI_RLE8 (8 bit RLE)
123+
// BIRLE8 (8 bit RLE)
124124
// 24 bit: BI_RGB
125125
if( !is_format_supported(bit_depth, compression) ) {
126126
dbg->warning("raw_image_t::read_bmp", "Can only use 8 bit (RLE or normal) or 24 bit bitmaps!");
@@ -379,7 +379,7 @@ bool raw_image_t::write_bmp(const char *filename) const
379379
iheader.height = endian(sint32(get_height()));
380380
iheader.num_color_planes = endian(uint16(1));
381381
iheader.bpp = endian(uint16(bpp));
382-
iheader.compression = endian(uint32(BI_RGB));
382+
iheader.compression = endian(uint32(BIRGB));
383383
iheader.horizontal_resolution = 0;
384384
iheader.vertical_resolution = 0;
385385
iheader.num_palette_colors = 0;

network/network.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -883,8 +883,12 @@ bool get_external_IP( cbuffer_t &myIPaddr, cbuffer_t &altIPaddr )
883883
*/
884884

885885
extern "C" {
886-
#include <miniupnpc.h>
887-
#include <upnpcommands.h>
886+
#define MINIUPNPC_DECLSPEC_H_INCLUDED
887+
#define MINIUPNP_LIBSPEC extern
888+
889+
//#define MINIUPNP_STATICLIB
890+
#include <miniupnpc/miniupnpc.h>
891+
#include <miniupnpc/upnpcommands.h>
888892
}
889893

890894
#if MINIUPNPC_API_VERSION < 14

0 commit comments

Comments
 (0)