Basically, libfmt also lacks support for propper generate_export_headers,
instead, some handwritten macros that only work on windows are used :-(
Personally, I think including dependencies in the build is always a bad idea,
but there might be good (Windows??) reasons for it. Anyhow, this is a rather
ugly fix to include the generate_export_headers into libfmt.
Signed-off-by: Matthias Schoepfer <matthias.schoepfer@ithinx.io>
This should only affect the library part, and to be more specific, the shared
library part. Cmake allows to generate a special header file through
GenerateExportHeader()[1]. This defines - amongst other - a SPDLOG_EXPORT
Symbol, that does the right thing, depending on compiler / OS. On Windows,
default is, if I recall correctly, that all symbols are not exported while
Linux does it the other way around. So this patch sets default to *not* export
symbols except those marked SPDLOG_EXPORT. Behaviour with Windows and Linux
should be the same. Also, I removed SPDLOG_BUILD_SHARED in favour of the
standard BUILD_SHARED_LIBS, which is a global symbol. This *might* give some
issues when used as add_subdirectory(), but I am not sure.
Also I made Threads::Threads private, so a depending cmake package does not
need to have find_package(Threads) on.
Why all that? On x86_64, gcc 8.3.0 .so code size reduction is:
811320 bytes original vs. 532536 now (~65% of the original). And, I *guess*,
this will resolve the issue that it is not possible to use shared libs
with windows. But I cannot test it, I only have Linux.
[1] https://cmake.org/cmake/help/latest/module/GenerateExportHeader.html
Signed-off-by: Matthias Schoepfer <matthias.schoepfer@ithinx.io>
The library gets installed into ${CMAKE_INSTALL_LIBDIR}/spdlog, which
is for unix / linux a rather strange place, hence, put it where the linker
is more likely to find it.
Signed-off-by: Matthias Schoepfer <matthias.schoepfer@ithinx.io>
I had to nuke the flags targetting spdlog_header_only because in CMake,
an interface target apparently really only supports the INTERFACE
option.
As I am only targeting Linux, the MSVC changes rely on spdlog's CI and
manual code review. That said, it makes sense to also stop forcing these
options on third party code, assuming that the CMake installations work
the same on Windows.
Fixes#1104