beached / daw_json_link

Fast, convenient JSON serialization and parsing in C++
https://beached.github.io/daw_json_link/
Boost Software License 1.0
478 stars 31 forks source link

Installing #147

Closed t0mpl closed 4 years ago

t0mpl commented 4 years ago

Hi everyone, Sorry i'm quite new with C++ and i can't figure out how to install this library

i've tried add_library(daw STATIC) target_include_directories(daw PUBLIC ${PROJECT_SOURCE_DIR}/external/daw) add_library(third_party STATIC) target_include_directories(third_party PUBLIC ${PROJECT_SOURCE_DIR}/external/third_party) target_link_libraries(${LIBRARY_NAME} PUBLIC doctest daw third_party)

but in my main.cpp i get this error when "make" fatal error: daw/json/daw_json_link.h: No such file or directory 29 | #include "daw/json/daw_json_link.h"

Does anyone have any idea how to install it easily?

beached commented 4 years ago

With the old version, one needed to clone the three repos and have them in the include path. In dev, and in the last prerelease https://github.com/beached/daw_json_link/releases/tag/v1.9.2 which should be stable and is nearing the v2.0 release one can use cmake's fetchcontent or do an install of the library. I would recommend using the v1.9.2. linked above as it's only deficiency compared to the v1 is the documentation isn't fully updated. It does include an extensive set of test/example files in tests though.

If you want v2. and the prerelease for the way to include in your cmake project is to

include( FetchContent )
FetchContent_Declare(
        daw_json_link
        GIT_REPOSITORY https://github.com/beached/daw_json_link
        GIT_TAG v1.9.2
)
FetchContent_MakeAvailable(daw_json_link)

then in your target_link_libraries it's just

target_link_libraries( MyTarget daw::json_link )

And the include paths would be set for everything needed and cmake will pull in the dependencies needed

beached commented 4 years ago

The release branch is now at v2. So the above instructions can be

include( FetchContent )
FetchContent_Declare(
        daw_json_link
        GIT_REPOSITORY https://github.com/beached/daw_json_link
)
FetchContent_MakeAvailable(daw_json_link)

then in your target_link_libraries it's just


target_link_libraries( MyTarget daw::json_link )
t0mpl commented 4 years ago

@beached Couldnt expect a better answer, thank you.

FYI, When installing it, it seemed that Cmake was by default looking for master branch.

include( FetchContent ) FetchContent_Declare( daw_json_link GIT_REPOSITORY https://github.com/beached/daw_json_link GIT_TAG release ) FetchContent_MakeAvailable(daw_json_link)

specifying the branch helped.

beached commented 4 years ago

Thanks, I'll update the docs. Too bad that cmake doesn't use the default branch.