Header only dependencies
Baklap4 opened this issue · 3 comments
Baklap4 commented
How to write a module for header only dependencies?
We're trying to add nlohmann_json it finds the include dir, but not the library.
nlohmann_json normally is found like this:
# looking for nlohmann json library
find_package(nlohmann_json 3.2.0 REQUIRED)
target_link_libraries(main PRIVATE nlohmann_json::nlohmann_json)
my current cmake module is this:
# - Try to find nlohmann_json
# Once done, this will define
#
# Json_FOUND - system has nlohmann_json
# Json_INCLUDE_DIRS - the nlohmann_json include directories
# Json_LIBRARIES - link these to use nlohmann_json
#
# See documentation on how to write CMake scripts at
# http://www.cmake.org/Wiki/CMake:How_To_Find_Libraries
include(LibFindMacros)
libfind_pkg_detect(Json nlohmann_json FIND_PATH nlohmann/json.hpp FIND_LIBRARY nlohmann_json::nlohmann_json)
set(Json_VERSION ${Json_PKGCONF_VERSION})
libfind_process(Json)
output is:
1> [CMake] CMake Error at cmake/Modules/LibFindMacros.cmake:263 (message):
1> [CMake] REQUIRED PACKAGE NOT FOUND
1> [CMake]
1> [CMake] We only found some files of Json, not all of them. Perhaps your
1> [CMake] installation is incomplete or maybe we just didn't look in the right place?
1> [CMake] This package is REQUIRED and you need to install it or adjust CMake
1> [CMake] configuration in order to continue building Performous.
1> [CMake]
1> [CMake] Relevant CMake configuration variables:
1> [CMake]
1> [CMake] Json_INCLUDE_DIR=C:/Users/myuser/source/repos/project/build/x64-Debug/vcpkg_installed/x64-windows/include
1> [CMake] Json_LIBRARY=<not found>
1> [CMake]
1> [CMake] You may use CMake GUI, cmake -D or ccmake to modify the values. Delete
1> [CMake] CMakeCache.txt to discard all values and force full re-detection if
1> [CMake] necessary.
I'm using v2.3
yoda-jm commented
I think it works, we just need to remove the FIND_LIBRARY xxx target (it is optional)
Tronic commented
FWIW, I prefer Meson Build now and despite writing all the libfind code I am not actively maintaining it nor much aware of how it works anymore. If you need more functionality to these macros, pull requests are welcome.
Baklap4 commented
I think it works, we just need to remove the FIND_LIBRARY xxx target (it is optional)
It seems to work without doing FIND_LIBRARY
:)