-
Notifications
You must be signed in to change notification settings - Fork 311
Make CMake project usable as a sub-project. Needed by KTX-Software. #411
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
base: master
Are you sure you want to change the base?
Conversation
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.
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. |
dg0yt
left a comment
There was a problem hiding this 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>) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
@dg0yt thanks for your review. I'll respond on Wednesday. It is late here now and I'll be busy tomorrow. |
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. |
|
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. |
@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.
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.
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. |
Also, I think the item that most makes review difficult is the change from using |
|
@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. |
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.
cf1588d to
059a04b
Compare
|
@dg0yt we had a change in plans that gave me a small window to take care of your comments today. |
* 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.
5a1d07b to
8bc19b1
Compare
for the latest fixes.
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.
Includes upstream fixes made 2025.11.22.
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:
interface so they are automatically exported to any application that
links with it.
Enhancements
basisuandexamplesbuilds. Both are built bydefault. You added conditional building of
examplesto master. This PRhad that feature before latest master was merged.
of libpthread.
means CMake's MSVC variable is not set.
Xcode SDK will run on build machine with pre-SDK version of macOS.
Bug Fixes
STATICoption, renamedBASISU_STATIC, is now set to TRUE bydefault because the library is always built as a static library.
STATICis a keyword for the
add_librarycommand so theSTATICoption wasignored there. (The BASISU_ prefix now makes it clear they are
different.) Hence the previous default option of FALSE was incorrect.
STATICis TRUE are only needed for MinGWand are now only added for MinGW.
STATICis FALSE is pointless with astatic library but was happening due to the incorrect value of
STATIC.buildandbin, but to not ignore the handful of files in there thatare tracked by git.
Bugs found but not fixed
if (MSVC)so it is incorrectly set on Windows ARMand not set in many other cases where it probably should be.
BASISU_STATICispointless.