Thalhammer / jwt-cpp

A header only library for creating and validating json web tokens in c++
https://thalhammer.github.io/jwt-cpp/
MIT License
864 stars 235 forks source link

Could NOT find jsoncons (missing: jsoncons_DIR) #226

Closed enriavil1 closed 2 years ago

enriavil1 commented 2 years ago

What happened?

Added jwt-cpp to my project and then tried to use cmake, but I get the following "Could NOT find jsoncons (missing: jsoncons_DIR)" in the beginning (doesn't throw an error) Later on it fails because of this error "fatal error: 'jsoncons/json.hpp' file not found

include "jsoncons/json.hpp" Am I doing something wrong?

How To Reproduce?

No response

Version

0.6.0

What OS are you seeing the problem on?

MacOS

What compiler are you seeing the problem on?

GCC, Clang

Relevant log output

Could NOT find jsoncons (missing: jsoncons_DIR)
fatal error: 'jsoncons/json.hpp' file not found
#include "jsoncons/json.hpp"

Code of Conduct

prince-chrismc commented 2 years ago

Can you please share the command you are running to configure CMake?

Which JSON library are you intending to use?

enriavil1 commented 2 years ago

I am intending to use nlohmann for my json library. I am just using cmake --build . I am trying to add jwt-cpp with the default options

prince-chrismc commented 2 years ago

Hmm 🤔 which file is complaining about the missing header?

If the library is not found, it should not be build https://github.com/Thalhammer/jwt-cpp/blob/master/example/traits/CMakeLists.txt#L8-L9

On mobile but I don't see a test for default options 🙈

enriavil1 commented 2 years ago

I meant I added this as a submodule and I am building the whole thing with all jwt-cpp default settings at the top cmake file. (by the way I am new to using cmake, so I might be doing something wrong) I added the jwt-cpp as a submodule and added it into my top cmake file like so. add_subdirectory(jwt-cpp) target_include_directories(silkrpc PUBLIC ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/jwt-cpp/include) target_link_libraries(silkrpc jwt-cpp absl::flat_hash_map absl::flat_hash_set absl::btree intx::intx gRPC::grpc++ protobuf::libprotobuf silkinterfaces silkworm_core silkworm_node mimalloc)

and running it using Apple clang version 13.0.0 (clang-1300.0.29.30)

enriavil1 commented 2 years ago

You can check it out here: https://github.com/torquem-ch/silkrpc/pull/275 if it helps.

enriavil1 commented 2 years ago

Sorry I forgot to mention that this is the line giving me the error https://github.com/Thalhammer/jwt-cpp/blob/5c588fccd67545b5bbe1d7653963034d0151742a/include/jwt-cpp/traits/danielaparker-jsoncons/traits.h#L6

prince-chrismc commented 2 years ago

Hmm I don't see the exact error you described in the pull request but it gives me a better idea of what you are trying to do!

Since we only have default settings, only the examples might be bringing the bad include...

For a test, you can try setting https://github.com/Thalhammer/jwt-cpp/blob/5c588fccd67545b5bbe1d7653963034d0151742a/CMakeLists.txt#L14 To OFF right before add submodule

Should look like (on mobile incase I make a typo)

set(JWT_BUILD_EXAMPLES OFF CACHE BOOL "disable examples" FORCE)

https://stackoverflow.com/q/39588836

Also I see this project have hunter support which this project supports so we can go that road if we get stuck.

enriavil1 commented 2 years ago

The thing is that it doesn't get to that point. It fails building the folder jwt-cpp/include also the problem with hunter is that it says this "Could NOT find jsoncons (missing: jsoncons_DIR)"

enriavil1 commented 2 years ago

I just tried it turning off examples, but it didn't work

prince-chrismc commented 2 years ago

Your project is really interesting! 🎉

So I cloned your branch and tried to play around but the code did not match what you shared, so I am not really sure what the issue you are facing. It's hard to help without the code to trying things out.

It seems like a project specific issue so I am going to close this, but if you find anything do not hesitate to re-open.

It's a pretty complicated build script so if you need help I love pair programing feel free to reach out.

enriavil1 commented 2 years ago

When you ran cmake --build . it didn't give the same error?

enriavil1 commented 2 years ago

I'll keep looking into it, but I believe the real culprit is Hunter not finding the "jsoncons" package.

prince-chrismc commented 2 years ago

I got the same errors as the pr when I looked, I share your suspicious around hunter. I recall it flips the default Cmake settings to be more sensitive but I don't have a lot of experience with it