Closed SpaceIm closed 1 year ago
Hi, thanks for the feedback. This is a good idea.
I'd propose to simplify it a bit by making it something like TMXLITE_EXTERNAL_LIBS
in which case you either use the supplied libraries or choose your own. This would also allow further configuration such as alternative zip libraries like zlib or zstdlib (for which there is already an issue) if users prefer.
I have build a ZLIB switch into my fork, but only for the code, I am not so firm with cmake.. see here for details: https://github.com/ldornbusch/tmxlite/commit/4d61d98f973c5db13c67e547dd75bd33d6d43db0
If you're only using a preprocessor definition then cmake is quite easy to update. First you'd need a cmake variable somewhere near the top of the file:
SET(TMXLITE_EXTERNAL_LIBS FALSE CACHE BOOL "Should tmxlite use external zlib and pugixml libraries?")
which lets the user configure it to true or false. Then:
if(TMXLITE_EXTERNAL_LIBS)
add_definitions(-DUSE_ZIP_LIB -DUSE_PUGIXML_LIB)
endif()
to add the preprocessor defs. You'll also need to tell cmake to find the libraries (probably the most complicated part depending on the library support for cmake)
if(TMX_EXTERNAL_LIBS)
find_package(zlib)
find_package(pugixml)
#optionally do other stuff here if libs not found like pull from github/package manager/build from source
endif()
and then finally tell cmake where the include dirs and libraries to link are
if(TMX_EXTERNAL_LIBS)
include_directories(${ZLIB_INCLUDE} ${PUGIXML_INCLUDE})
target_link_libraries(${ZLIB_LIBRARIES} ${PUGIXML_LIBRARIES})
endif
Although the exact include/lib variables will depend on how cmake finds them. As for meson, I have no idea, I've never used it 😅
ok I will try this out but will take some time
The standard way to do this in meson is actually to delete:
--wrap-mode=forcefallback
.You'd then use dependency()
as the sole way to get either external dependency, and run meson wrap install pugixml && meson wrap install miniz
-- this would install two small INI files describing where to download the sources from on demand.
See https://mesonbuild.com/Wrap-dependency-system-manual.html
Oh, OK. I'm not really familiar with meson, support was kindly provided by @KingDuckZ and I modified it as best I knew how to work with this update. Thanks for the tip!
It would be nice to be able to use externally installed miniz & pugixml, vendoring is bad for package managers (ODR violation).
miniz
&pugixml
files in specific folders (vendor/miniz
&vendor/pugixml
for example)#include <pugixml.hpp>
instead of#include "detail/pugixml.hpp"
(this modification is tedious for package managers)TMXLLITE_EXTERNAL_MINIZ
andTMXLLITE_EXTERNAL_PUGIXML