KhronosGroup / KTX-Software

KTX (Khronos Texture) Library and Tools
Other
877 stars 229 forks source link

Use BUILD_SHARED_LIBS instead of KTX_FEATURE_STATIC_LIBRARY #935

Closed UX3D-haertl closed 1 week ago

UX3D-haertl commented 2 months ago

Is there a specific reason why the inbuilt CMake variable BUILD_SHARED_LIBS is not used to control if KTX is build dynamic or static?

Using a custom variable makes it harder to integrate with other projects

MarkCallow commented 1 month ago

Is there a specific reason why the inbuilt CMake variable BUILD_SHARED_LIBS is not used to control if KTX is build dynamic or static?

I do not know. I did not write the initial CMake build setup and, as back then I did not know of the existence of CMAKE_BUILD_SHARED_LIBS, the question never came up. The one concern I have with changing to use it is that some other CMake-using projects are included in KTX-Software, e.g, astc-encoder and fmt, for which we want static libraries even when building libktx as a shared library. (Note fmt is only used by the tools but we prefer a static library to minimize the shared libraries we have to wrangle for installation.) Therefore we have to ensure the top-level choice of value is not propagated to those projects. Also some platforms require static libraries. CMAKE_BUILD_SHARED_LIBS must not be allowed to override those.

I would be happy to accept a PR to fix this that is cognizant of the above.

MarkCallow commented 1 week ago

Ping @UX3D-haertl will you provide a PR for this? A release is in the offing so if you have interest now is the time to do it.