Skip to content

Commit 2611431

Browse files
authored
Replace libjpeg-turbo with IJG's libjpeg (#795)
* Replace libjpeg-turbo with IJG's libjpeg libjpeg-turbo is a bad fit as a CMake dependency. It requires the use of ExternalProject_Add() which creates complications, particularly when swapping the compiler (e.g. for mingw), not to mention as-is, it ends up having to fetch at build time rather than configure time like every other dependency. As we only use this for screenshots (KSCs) (i.e. its use is limited to the KscViewer and the very rare instance of pressing the in-game screenshot button), the performance benefit of libjpeg-turbo is fairly moot. For simplicity, we go back to the basic IJG implementation (with unofficially added CMake config). This allows us to use the dependency directly and consistently with the others, and there's no concern with it using a different compiler unintentionally. * clang-tidy-check.yml doesn't need hacks anymore
1 parent 33c2b00 commit 2611431

25 files changed

+461
-832
lines changed

.github/workflows/clang-tidy-check.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,6 @@ jobs:
7272
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON `
7373
-DCMAKE_DISABLE_PRECOMPILE_HEADERS=TRUE
7474

75-
- name: Build external CMake projects
76-
shell: pwsh
77-
run: |
78-
cmake `
79-
--build build-windows-${{ matrix.BUILD_CONFIGURATION }}-${{ matrix.BUILD_PLATFORM }} `
80-
--target libjpeg-turbo-project
81-
8275
- uses: Open-KO/cpp-linter-action@OpenKO
8376
name: "Run linter"
8477
id: linter

.gitmodules

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@
1212
url = https://github.com/madler/zlib
1313
branch = master
1414
shallow = true
15-
[submodule "deps/libjpeg-turbo"]
16-
path = deps/libjpeg-turbo
17-
url = https://github.com/libjpeg-turbo/libjpeg-turbo
18-
branch = main
19-
shallow = true
2015
[submodule "deps/db-models"]
2116
path = deps/db-models
2217
url = https://github.com/Open-KO/OpenKO-db-models
@@ -61,3 +56,7 @@
6156
path = deps/openal-soft
6257
url = https://github.com/Open-KO/openal-soft
6358
shallow = true
59+
[submodule "deps/libjpeg"]
60+
path = deps/libjpeg
61+
url = https://github.com/Open-KO/jpeg-cmake
62+
shallow = true

All.slnx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
</Folder>
145145
<Folder Name="/_deps/">
146146
<Project Path="src/Client/JpegFile/JpegFile.vcxproj" Id="e3ce5b4f-97bc-46b1-b36d-25ab39d4a3f9">
147-
<BuildDependency Project="deps/fetch-and-build-wrappers/fetch-libjpeg-turbo.vcxproj" />
147+
<BuildDependency Project="deps/fetch-and-build-wrappers/fetch-libjpeg.vcxproj" />
148148
</Project>
149149
<Project Path="src/db-library/db-library.vcxproj" Id="05054154-a8f1-4094-ab01-e1402cd9f65a">
150150
<BuildDependency Project="deps/fetch-and-build-wrappers/fetch-db-models.vcxproj" />
@@ -191,7 +191,7 @@
191191
<Project Path="deps/fetch-and-build-wrappers/fetch-ko-client-assets.vcxproj" Id="0047bee8-1361-6bcb-3edf-26dcb127e1b5">
192192
<BuildDependency Project="deps/fetch-and-build-wrappers/sync-submodules.vcxproj" />
193193
</Project>
194-
<Project Path="deps/fetch-and-build-wrappers/fetch-libjpeg-turbo.vcxproj" Id="56988836-40f9-f81d-c8b4-4dc1ce5901e2">
194+
<Project Path="deps/fetch-and-build-wrappers/fetch-libjpeg.vcxproj" Id="56988836-40f9-f81d-c8b4-4dc1ce5901e2">
195195
<BuildDependency Project="deps/fetch-and-build-wrappers/sync-submodules.vcxproj" />
196196
</Project>
197197
<Project Path="deps/fetch-and-build-wrappers/fetch-mpg123.vcxproj" Id="b24123a5-2fe3-4ad6-9b8d-c3090e87408d">

CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,7 @@ if(MSVC)
138138
# so we'll pull this in here.
139139
require_config_package(client-assets)
140140

141-
# libjpeg-turbo doesn't allow regular builds. They insist on manual/external builds,
142-
# so we must structure this a little bit differently to everything else.
143-
require_package(JpegTurbo)
141+
require_package(Jpeg)
144142
add_subdirectory(src/Client/JpegFile)
145143
endif()
146144

Client.slnx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</Configurations>
66
<Folder Name="/_deps/">
77
<Project Path="src/Client/JpegFile/JpegFile.vcxproj" Id="e3ce5b4f-97bc-46b1-b36d-25ab39d4a3f9">
8-
<BuildDependency Project="deps/fetch-and-build-wrappers/fetch-libjpeg-turbo.vcxproj" />
8+
<BuildDependency Project="deps/fetch-and-build-wrappers/fetch-libjpeg.vcxproj" />
99
</Project>
1010
<Project Path="src/N3Base/N3Base_client.vcxproj" Id="d06d505a-f28e-343f-09f4-c3809398b508">
1111
<BuildDependency Project="deps/fetch-and-build-wrappers/fetch-dx9sdk.vcxproj" />
@@ -33,7 +33,7 @@
3333
<Project Path="deps/fetch-and-build-wrappers/fetch-ko-client-assets.vcxproj" Id="0047bee8-1361-6bcb-3edf-26dcb127e1b5">
3434
<BuildDependency Project="deps/fetch-and-build-wrappers/sync-submodules.vcxproj" />
3535
</Project>
36-
<Project Path="deps/fetch-and-build-wrappers/fetch-libjpeg-turbo.vcxproj" Id="56988836-40f9-f81d-c8b4-4dc1ce5901e2">
36+
<Project Path="deps/fetch-and-build-wrappers/fetch-libjpeg.vcxproj" Id="56988836-40f9-f81d-c8b4-4dc1ce5901e2">
3737
<BuildDependency Project="deps/fetch-and-build-wrappers/sync-submodules.vcxproj" />
3838
</Project>
3939
<Project Path="deps/fetch-and-build-wrappers/fetch-mpg123.vcxproj" Id="b24123a5-2fe3-4ad6-9b8d-c3090e87408d">

ClientTools.slnx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
</Configurations>
66
<Folder Name="/_deps/">
77
<Project Path="src/Client/JpegFile/JpegFile.vcxproj" Id="e3ce5b4f-97bc-46b1-b36d-25ab39d4a3f9">
8-
<BuildDependency Project="deps/fetch-and-build-wrappers/fetch-libjpeg-turbo.vcxproj" />
8+
<BuildDependency Project="deps/fetch-and-build-wrappers/fetch-libjpeg.vcxproj" />
99
</Project>
1010
<Project Path="src/Client/ZipArchive/ZipArchive.vcxproj" Id="6e97fd6e-7530-4be3-b8e6-9e17ed45cd45">
1111
<BuildDependency Project="deps/fetch-and-build-wrappers/fetch-zlib.vcxproj" />
1212
</Project>
1313
</Folder>
1414
<Folder Name="/_deps/fetch wrappers/">
15-
<Project Path="deps/fetch-and-build-wrappers/fetch-libjpeg-turbo.vcxproj" Id="56988836-40f9-f81d-c8b4-4dc1ce5901e2">
15+
<Project Path="deps/fetch-and-build-wrappers/fetch-libjpeg.vcxproj" Id="56988836-40f9-f81d-c8b4-4dc1ce5901e2">
1616
<BuildDependency Project="deps/fetch-and-build-wrappers/sync-submodules.vcxproj" />
1717
</Project>
1818
<Project Path="deps/fetch-and-build-wrappers/fetch-zlib.vcxproj" Id="99b647bc-d49e-4322-c338-dc20acc4239b">

Tests.slnx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</Folder>
1515
<Folder Name="/_deps/">
1616
<Project Path="src/Client/JpegFile/JpegFile.vcxproj" Id="e3ce5b4f-97bc-46b1-b36d-25ab39d4a3f9">
17-
<BuildDependency Project="deps/fetch-and-build-wrappers/fetch-libjpeg-turbo.vcxproj" />
17+
<BuildDependency Project="deps/fetch-and-build-wrappers/fetch-libjpeg.vcxproj" />
1818
</Project>
1919
<Project Path="src/N3Base/N3Base_client.vcxproj" Id="d06d505a-f28e-343f-09f4-c3809398b508">
2020
<BuildDependency Project="deps/fetch-and-build-wrappers/fetch-dx9sdk.vcxproj" />
@@ -81,7 +81,7 @@
8181
<Project Path="deps/fetch-and-build-wrappers/fetch-ko-client-assets.vcxproj" Id="0047bee8-1361-6bcb-3edf-26dcb127e1b5">
8282
<BuildDependency Project="deps/fetch-and-build-wrappers/sync-submodules.vcxproj" />
8383
</Project>
84-
<Project Path="deps/fetch-and-build-wrappers/fetch-libjpeg-turbo.vcxproj" Id="56988836-40f9-f81d-c8b4-4dc1ce5901e2">
84+
<Project Path="deps/fetch-and-build-wrappers/fetch-libjpeg.vcxproj" Id="56988836-40f9-f81d-c8b4-4dc1ce5901e2">
8585
<BuildDependency Project="deps/fetch-and-build-wrappers/sync-submodules.vcxproj" />
8686
</Project>
8787
<Project Path="deps/fetch-and-build-wrappers/fetch-mpg123.vcxproj" Id="b24123a5-2fe3-4ad6-9b8d-c3090e87408d">

ThirdParty.slnx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<Project Path="deps/fetch-and-build-wrappers/fetch-googletest.vcxproj" Id="d4f3d338-a7ef-430c-ad99-2fc6a591a711">
2424
<BuildDependency Project="deps/fetch-and-build-wrappers/sync-submodules.vcxproj" />
2525
</Project>
26-
<Project Path="deps/fetch-and-build-wrappers/fetch-libjpeg-turbo.vcxproj" Id="56988836-40f9-f81d-c8b4-4dc1ce5901e2">
26+
<Project Path="deps/fetch-and-build-wrappers/fetch-libjpeg.vcxproj" Id="56988836-40f9-f81d-c8b4-4dc1ce5901e2">
2727
<BuildDependency Project="deps/fetch-and-build-wrappers/sync-submodules.vcxproj" />
2828
</Project>
2929
<Project Path="deps/fetch-and-build-wrappers/fetch-mpg123.vcxproj" Id="b24123a5-2fe3-4ad6-9b8d-c3090e87408d">
@@ -50,8 +50,8 @@
5050
<BuildDependency Project="deps/fetch-and-build-wrappers/fetch-db-models.vcxproj" />
5151
<Build Project="false" />
5252
</Project>
53-
<Project Path="deps/libjpeg-turbo-msvc/jpeg-static.vcxproj" Id="569846a7-5a48-3b16-bb39-be89e1c71caa">
54-
<BuildDependency Project="deps/fetch-and-build-wrappers/fetch-libjpeg-turbo.vcxproj" />
53+
<Project Path="deps/libjpeg-msvc/jpeg-static.vcxproj" Id="569846a7-5a48-3b16-bb39-be89e1c71caa">
54+
<BuildDependency Project="deps/fetch-and-build-wrappers/fetch-libjpeg.vcxproj" />
5555
<Build Project="false" />
5656
</Project>
5757
<Project Path="deps/mpg123-msvc/mpg123.vcxproj" Id="c93d6595-cd66-4e98-b99d-31da0e2ec408">

cmake/FindJpeg.cmake

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Get Jpeg package
2+
#
3+
# Makes the libjpeg target available.
4+
5+
fetchcontent_declare(
6+
jpeg
7+
GIT_REPOSITORY "https://github.com/Open-KO/jpeg-cmake.git"
8+
GIT_TAG "v1.3.0a-OpenKO"
9+
GIT_PROGRESS ON
10+
GIT_SHALLOW ON
11+
EXCLUDE_FROM_ALL
12+
)
13+
14+
if(WIN32)
15+
set(LIBJPEG_BUILD_SHARED_LIBS OFF CACHE BOOL "libjpeg: Build shared libraries")
16+
set(LIBJPEG_BUILD_STATIC_LIBS ON CACHE BOOL "libjpeg: Build static libraries")
17+
else()
18+
set(LIBJPEG_BUILD_SHARED_LIBS ON CACHE BOOL "libjpeg: Build shared libraries")
19+
set(LIBJPEG_BUILD_STATIC_LIBS OFF CACHE BOOL "libjpeg: Build static libraries")
20+
endif()
21+
22+
set(LIBJPEG_INSTALL OFF CACHE BOOL "libjpeg: Install targets and headers")
23+
set(LIBJPEG_BUILD_EXECUTABLES OFF CACHE BOOL "libjpeg: Build JPEG utilities")
24+
set(LIBJPEG_BUILD_TESTS OFF CACHE BOOL "libjpeg: Build test executables")
25+
26+
fetchcontent_makeavailable(jpeg)
27+
28+
# Setup a wrapper project to reference the preferred jpeg target for this build
29+
add_library(libjpeg INTERFACE)
30+
if(WIN32)
31+
target_link_libraries(libjpeg INTERFACE jpeg_static)
32+
else()
33+
target_link_libraries(libjpeg INTERFACE jpeg)
34+
endif()
35+
36+
set(jpeg_FOUND TRUE)

cmake/FindJpegTurbo.cmake

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)