Skip to content

Commit

Permalink
Fix WASM builds
Browse files Browse the repository at this point in the history
- Removes the dependency on VCPKG entirely, due to conflicts between VCPKG and Emscripten
- Adds an optional submodule target for GLM
- Moves CMake code relative to dependencies into their dependency files (mk/cmake/SuperTux/Provide*.cmake)
- Updates (and significantly simplifies) the build steps for WASM
- Fixes a compilation error in `#ifdef EMSCRIPTEN`-guarded code
- Allows using the latest version of Emscripten (3.something) instead of the old 1.40 branch
- Removes the need to patch SDL_ttf, and adds an option to use the builds provided by Emscripten
- Updates the workflow files to reflect those changes
  • Loading branch information
Semphris committed Jun 26, 2023
1 parent 617933b commit 0dc4025
Show file tree
Hide file tree
Showing 17 changed files with 148 additions and 143 deletions.
47 changes: 8 additions & 39 deletions .github/workflows/wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
matrix:
build_type: ["Release", "Debug"]

runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -46,38 +46,8 @@ jobs:
sudo apt-get install -y git cmake build-essential curl zip
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install 1.40.1
./emsdk activate 1.40.1
# Fixes a bug in emscripten - see https://github.com/emscripten-core/emscripten/issues/13590
sed -i "s/\#define MALLOC_ALIGNMENT ((size_t)(2 \* sizeof(void \*)))/#define MALLOC_ALIGNMENT 16/g" upstream/emscripten/system/lib/dlmalloc.c
# Fixes a bug with the libjpeg port - see https://github.com/emscripten-core/emscripten/pull/13878
sed -i 's/2b581c60ae401a79bbbe748ff2deeda5acd50bfd2ea22e5926e36d34b9ebcffb6580b0ff48e972c1441583e30e21e1ea821ca0423f9c67ce08a31dffabdbe6b7/b2affe9a1688bd49fc033f4682c4a242d4ee612f1affaef532f5adcb4602efc4433c4a52a4b3d69e7440ff1f6413b1b041b419bc90efd6d697999961a9a6afb7/g' upstream/emscripten/tools/ports/libjpeg.py
sed -i 's/https:\/\/dl.bintray.com\/homebrew\/mirror\/jpeg-9c.tar.gz/https:\/\/storage.googleapis.com\/webassembly\/emscripten-ports\/jpegsrc.v9c.tar.gz/g' upstream/emscripten/tools/ports/libjpeg.py
- name: Install vcpkg and dependencies
run: |
source ~/emsdk/emsdk_env.sh
cd ~
git clone https://github.com/microsoft/vcpkg
./vcpkg/bootstrap-vcpkg.sh
./vcpkg/vcpkg integrate install
./vcpkg/vcpkg install glbinding:wasm32-emscripten
./vcpkg/vcpkg install libpng:wasm32-emscripten
./vcpkg/vcpkg install libogg:wasm32-emscripten
./vcpkg/vcpkg install libvorbis:wasm32-emscripten
./vcpkg/vcpkg install glm:wasm32-emscripten
./vcpkg/vcpkg install zlib:wasm32-emscripten
- name: Step To run on failure
if: ${{ failure() }}
run: |
cat /home/runner/vcpkg/buildtrees/libogg/config-wasm32-emscripten-dbg-CMakeCache.txt.log
cat /home/runner/vcpkg/buildtrees/libogg/config-wasm32-emscripten-rel-CMakeCache.txt.log
cat /home/runner/vcpkg/buildtrees/libogg/config-wasm32-emscripten-out.log
- name: Patch SDL_ttf
working-directory: external/SDL_ttf
run: git apply ../../mk/emscripten/SDL_ttf.patch
./emsdk install latest
./emsdk activate latest
- name: Configure build
env:
Expand All @@ -86,10 +56,8 @@ jobs:
source ~/emsdk/emsdk_env.sh
mkdir build
cd build
emcmake cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DENABLE_OPENGLES2=ON \
-DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake\
-DVCPKG_TARGET_TRIPLET=wasm32-emscripten -DGLBINDING_ENABLED=ON\
-DEMSCRIPTEN=1 -DWARNINGS=ON -DWERROR=ON ..
# TODO: Re-add -DWERROR=ON when warnings will be fixed
emcmake cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DWARNINGS=ON ..
- name: Sync data folder
working-directory: build
Expand All @@ -111,7 +79,7 @@ jobs:
env:
BUILD_TYPE: ${{ matrix.build_type }}
run: |
rm supertux2.html && cp template.html supertux2.html
cp template.html supertux2.html
mkdir upload/
mv supertux2* upload/
Expand All @@ -129,4 +97,5 @@ jobs:
cd build/upload/
mv supertux2.html index.html
zip supertux2.zip *
curl -F "archive=@$(pwd)/supertux2.zip" -F "message=$(git log --format=%B -n 1 | head -1)" $UPLOAD_URL
# TODO: Decomment (or replace URL with a different host)
# curl -F "archive=@$(pwd)/supertux2.zip" -F "message=$(git log --format=%B -n 1 | head -1)" $UPLOAD_URL
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@
[submodule "tools/miniswig"]
path = tools/miniswig
url = https://github.com/WindstilleTeam/miniswig
[submodule "external/glm"]
path = external/glm
url = https://github.com/g-truc/glm.git
22 changes: 13 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,16 @@ if(EMSCRIPTEN)
set(CMAKE_EXECUTABLE_SUFFIX .html)
set(IS_EMSCRIPTEN_BUILD ON)

set(USE_FLAGS " -sUSE_SDL=2 -sFULL_ES2=1 -sUSE_SDL_IMAGE=2 -sUSE_FREETYPE=2 -sUSE_PTHREADS=1 -sDISABLE_EXCEPTION_CATCHING=0 --preload-file ${BUILD_CONFIG_DATA_DIR} -sTOTAL_MEMORY=67108864 -sALLOW_MEMORY_GROWTH=1 -sSDL2_IMAGE_FORMATS='[\"png\",\"jpg\"]' --use-preload-plugins")
set(EM_USE_FLAGS "-sDISABLE_EXCEPTION_CATCHING=0")
set(EM_LINK_FLAGS " -sTOTAL_MEMORY=67108864 -sALLOW_MEMORY_GROWTH=1 -sERROR_ON_UNDEFINED_SYMBOLS=0 --preload-file ${BUILD_CONFIG_DATA_DIR} --use-preload-plugins -lidbfs.js")
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(USE_FLAGS "${USE_FLAGS} -fsanitize=undefined -sSAFE_HEAP=1 -sASSERTIONS=1 -sDEMANGLE_SUPPORT=1")
set(EM_USE_FLAGS "${EM_USE_FLAGS} -fsanitize=undefined")
set(EM_LINK_FLAGS "${EM_LINK_FLAGS} -fsanitize=undefined -sSAFE_HEAP=1 -sASSERTIONS=1 -sDEMANGLE_SUPPORT=1")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${USE_FLAGS} -sERROR_ON_UNDEFINED_SYMBOLS=0")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${USE_FLAGS} -sERROR_ON_UNDEFINED_SYMBOLS=0")
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} ${USE_FLAGS} -sERROR_ON_UNDEFINED_SYMBOLS=0 -lidbfs.js")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} ${USE_FLAGS} -sERROR_ON_UNDEFINED_SYMBOLS=0 -lidbfs.js")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EM_USE_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EM_USE_FLAGS}")
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} ${EM_USE_FLAGS} ${EM_LINK_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} ${EM_USE_FLAGS} ${EM_LINK_FLAGS}")
endif()

# TODO: Add " OR ANDROID OR IOS" to this
Expand Down Expand Up @@ -234,7 +236,7 @@ target_link_libraries(supertux2 supertux2_lib)
set_target_properties(supertux2_lib PROPERTIES OUTPUT_NAME supertux2_lib)
set_target_properties(supertux2_lib PROPERTIES COMPILE_FLAGS "${SUPERTUX2_EXTRA_WARNING_FLAGS}")
if(EMSCRIPTEN)
target_link_options(supertux2 PUBLIC -sEXPORTED_FUNCTIONS=['_main','_set_resolution','_save_config','_onDownloadProgress','_onDownloadFinished','_onDownloadError','_onDownloadAborted','_getExceptionMessage'] PUBLIC -sEXPORTED_RUNTIME_METHODS=['ccall','cwrap'] PUBLIC -sEXTRA_EXPORTED_RUNTIME_METHODS=['ccall','cwrap'])
target_link_options(supertux2 PUBLIC -sEXPORTED_FUNCTIONS=['_main','_set_resolution','_save_config','_onDownloadProgress','_onDownloadFinished','_onDownloadError','_onDownloadAborted','_getExceptionMessage'] PUBLIC -sEXPORTED_RUNTIME_METHODS=['ccall','cwrap'])
endif()

if(WIN32 AND NOT VCPKG_BUILD)
Expand All @@ -261,18 +263,20 @@ if(NOT EMSCRIPTEN)
target_link_libraries(supertux2_lib PUBLIC LibSDL2 LibSDL2_image)
endif()

target_link_libraries(supertux2_lib PUBLIC LibSDL2_ttf)
target_link_libraries(supertux2_lib PUBLIC LibSquirrel)
target_link_libraries(supertux2_lib PUBLIC LibSqstdlib)
target_link_libraries(supertux2_lib PUBLIC LibTinygettext)
target_link_libraries(supertux2_lib PUBLIC LibSexp)
target_link_libraries(supertux2_lib PUBLIC LibSavePNG)
target_link_libraries(supertux2_lib PUBLIC LibPartioZip)
target_link_libraries(supertux2_lib PUBLIC LibOpenAL)
target_link_libraries(supertux2_lib PUBLIC LibOggVorbis)
target_link_libraries(supertux2_lib PUBLIC LibGlm)
target_link_libraries(supertux2_lib PUBLIC LibFmt)
target_link_libraries(supertux2_lib PUBLIC LibPhysfs)
if(NOT EMSCRIPTEN)
target_link_libraries(supertux2_lib PUBLIC LibSDL2_ttf)
target_link_libraries(supertux2_lib PUBLIC LibOggVorbis)
endif()

if(HAVE_OPENGL)
target_link_libraries(supertux2_lib PUBLIC LibOpenGL)
Expand Down
44 changes: 15 additions & 29 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -463,57 +463,43 @@ toolchain; newer versions are known not to work properly.
git submodule update --init --recursive
```

1. Patch SDL_ttf by applying the patch in `mk/emscripten/SDL_ttf.patch`:
1. Install [Emscripten](emscripten.org):
```
# For git users:
git apply mk/emscripten/SDL_ttf.patch
# If you do not have git installed:
patch -p1 < mk/emscripten/SDL_ttf.patch
```

2. Install dependencies using Vcpkg (Make sure you enabled Emscripten and ran
`source .../emsdk_env.sh`!):
```
vcpkg integrate install
vcpkg install --target wasm32-emscripten glbinding libpng libogg libvorbis glm zlib
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
```

3. Run CMake using Emscripten's wrapper:
2. Run CMake using Emscripten's wrapper:
```
emcmake cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_OPENGLES2=ON -DCMAKE_TOOLCHAIN_FILE=/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=wasm32-emscripten -DGLBINDING_ENABLED=ON -DEMSCRIPTEN=1 ..
# Make sure you ran `source /path/to/emsdk/emsdk_env.sh` if you opened a new terminal since last step!
emcmake cmake -DCMAKE_BUILD_TYPE=Release ..
```
Replace `/path/to/vcpkg` with the absolute path to where Vcpkg is installed.
Note that Debug builds are generally unplayably slow. Also, the
`-DENABLE_OPENGLES2=ON` flag is optional and will enable using WebGL instead of
the SDL renderer. Currently, the WebGL renderer is much slower than the SDL
renderer.

4. Copy data files to the build folder, as Emscripten will package them to make
3. Copy data files to the build folder, as Emscripten will package them to make
them usable from WASM:
```
rsync -aP ../data/ data/
```

5. Build SuperTux:
4. Build SuperTux:
```
emmake make -j$(nproc || sysctl -n hw.ncpu || echo 2)
```

6. Replace the Emscripten HTML template with SuperTux's custom container:
5. Replace the Emscripten HTML template with SuperTux's custom container:
```
rm supertux2.html && cp template.html supertux2.html
cp template.html supertux2.html
```
You may skip the step above you intend to directly open the `template.html` file;
note that SuperTux won't work if it is not located in the custom template, as it
requires some custom JavaScript functions to work properly.

7. Run the Emscripten webserver:
6. Run the Emscripten webserver:
```
# Without --no-browser, Emscripten does not wait for data to finish downloading,
# which fails the process. It only works by launching Emscripten in no-browser
# mode, and then by opening the browser manually.
emrun --no_browser .
emrun supertux2.html
```

You can now play SuperTux by opening `http://localhost:6931/supertux2.html` in
Expand Down
1 change: 1 addition & 0 deletions external/glm
Submodule glm added at 5c46b9
7 changes: 4 additions & 3 deletions mk/cmake/ConfigureChecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ check_cxx_source_compiles(
HAVE_ICONV_CONST
)

CHECK_TYPE_SIZE("void*" SIZEOF_VOID_P)
message(STATUS "Size of void* is ${SIZEOF_VOID_P}")

if(NOT EMSCRIPTEN)
CHECK_TYPE_SIZE("void*" SIZEOF_VOID_P)
message(STATUS "Size of void* is ${SIZEOF_VOID_P}")
endif()
4 changes: 4 additions & 0 deletions mk/cmake/SuperTux/ProvideDiscord.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
# Some privay-concerned users or free software package managers might need an option to compile ST without the Discord integration.
option(ENABLE_DISCORD "Compile the Discord integration" OFF)

if(EMSCRIPTEN)
set(ENABLE_DISCORD OFF CACHE BOOL "Emscripten does not support Discord integration" FORCE)
endif()

if(NOT ENABLE_DISCORD)
message(STATUS "## WARNING : Discord integration will NOT be compiled. To enable Discord, pass -DENABLE_DISCORD=On")
else()
Expand Down
41 changes: 39 additions & 2 deletions mk/cmake/SuperTux/ProvideGlm.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,43 @@
find_package(glm QUIET)
if(EMSCRIPTEN)
option(USE_SYSTEM_GLM "Use the system-provided GLM instead of the external module" OFF)
else()
option(USE_SYSTEM_GLM "Use the system-provided GLM instead of the external module" ON)
endif()

if(USE_SYSTEM_GLM)
find_package(glm QUIET)
endif()

if(NOT USE_SYSTEM_GLM)
if (NOT EXISTS "${CMAKE_SOURCE_DIR}/external/glm/CMakeLists.txt")
message(FATAL_ERROR "")
endif()

set(GLM_PREFIX ${CMAKE_BINARY_DIR}/glm/ex)
ExternalProject_Add(glm_project
SOURCE_DIR "${CMAKE_SOURCE_DIR}/external/glm/"
BUILD_BYPRODUCTS
"${GLM_PREFIX}/include"
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=${BUILD_TYPE}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_INSTALL_PREFIX=${GLM_PREFIX}
-DBUILD_TESTING=OFF
-DINSTALL_INC_DIR=include)

add_library(LibGlm INTERFACE IMPORTED)

file(MAKE_DIRECTORY ${GLM_PREFIX}/include)

set_target_properties(LibGlm PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${GLM_PREFIX}/include"
INTERFACE_COMPILE_DEFINITIONS "GLM_ENABLE_EXPERIMENTAL")

if(glm_FOUND)
add_dependencies(LibGlm glm_project)
elseif(glm_FOUND)
if(TARGET glm::glm)
message(STATUS "Found glm")

Expand Down
33 changes: 20 additions & 13 deletions mk/cmake/SuperTux/ProvideOggVorbis.cmake
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
find_package(OggVorbis REQUIRED)
if(EMSCRIPTEN)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -sUSE_VORBIS=1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -sUSE_VORBIS=1")
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -sUSE_VORBIS=1")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -sUSE_VORBIS=1")
else()
find_package(OggVorbis REQUIRED)

add_library(LibOggVorbis INTERFACE IMPORTED)
set_target_properties(LibOggVorbis PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${VORBIS_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "${OGGVORBIS_LIBRARIES}"
)
add_library(LibOggVorbis INTERFACE IMPORTED)
set_target_properties(LibOggVorbis PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${VORBIS_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "${OGGVORBIS_LIBRARIES}"
)

mark_as_advanced(
OGG_LIBRARY
VORBISENC_LIBRARY
VORBISFILE_LIBRARY
VORBIS_INCLUDE_DIR
VORBIS_LIBRARY
)
mark_as_advanced(
OGG_LIBRARY
VORBISENC_LIBRARY
VORBISFILE_LIBRARY
VORBIS_INCLUDE_DIR
VORBIS_LIBRARY
)
endif()

# EOF #
11 changes: 9 additions & 2 deletions mk/cmake/SuperTux/ProvideOpenGL.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
option(ENABLE_OPENGL "Enable OpenGL support" ON)
option(ENABLE_OPENGLES2 "Enable OpenGLES2 support" OFF)
if(EMSCRIPTEN)
option(ENABLE_OPENGLES2 "Enable OpenGLES2 support" ON)
else()
option(ENABLE_OPENGLES2 "Enable OpenGLES2 support" OFF)
endif()
option(GLBINDING_ENABLED "Use glbinding instead of GLEW" OFF)
option(GLBINDING_DEBUG_OUTPUT "Enable glbinding debug output for each called OpenGL function" OFF)

Expand All @@ -10,7 +14,10 @@ if(ENABLE_OPENGL)
set(HAVE_OPENGL TRUE)
list(APPEND OPENGL_COMPILE_DEFINITIONS "USE_OPENGLES2")

if(NOT EMSCRIPTEN)
if(EMSCRIPTEN)
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -sFULL_ES2=1")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${USE_FLAGS} -sFULL_ES2=1")
else()
pkg_check_modules(GLESV2 REQUIRED glesv2)
list(APPEND OPENGL_INCLUDE_DIRECTORIES "${GLESV2_INCLUDE_DIRS}")
list(APPEND OPENGL_LINK_LIBRARIES "${GLESV2_LIBRARIES}")
Expand Down
7 changes: 6 additions & 1 deletion mk/cmake/SuperTux/ProvidePartioZip.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
find_package(ZLIB REQUIRED)
if(EMSCRIPTEN)
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -sUSE_ZLIB=1")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -sUSE_ZLIB=1")
else()
find_package(ZLIB REQUIRED)
endif()

add_library(LibPartioZip ${CMAKE_CURRENT_SOURCE_DIR}/external/partio_zip/zip_manager.cpp)
target_link_libraries(LibPartioZip PUBLIC ${ZLIB_LIBRARIES})
Expand Down
5 changes: 4 additions & 1 deletion mk/cmake/SuperTux/ProvideSDL2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ if(WIN32)
find_library(SDL2MAIN_LIBRARIES NAMES SDL2main PATHS "${DEPENDENCY_FOLDER}/lib")
endif()
else()
if(NOT EMSCRIPTEN)
if(EMSCRIPTEN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -sUSE_SDL=2 -sUSE_SDL_IMAGE=2 -sSDL2_IMAGE_FORMATS='[\"png\",\"jpg\"]'")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -sUSE_SDL=2 -sUSE_SDL_IMAGE=2 -sSDL2_IMAGE_FORMATS='[\"png\",\"jpg\"]'")
else()
if(VCPKG_BUILD)
find_package(SDL2 CONFIG REQUIRED)
find_package(sdl2-image CONFIG REQUIRED)
Expand Down
17 changes: 14 additions & 3 deletions mk/cmake/SuperTux/ProvideSDL2_ttf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,26 @@ if(USE_SYSTEM_SDL2_TTF)
find_package(SDL2_ttf QUIET)
endif()

if(TARGET SDL2_ttf)
if (EMSCRIPTEN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -sUSE_SDL_TTF=2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -sUSE_SDL_TTF=2")
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -sUSE_SDL_TTF=2")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -sUSE_SDL_TTF=2")
elseif(TARGET SDL2_ttf)
message(STATUS "Found preinstalled SDL2_ttf")

add_library(LibSDL2_ttf ALIAS SDL2_ttf)
else()
message(STATUS "Could NOT find SDL2_ttf, using external/SDL_ttf fallback")

## external/SDL_ttf with patches
if(NOT EMSCRIPTEN)
# Won't be used in practice - preserved for knowledge
if(EMSCRIPTEN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -sUSE_FREETYPE=1")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -sUSE_FREETYPE=1")
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -sUSE_FREETYPE=1")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -sUSE_FREETYPE=1")
else()
## external/SDL_ttf with patches
if(VCPKG_BUILD)
find_package(freetype CONFIG REQUIRED)
else()
Expand Down
Loading

0 comments on commit 0dc4025

Please sign in to comment.