KTX-Software icon indicating copy to clipboard operation
KTX-Software copied to clipboard

Add more options to control which CMake targets are created

Open AntonShalgachev opened this issue 1 year ago • 5 comments

Hi! I've noticed that CMakeLists.txt includes several targets by default with no option to prevent that. For example, both ktx and ktx_read would be added (leading to compilation of both targets when building the app regardless of which target is linked to it). Also obj_basisu_cbind and objUtil are always added (but looks like they are unused by the core library) Apart from that ktx always includes ASTC encoder and basisu encoder, which might not always be desired

My current setup is that I use libktx as a CMake dependency (via FetchContent). My project consists of 2 parts: a simple offline tool which saves the input image data to the ktx2 format without encoding; and a renderer which only needs to read the ktx2 file without transcoding. My ideal setup would be that I could disable everything I don't need, leaving only a basic library with the read/write functionality

Would that be in line with the project to add additional CMake options to conditionally skip adding some targets? If yes, I can try to come up with a PR

AntonShalgachev avatar Apr 14 '23 18:04 AntonShalgachev

PRs for the following changes are acceptable:

  • Build only ktx_read. Must disable tests. I think this may be the case already.
  • Don't include obj_basisu_cbind unless the tests are being built. I think this may the case currently. It is only used by the transcode tests.
  • Don't include objUtil unless tools or loadtests are being built. If this isn't the case I'd be surprised. The only part of objUtil that is used by the core library is unused.h which doesn't require the library to be built.

It's best to wait a month or so before creating PRs for these as some big changes are coming ...

The following are unacceptable

  • Omitting the transcoder from ktx or ktx_read.
  • Omitting the encoders from ktx.

MarkCallow avatar Apr 15 '23 07:04 MarkCallow

Great, thanks for the confirmation I'll wait then for those big changes you mentioned before looking further into that

AntonShalgachev avatar Apr 15 '23 09:04 AntonShalgachev

Those big changes are in main now.

MarkCallow avatar Jun 14 '23 08:06 MarkCallow

@AntonShalgachev Do you still plan to provide a PR? I think the only thing to be done here is make it possible to build only one of ktx or ktx_read.

MarkCallow avatar Sep 17 '23 07:09 MarkCallow

I'm still interested in having this change, but I won't be able to find time for a PR in the foreseeable future (I've switched to something else at the moment). If anyone else would need this feature earlier and would find some time for a PR, I'll happily let them do it :) Otherwise I can look into it once I'm back on the ktx topic

AntonShalgachev avatar Sep 19 '23 21:09 AntonShalgachev