Skip to content

Conversation

@MarkCallow
Copy link
Contributor

@MarkCallow MarkCallow commented Nov 17, 2025

These are all the CMake-related fixes from PR #408 based on the latest master, which includes the warning fixes that were in PR #408. This will simplify eventual merging of the CMake-related fixes.

The source branch for this is branched off the source branch for PR #410 so includes those reuse and .gitignore fixes.

This builds on all the platforms and with all the compilers noted in #408.

OpenCL configurations are included in those builds on Linux, macOS and Windows. I have also successfully built the basis_universal project standalone including OpenCL on all 3 platforms. KTX-Software CI does not have tests that try to use OpenCL and I do not have any so I can only confirm that builds that include OpenCL run successfully when the app is not using OpenCL. @richgel999 please provide details of the issues you are seeing with OpenCL and your test programs so I can debug the problems.

There is one additional fix c/f #408: support building on Windows with non-MSVC-front-end compiler which means CMake's MSVC variable is not set.

Here are details of the changes.

  • 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 disabling of the basisu and examples builds. Both are built by
      default. You added conditional building of examples to master. This PR
      had that feature before latest master was merged.
    • 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.
    • 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.
    • There is no way to build with OpenCL for Windows arm64.

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.
@MarkCallow
Copy link
Contributor Author

MarkCallow commented Nov 17, 2025

@Pandapip1

It seems this is missing installation rules:

  > buildPhase completed in 1 minutes 16 seconds
  > Running phase: installPhase
  > install flags: -j8 SHELL=/nix/store/ciarnmsx8lvsrmdbjddpmx0pqjrm8imb-bash-5.3p3/bin/bash install
  > make: *** No rule to make target 'install'.  Stop.

If you could rebase your branch on master, I'll rebase my own branch on top of this and pull out the installation rules I made. Alternatively, just pick and choose whatever you want from Pandapip1@e2f294d. Thank you so much for this work!

Please rebase your branch on top of this PR, #411. I don't want to expand its scope any more. It already has many changes.

Copy link

@dg0yt dg0yt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the CMake changes should be broken into more pieces.

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBASISU_SUPPORT_SSE=0")
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:-Wno-reorder;-Wno-class-memaccess;-Wno-deprecated-copy>")

add_compile_options($<$<NOT:$<BOOL:BASISU_BUILD_X64>>:-m32>)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the responsibilty of the indivdual project, or wouldn't this come from the toolchain?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is what the responsibility of the individual project?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO m32 is part of what a toolchain would inject into an actual configuration.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Above my pay grade. This comes from the original CMakeLists.txt. @richgel999 will have to determine if this is necessary or not.

@MarkCallow
Copy link
Contributor Author

@dg0yt thanks for your review. I'll respond on Wednesday. It is late here now and I'll be busy tomorrow.

@MarkCallow
Copy link
Contributor Author

Maybe the CMake changes should be broken into more pieces.

I need all these changes for my project.

@dg0yt
Copy link

dg0yt commented Nov 17, 2025

Maybe the CMake changes should be broken into more pieces.

I need all these changes for my project.

I understand that it works for you, but it should work well for everyone. ATM it is hard to review.

@sehurlburt
Copy link
Contributor

Thank you both for contributing to this conversation. To be clear, both vcpkg and KTX are very important for us to be supportive of, and neither Rich nor I are CMake experts (we just know that some of the KTX-requested CMake changes broke builds on OSX and Windows OpenCL on our personal machines, which is why we didn’t accept them, but we aren’t sure why).

Testing is difficult on this repo and we can’t rely purely on CI, so having various experts weigh in with proactive comments is invaluable. @MarkCallow , now that we know these aren’t simple changes, you can break things up into multiple key PRs for easier review by @dg0yt if needed. We will prioritize CMake changes that are considered critical to the health of your codebases, so if anyone is interested in a specific change being accepted, attaching reasons for why changes are needed will help us triage.

@MarkCallow
Copy link
Contributor Author

MarkCallow commented Nov 18, 2025

(we just know that some of the KTX-requested CMake changes broke builds on OSX and Windows OpenCL on our personal machines, which is why we didn’t accept them, but we aren’t sure why)

@sehurlburt Please describe the problems you are seeing and how you are reproducing them. I can't even begin to debug without such info. As I've written before I can successfully build with OpenCL on my personal MacBook under macOS 15.6.1. I was also able to successfully build with OpenCL on an old and v. slow Windows 7 machine - my only x64 machine. The OpenCL libraries in this repo are only for x64.

you can break things up into multiple key PRs for easier review by @dg0yt if needed.

Breaking this up into multiple PRs makes interim use in KTX-Software builds more difficult and very time-consuming for me so I won't be doing it. I know because I already tried that with separating the warning and cmake fixes.

We will prioritize CMake changes that are considered critical to the health of your codebases, so if anyone is interested in a specific change being accepted, attaching reasons for why changes are needed will help us triage.

Please review the detailed explanation of the changes in the PR description and tell me what further information you need in order to understand the reasons for those changes.

@MarkCallow
Copy link
Contributor Author

MarkCallow commented Nov 18, 2025

you can break things up into multiple key PRs for easier review by @dg0yt if needed.

Also, I think the item that most makes review difficult is the change from using CMAKE_ globals to add_compile_{definitions,options}. Those would happen all at once regardless of any other splitting up of the changes.

@sehurlburt
Copy link
Contributor

@MarkCallow - If KTX has an urgent blocking issue, we’ll need to schedule a call to discuss both of our current constraints. Feel free to send me an e-mail to set that up. Otherwise, we’ll do our best to see what we can prioritize and can continue to keep posted over PRs.

@MarkCallow
Copy link
Contributor Author

If KTX has an urgent blocking issue

It does not. We are using the fork and branch which is the source for this PR. The problem I have is that merging changes you make to the existing CMakeLists.txt can be difficult, the corollary of the problem of reviewing this PR. So I hope you will merge this at the time of the January release.

With that in mind, please respond to my previous requests re your issues with OpenCL and what information you still need after your review of the detailed explanation of the changes here.

Only set -g for debug config. Don't set -fPIC in base options.
Quote string arguments to STREQUAL.
@MarkCallow
Copy link
Contributor Author

@dg0yt we had a change in plans that gave me a small window to take care of your comments today.

@MarkCallow MarkCallow mentioned this pull request Nov 18, 2025
* 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.
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.

3 participants