-
Notifications
You must be signed in to change notification settings - Fork 65
Upgrade Basis plugins to 1.15 #112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3bc79d8
d83eb5b
09f13dd
75e47e7
7b9d26a
aec8e3d
564f380
256efbc
c603aa5
e7c5843
b2c3c84
f315885
38abfea
7cc5707
f1c5d05
015f24e
3c4852d
426da44
2bb860f
1bd045b
a4348cc
6f479a7
1b78acf
85ffabb
85e46e7
d29a013
d85bfb1
2d3a38e
42ea61f
57865fe
e65f438
a88304b
9d7a1e1
fc64838
cc933cf
d6c9dc7
2db78c8
b63e2e5
2ce8853
0542a35
cbb05c7
25bdbc3
5cc3bbf
e8b48ce
3cd27aa
7935c91
3626ca2
36af4d8
ed50c26
3ec1fc6
3d9914b
d6eb04b
6f41d58
68bcaa9
0f295d5
a2e9d49
6594d79
b06f6e9
3e03f27
fef35be
d191233
ebfb048
e97ed9c
08f9abd
be76be9
d7c50ca
319a050
4ff0737
a5aca85
4597fb1
1ac0592
4f791ed
439a883
94b1798
d1ef9ab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,7 @@ | |
| # Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, | ||
| # 2020, 2021 Vladimír Vondruš <mosra@centrum.cz> | ||
| # Copyright © 2019 Jonathan Hale <squareys@googlemail.com> | ||
| # Copyright © 2021 Pablo Escobar <mail@rvrs.in> | ||
| # | ||
| # Permission is hereby granted, free of charge, to any person obtaining a | ||
| # copy of this software and associated documentation files (the "Software"), | ||
|
|
@@ -51,13 +52,50 @@ | |
| # DEALINGS IN THE SOFTWARE. | ||
| # | ||
|
|
||
| # Several places in this find module assume that the C language is enabled: | ||
| # - test_big_endian() assumes C is enabled, configuration fails without. | ||
| # CMake says to call enable_language() in the highest directory using the | ||
| # language, so we can't do that here. | ||
| # - both the transcoder and encoder link to .c files that would just not be | ||
| # compiled without the language enabled, or the source file language being | ||
| # changed to CXX | ||
| # Currently both BasisImporter and BasisImageConverter call enable_language(C). | ||
|
|
||
| list(FIND BasisUniversal_FIND_COMPONENTS "Encoder" _index) | ||
| if(${_index} GREATER -1) | ||
| list(APPEND BasisUniversal_FIND_COMPONENTS "Transcoder") | ||
| list(REMOVE_DUPLICATES BasisUniversal_FIND_COMPONENTS) | ||
| endif() | ||
|
|
||
| # Figure out endianness for Basis Universal. test_big_endian() fails on | ||
| # Emscripten, but WebAssembly is always little-endian. On CMake 3.8 and below, | ||
| # test_big_endian() requires C support which breaks compilation in funny ways | ||
| # (see comment below) so we skip that. | ||
| if(NOT CORRADE_TARGET_EMSCRIPTEN AND NOT CMAKE_VERSION VERSION_LESS 3.9) | ||
| include(TestBigEndian) | ||
| test_big_endian(BIG_ENDIAN) | ||
| endif() | ||
|
|
||
| macro(_basis_setup_source_file source) | ||
| # Compile any .c files as C++. Otherwise the files are just ignored because | ||
| # the C language is not enabled by project() or enable_language(). Calling | ||
| # enable_language in a find module is not a good idea, and even if we do | ||
| # this higher up in one of the Basis* plugins, some compilers will require | ||
| # the C99 standard being enabled and/or complain about -std=c++11 (done by | ||
| # CORRADE_CXX_STANDARD) being set on a C compiler. Doing both (enabling C | ||
| # and setting LANGUAGE CXX) still results in static libraries compiling | ||
| # with C and producing above-mentioned errors, possibly to do with | ||
| # LINKER_LANGUAGE. What a horrible mess. | ||
| set_property(SOURCE ${source} PROPERTY LANGUAGE | ||
| CXX) | ||
|
|
||
| # Tell Basis if we're on a big endian system. It currently doesn't figure | ||
| # this out by itself. | ||
| if(BIG_ENDIAN) | ||
| set_property(SOURCE ${source} APPEND PROPERTY COMPILE_DEFINITIONS | ||
| BASISD_IS_BIG_ENDIAN=1) | ||
| endif() | ||
|
|
||
| # Basis shouldn't override the MSVC iterator debug level as it would make | ||
| # it inconsistent with the rest of the code | ||
| if(CORRADE_TARGET_WINDOWS) | ||
|
|
@@ -73,7 +111,7 @@ macro(_basis_setup_source_file source) | |
| " -w") | ||
| # Clang supports -w, but it doesn't have any effect on all the | ||
| # -Wall -Wold-style-cast etc flags specified before. -Wno-everything does. | ||
| # Funnily enough this is not an issue on Emscripten.; | ||
| # Funnily enough this is not an issue on Emscripten. | ||
| elseif(CMAKE_CXX_COMPILER_ID MATCHES "(Apple)?Clang" AND NOT CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") | ||
| set_property(SOURCE ${source} APPEND_STRING PROPERTY COMPILE_FLAGS | ||
| " -Wno-everything") | ||
|
|
@@ -125,20 +163,30 @@ foreach(_component ${BasisUniversal_FIND_COMPONENTS}) | |
| "Set BASIS_UNIVERSAL_DIR to the root of a directory containing basis_universal source.") | ||
| endif() | ||
|
|
||
| # @todo Disable file loading at compile time and get rid of the | ||
| # BMP/JPG/PNG libraries, we don't use those at all. Hopefully | ||
| # this becomes a preprocessor define upstream at some point. | ||
| # Alternatively, look into creating stubs for the library | ||
| # functions used by basis_universal. | ||
| set(BasisUniversalEncoder_SOURCES | ||
| ${BasisUniversalEncoder_DIR}/apg_bmp.c | ||
| ${BasisUniversalEncoder_DIR}/basisu_astc_decomp.cpp | ||
| ${BasisUniversalEncoder_DIR}/basisu_backend.cpp | ||
| ${BasisUniversalEncoder_DIR}/basisu_basis_file.cpp | ||
| ${BasisUniversalEncoder_DIR}/basisu_bc7enc.cpp | ||
| ${BasisUniversalEncoder_DIR}/basisu_comp.cpp | ||
| ${BasisUniversalEncoder_DIR}/basisu_enc.cpp | ||
| ${BasisUniversalEncoder_DIR}/basisu_etc.cpp | ||
| ${BasisUniversalEncoder_DIR}/basisu_frontend.cpp | ||
| ${BasisUniversalEncoder_DIR}/basisu_global_selector_palette_helpers.cpp | ||
| ${BasisUniversalEncoder_DIR}/basisu_gpu_texture.cpp | ||
| ${BasisUniversalEncoder_DIR}/basisu_kernels_sse.cpp | ||
| ${BasisUniversalEncoder_DIR}/basisu_pvrtc1_4.cpp | ||
| ${BasisUniversalEncoder_DIR}/basisu_resampler.cpp | ||
| ${BasisUniversalEncoder_DIR}/basisu_resample_filters.cpp | ||
| ${BasisUniversalEncoder_DIR}/basisu_ssim.cpp | ||
| ${BasisUniversalEncoder_DIR}/basisu_uastc_enc.cpp | ||
| ${BasisUniversalEncoder_DIR}/jpgd.cpp | ||
| ${BasisUniversalEncoder_DIR}/lodepng.cpp) | ||
|
|
||
| foreach(_file ${BasisUniversalEncoder_SOURCES}) | ||
|
|
@@ -173,8 +221,6 @@ foreach(_component ${BasisUniversal_FIND_COMPONENTS}) | |
| # The rest is documented in the BasisImageConverter plugin itself. | ||
| set_property(TARGET BasisUniversal::Encoder APPEND PROPERTY | ||
| INTERFACE_LINK_LIBRARIES BasisUniversal::Transcoder) | ||
| set_property(TARGET BasisUniversal::Encoder APPEND PROPERTY | ||
| INTERFACE_COMPILE_DEFINITIONS "BASISU_NO_ITERATOR_DEBUG_LEVEL") | ||
| endif() | ||
| else() | ||
| set(BasisUniversal_Encoder_FOUND TRUE) | ||
|
|
@@ -227,6 +273,27 @@ foreach(_component ${BasisUniversal_FIND_COMPONENTS}) | |
| set(BasisUniversalTranscoder_SOURCES | ||
| ${BasisUniversalTranscoder_DIR}/basisu_transcoder.cpp) | ||
|
|
||
| set(BasisUniversalTranscoder_DEFINITIONS "BASISU_NO_ITERATOR_DEBUG_LEVEL") | ||
|
|
||
| # Not linking to zstddeclib.c because together with Encoder | ||
| # linking to zstd.c this would lead to duplicate symbol | ||
| # errors. | ||
| # @todo Unused functions *should* be removed by LTO but is | ||
| # there a better way? | ||
| find_path(BasisUniversalZstd_DIR NAMES zstd.c | ||
| HINTS "${BASIS_UNIVERSAL_DIR}/zstd" "${BASIS_UNIVERSAL_DIR}" | ||
| NO_CMAKE_FIND_ROOT_PATH) | ||
| if(BasisUniversalZstd_DIR) | ||
| list(APPEND BasisUniversalTranscoder_SOURCES | ||
| ${BasisUniversalZstd_DIR}/zstd.c) | ||
| else() | ||
| # If zstd wasn't found, disable Zstandard supercompression | ||
| # support at compile time. The zstd.h include is hidden | ||
| # behind this definition as well. | ||
| list(APPEND BasisUniversalTranscoder_DEFINITIONS | ||
| "BASISD_SUPPORT_KTX2_ZSTD=0") | ||
| endif() | ||
|
Comment on lines
+278
to
+295
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sigh... let's hope the unused functions get indeed thrown away by the linker. If the Emscripten binary size inflates a lot, we can reconsider. One option would be to have the Encoder and Transcoder independent, but that only moves the problem one level up, to any binary that links to both of them (i.e., the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we turned BasisUniversal::{Encoder, Decoder} into a static library, would there be a way to make this work? Or is that bad style for a find module?
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AFAIK throwing away duplicates from static libraries generally works only at the object file level -- i.e., if there would be But if Another idea I had was to build & bundle our own But ... leave that for later. Unless @Squareys sees it's really making wasm binaries twice as huge, I don't think it's a priority :) |
||
|
|
||
| foreach(_file ${BasisUniversalTranscoder_SOURCES}) | ||
| _basis_setup_source_file(${_file}) | ||
| endforeach() | ||
|
|
@@ -243,7 +310,7 @@ foreach(_component ${BasisUniversal_FIND_COMPONENTS}) | |
| set_property(TARGET BasisUniversal::Transcoder APPEND PROPERTY | ||
| INTERFACE_INCLUDE_DIRECTORIES ${BasisUniversalTranscoder_INCLUDE_DIR}) | ||
| set_property(TARGET BasisUniversal::Transcoder APPEND PROPERTY | ||
| INTERFACE_COMPILE_DEFINITIONS "BASISU_NO_ITERATOR_DEBUG_LEVEL") | ||
| INTERFACE_COMPILE_DEFINITIONS ${BasisUniversalTranscoder_DEFINITIONS}) | ||
| set_property(TARGET BasisUniversal::Transcoder APPEND PROPERTY | ||
| INTERFACE_SOURCES "${BasisUniversalTranscoder_SOURCES}") | ||
| endif() | ||
|
|
||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.