Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

external spdlog package not found #53

Open
artemyv opened this issue Nov 18, 2019 · 4 comments
Open

external spdlog package not found #53

artemyv opened this issue Nov 18, 2019 · 4 comments

Comments

@artemyv
Copy link

artemyv commented Nov 18, 2019

I have build spdlog library separately and copied the exported cmake package of it.
I tried to build spdlog_setup librabies unittests using the -DCMAKE_PREFIX_PATH= command line switch.
cmake has found the package correctly and initialized the spdlog_DIR:PATH= to the correct value

But the "AdditionalIncludeDirectories" entry inside the vcxproj does not includes path to spdlog include folder.

As a result the build of unittest project fails since the spdlog inlude is not found

Full command line
cmake.exe -H. -B_builds "-GVisual Studio 15 2017" -DCMAKE_INSTALL_PREFIX=package -DCMAKE_BUILD_TYPE=Release -DSPDLOG_SETUP_INCLUDE_UNIT_TESTS=ON -DCMAKE_PREFIX_PATH=d:\spdlog\release.32

cmake.exe --build _builds --config Release

Compilation error
include\spdlog_setup\details\conf_impl.h(20): fatal error C10
83: Cannot open include file: 'spdlog/spdlog.h': No such file or directory [testing_ut
2\spdlog_setup_builds\spdlog_setup_unit_test.vcxproj]

Is the building of spdlog_setup using external spdlog library supported?

@guangie88
Copy link
Owner

Actually it is supposed to support it, as seen here in the CMakeLists.txt:
https://github.com/guangie88/spdlog_setup/blob/master/CMakeLists.txt#L54

Assuming that CMAKE_PREFIX_PATH was set correctly to allow spdlog_setup to find the CMake package spdlog, I suspect it might be the case that it can find the spdlog package, but does not automatically add the include dir paths to where the actual spdlog header files are located.

This is usually not a problem for Linux (or maybe just missed out) since the spdlog header files are typically copied into /usr/local/include/ which is a default include search path, whereas Windows does not really have any default include search path to copy such header files to.

I will try to investigate a bit more, and for now I think this is likely a bug.

@artemyv
Copy link
Author

artemyv commented Dec 2, 2019

I looked at the spdlogConfigTargets.cmake generated by spdlog module it creates 2 targets
spdlog::spdlog spdlog::spdlog_header_only
while spdlog_setup is using

target_link_libraries(spdlog_setup
INTERFACE spdlog)

When I changed it to
target_link_libraries(spdlog_setup
INTERFACE spdlog
INTERFACE spdlog::spdlog_header_only)
The correct include directories were added to the AdditionalIncludeDirectories entries of the project

@guangie88
Copy link
Owner

I guess you are using trying to use v1.4.z for spdlog, since v1.3.z does not contain spdlogConfigTargets.cmake?

Currently v1.4.z is not supported, as I have noticed there seemed to be two breaking changes from the perspective of spdlog_setup, one at the cmake build where now it defaults to using a static library instead of pure header files, and also syslog_sink_st / syslog_sink_mt seems to require an additional argument.

This would require a new release tag (i.e. breaking change) to support v1.4.z and won't be backward compatible to <= v1.3.z sadly.

@artemyv
Copy link
Author

artemyv commented Dec 3, 2019

Yes you are right - Not long time ago I have updated the spdlog in my environment to 1.4.2
Since I do not use syslog sinks - It did not require any changes in spdlog_setup
But I wanted to enable the UT of both projects in my environment to be sure nothing is broken or will be broken by the future upgrades of the libraries.

BTW I continue to use the headers-only variant of the spdlog library to avoid possibility that shared library flavor will break something already working.

My final working change is using
target_link_libraries(spdlog_setup
INTERFACE spdlog::spdlog_header_only)
I have not tested it in case when spdlog is compiled as subfolder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants