Header only build is too complex
igormcoelho opened this issue · 1 comments
Normally, adding Header Only libraries only require including the include
folder.
See FMT library:
FMT_DIR=external/fmt-9.1.0
INCLUDES=-I$(FMT_DIR)/include
DEFINES=-DFMT_HEADER_ONLY
With SCN library, multiple things are necessary, including, to include the src/ directory, which is quite strange... also, manually including thirdparty libraries also makes it even more complex.
SCN_DIR=external/scn-1.1.2
INCLUDES=-I$(SCN_DIR)/include -I$(SCN_DIR)/src -I$(SCN_DIR)/src/deps/fast_float/single_include
DEFINES= -DSCN_HEADER_ONLY
So, my suggestions are:
- if possible, only include "includable" things on
include/
folder, not onsrc/
folder. - if possible, automatically add the dependency when
SCN_HEADER_ONLY
is defined... something like:
// on some important src/ file that depends on fast_float...
#ifdef SCN_HEADER_ONLY
#include "deps/fast_float/single_include/fast_float.h"
#endif
- if possible, create a define HEADER_ONLY that defines SCN_HEADER_ONLY
#ifdef HEADER_ONLY
#define SCN_HEADER_ONLY
#endif
If something like this existed, maybe even on FMT, then projects that depend on header only configurations would be make so much simpler, by simply defining "HEADER_ONLY", and everybody defines their own specific header only definitions.
One solution used by CATCH2 project is to manually build an "amalgamated" header file, that includes headers and sources together... so it could possibly be distributed together with versioned builds of this library, thus removing the need to include src/
and deps.
I mean, the project currently work fine and these are all suggestions, to make it simpler for adoption when CMake or other build systems are not used (maybe in very tiny or demonstration projects). Congratulations for this nice library!
Thank you for your suggestion! However, I don't think I'll be touching the header-only builds: as you said, they work fine-ish now, and they are a workaround anyway for the mess that is dependency management in C++. It's very easy to also accidentally blow up your compile times when using the header only mode.
For that reason, I've removed header-only mode from v2, and will leave it be for v1. But, as I said, thanks anyway!