Skip to content

Make CMakeLists easily usable as a subproject and fix build issues#433

Closed
MarkCallow wants to merge 25 commits intoBinomialLLC:masterfrom
KhronosGroup:set_fp_options
Closed

Make CMakeLists easily usable as a subproject and fix build issues#433
MarkCallow wants to merge 25 commits intoBinomialLLC:masterfrom
KhronosGroup:set_fp_options

Conversation

@MarkCallow
Copy link

@MarkCallow MarkCallow commented Feb 5, 2026

A repeat of #411 but based on the BU 2.0.

Here are details of the changes.

  • Make it usable as a subproject:

    • Don't use CMAKE_ global variables for compiler options.
    • Expose libbasisu_encoder's dependencies and link options in its target
      interface so they are automatically exported to any application that
      links with it.
  • Enhancements

    • Support disabling of the basisu build. It is built by default.
    • Support building on Android and MinGW by handling potential absence
      of libpthread.
    • Support building with CLangCL.
    • Support building on Windows with non-MSVC-front-end compiler which
      means CMake's MSVC variable is not set.
    • Set CMAKE_OSX_DEPLOYMENT_TARGET so program built with latest
      Xcode SDK will run on build machine with pre-SDK version of macOS.
  • Bug Fixes

    • Make work with any multi-config CMake generator, not just Visual Studio.
    • Only set c++ compile options when compiling c++ files.
    • Set the default value of BASISU_STATIC, to TRUE because the library is
      always built as a static library.
    • The libraries added when STATIC is TRUE are only needed for MinGW
      and are now only added for MinGW.
    • The rpath setting done when STATIC is FALSE is pointless with a
      static library but was happening due to the incorrect default of
      BASISU_STATIC.
    • .gitignore files have been added to ignore build files and binaries in
      build and bin, but to not ignore the handful of files in there that
      are tracked by git.
  • Bugs found but not fixed

    • BASISU_SSE is set if (MSVC) so it is incorrectly set on Windows ARM
      and not set in many other cases where it probably should be. MSVC does
      not mean the SSE is available.
    • Building a dynamic library never happens so BASISU_STATIC is
      pointless.
    • There is no way to build with OpenCL for Windows arm64.

This incorporates the WASM and Python stuff largely unchanged. I have not tested it as I do not have the build environment set up.

It includes the FP option setting stuff from my earlier PR. Since your 2.0 release announcement said it produces deterministic results I'm not sure it is still needed. As it is in a single block, it can easily be removed. Let me know.

Convert license info from deprecated .reuse/dep5 to REUSE.toml.

Ignore CMakeUserPresets.json, build files in build and
output binaries in bin.
* Make it usable as a subproject:
   - Don't use CMAKE_ global variables for compiler options.
   - Prefix config options with BASISU_ to avoid polluting the namespace.
   - Expose libbasisu_encoder's dependencies and link options in its target
     interface so they are automatically exported to _any_ application that
     links with it.

* Enhancements
   - Support building on Android and minGW by handling potential absence
     of libpthread.
   - Support building with CLangCL.
   - Support building on Windows with non-MSVC-front-end compiler so
     CMake MSVC variable is not set.
   - Set CMAKE_OSX_DEPLOYMENT_TARGET so program built with latest
     Xcode SDK will run on build machine with pre-SDK version of macOS.

* Bug Fixes
   - Make work with any multi-config CMake generator, not just Visual Studio.
   - Only set c++ compile options when compiling c++ files.
   - The `STATIC` option, renamed `BASISU_STATIC`, is now set to TRUE by
     default because the library is always built as a static library. `STATIC`
     is a keyword for the `add_library` command so the `STATIC` option was
     ignored there. (The BASISU_ prefix now makes it clear they are
     different.) Hence the previous default option of FALSE was incorrect.
   - The libraries added when `STATIC` is TRUE are only needed for MinGW
     and are now only added for MinGW.
   - The rpath setting done when `STATIC` is FALSE is pointless with a
     static library but was happening due to the incorrect value of `STATIC`.
   - .gitignore files have been added to ignore build files and binaries in
     `build` and `bin`, but to not ignore the handful of files in there that
     are tracked by git.

* Bugs found but not fixed
   - BASISU_SSE is set `if (MSVC)` so it is incorrectly set on Windows ARM
     and not set in many other cases where it probably should be.
   - Building a dynamic library never happens so `BASISU_STATIC` is
     pointless.
Only set -g for debug config. Don't set -fPIC in base options.
Quote string arguments to STREQUAL.
* Change PRIVATE to PUBLIC for SSE and OPENCL definitions to propagate
  them to dependent apps. Fixes failure running `basisu -opencl` when
  BASISU_OPENCL is set during config.
* Change INTERFACE to PRIVATE for OpenCL include directory.
  basisu_encoder needs this. Apps don't. Fixes build failure on Windows.
* Change INTERFACE to PRIVATE for OpenCL link library. Needed if
  basisu_encoder ever becomes a shared library. When it's a static
  library, CMake will cause the OpenCL library to be linked to dependent
  apps.
* Set BASISU_SUPPORT_OPENCL=0 when OpenCL not configured.
* Make finding OpenCL required for non-Windows when OpenCL configured.
  Removes need for later checks, allowing code simplification.
* Use embedded OpenCL stuff if WIN32 not if MSVC to support use with
  non-MSVC-front-end compilers.
for latest fixes from master via reuse_ignore.
Remove when issue is fixes in master.
to match usage in the library and usage of BASISU_SUPPORT_SSE.
Important now that CMakeLists.txt sets it to 0 when not supported.
Convert license info from deprecated .reuse/dep5 to REUSE.toml.

Ignore CMakeUserPresets.json, build files in build and
output binaries in bin.
Convert license info from deprecated .reuse/dep5 to REUSE.toml.

Ignore CMakeUserPresets.json, build files in build and
output binaries in bin.
Includes upstream fixes as of 2025.12.28.
@richgel999 richgel999 closed this Feb 5, 2026
@richgel999 richgel999 reopened this Feb 5, 2026
@richgel999 richgel999 closed this Feb 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants