Skip to content

Commit f3bed9a

Browse files
committed
switch to exclude and ifndef because of how compiler defines are propogated in cmake
it's probably possible to get this working with some intense cmake digging on the port side but i don't see a clear path forward with that at the moment
1 parent 9ebc8c9 commit f3bed9a

File tree

6 files changed

+60
-11
lines changed

6 files changed

+60
-11
lines changed

.github/workflows/build-validation.yml

+49
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,55 @@ jobs:
104104
name: soh-linux
105105
path: build-cmake/src/*.a
106106
if-no-files-found: error
107+
build-linux-no-mpq:
108+
runs-on: ubuntu-latest
109+
steps:
110+
- uses: actions/checkout@v2
111+
- name: Install dependencies
112+
run: |
113+
sudo apt-get update
114+
sudo apt-get install -y $(cat .github/workflows/apt-deps.txt)
115+
- name: ccache
116+
uses: hendrikmuhs/[email protected]
117+
with:
118+
key: ${{ matrix.os }}-ccache-${{ github.ref }}-${{ github.sha }}
119+
restore-keys: |
120+
${{ matrix.os }}-ccache-${{ github.ref }}
121+
${{ matrix.os }}-ccache-
122+
- name: Install latest SDL
123+
run: |
124+
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
125+
wget https://www.libsdl.org/release/SDL2-2.24.1.tar.gz
126+
tar -xzf SDL2-2.24.1.tar.gz
127+
cd SDL2-2.24.1
128+
./configure
129+
make -j 10
130+
sudo make install
131+
- name: Install latest tinyxml2
132+
run: |
133+
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
134+
wget https://github.com/leethomason/tinyxml2/archive/refs/tags/10.0.0.tar.gz
135+
tar -xzf 10.0.0.tar.gz
136+
cd tinyxml2-10.0.0
137+
mkdir build
138+
cd build
139+
cmake ..
140+
make
141+
sudo make install
142+
- name: Build libultraship
143+
run: |
144+
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
145+
cmake --no-warn-unused-cli -H. -Bbuild-cmake -GNinja -DCMAKE_BUILD_TYPE:STRING=Release -DEXCLUDE_MPQ_SUPPORT=TRUE
146+
cmake --build build-cmake --config Release --parallel 10
147+
env:
148+
CC: gcc-10
149+
CXX: g++-10
150+
- name: Upload build
151+
uses: actions/upload-artifact@v3
152+
with:
153+
name: soh-linux
154+
path: build-cmake/src/*.a
155+
if-no-files-found: error
107156
build-windows:
108157
runs-on: windows-latest
109158
steps:

CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ include(cmake/Utils.cmake)
2424
set(ADDITIONAL_LIB_INCLUDES "")
2525

2626
# ========= Configuration Options =========
27-
set(MPQ_SUPPORT TRUE CACHE BOOL "Include StormLib and support using MPQ archives")
28-
if(MPQ_SUPPORT)
29-
add_compile_definitions(MPQ_SUPPORT)
27+
set(EXCLUDE_MPQ_SUPPORT FALSE CACHE BOOL "Exclude StormLib and MPQ archive support")
28+
if(EXCLUDE_MPQ_SUPPORT)
29+
add_compile_definitions(EXCLUDE_MPQ_SUPPORT)
3030
endif()
3131

3232
# =========== Dependencies =============

cmake/dependencies/common.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ target_sources(ImGui
3232
target_include_directories(ImGui PUBLIC ${imgui_SOURCE_DIR} ${imgui_SOURCE_DIR}/backends PRIVATE ${SDL2_INCLUDE_DIRS})
3333

3434
# ========= StormLib =============
35-
if(MPQ_SUPPORT)
35+
if(NOT EXCLUDE_MPQ_SUPPORT)
3636
FetchContent_Declare(
3737
StormLib
3838
GIT_REPOSITORY https://github.com/ladislav-zezula/StormLib.git

src/resource/archive/ArchiveManager.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "spdlog/spdlog.h"
55

66
#include "resource/archive/Archive.h"
7-
#ifdef MPQ_SUPPORT
7+
#ifndef EXCLUDE_MPQ_SUPPORT
88
#include "resource/archive/OtrArchive.h"
99
#endif
1010
#include "resource/archive/O2rArchive.h"
@@ -153,7 +153,7 @@ std::shared_ptr<Archive> ArchiveManager::AddArchive(const std::string& archivePa
153153

154154
if (StringHelper::IEquals(extension, ".zip") || StringHelper::IEquals(extension, ".zip")) {
155155
archive = dynamic_pointer_cast<Archive>(std::make_shared<O2rArchive>(archivePath));
156-
#ifdef MPQ_SUPPORT
156+
#ifndef EXCLUDE_MPQ_SUPPORT
157157
} else if (StringHelper::IEquals(extension, ".otr") || StringHelper::IEquals(extension, ".mpq")) {
158158
archive = dynamic_pointer_cast<Archive>(std::make_shared<OtrArchive>(archivePath));
159159
#endif

src/resource/archive/OtrArchive.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#ifdef MPQ_SUPPORT
1+
#ifndef EXCLUDE_MPQ_SUPPORT
22

33
#include "OtrArchive.h"
44

@@ -103,4 +103,4 @@ bool OtrArchive::Close() {
103103

104104
} // namespace Ship
105105

106-
#endif // MPQ_SUPPORT
106+
#endif // EXCLUDE_MPQ_SUPPORT

src/resource/archive/OtrArchive.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#pragma once
1+
#ifndef EXCLUDE_MPQ_SUPPORT
22

3-
#ifdef MPQ_SUPPORT
3+
#pragma once
44

55
#undef _DLL
66

@@ -38,4 +38,4 @@ class OtrArchive : virtual public Archive {
3838
};
3939
} // namespace Ship
4040

41-
#endif // MPQ_SUPPORT
41+
#endif // EXCLUDE_MPQ_SUPPORT

0 commit comments

Comments
 (0)