2

I'm trying to include this library in my project: https://github.com/kuafuwang/LspCpp.git

I'm using FetchContent which succesfully populates _deps/lspcpp-build, _deps/lspcpp-src, _deps/lspcpp-subbuild:

FetchContent_Declare( lspcpp GIT_REPOSITORY https://github.com/kuafuwang/LspCpp.git ) FetchContent_GetProperties(lspcpp) if(NOT lspcpp_POPULATED) FetchContent_Populate(lspcpp) endif() 

I define my executable:

add_executable(myApp foo.cpp bar.cpp ... ) 

And try to link it:

target_include_directories(myApp lspcpp) target_link_libraries(myApp lspcpp) 

This produces this error:

/usr/bin/ld: cannot find -llspcpp: No such file or directory 
2
  • 1
    I believe you need to add_subdirectory(${lspcpp_SOURCE_DIR} ${lspcpp_BINARY_DIR}) within the if statement after populate Commented Nov 3, 2022 at 20:55
  • 1
    @DoritoJohnson It worked! Feel free to write an answer, then I will be happy to accept it. :) Commented Nov 3, 2022 at 21:13

1 Answer 1

3

You are missing a step for FetchContent, to build the library.

FetchContent_Declare( lspcpp GIT_REPOSITORY https://github.com/kuafuwang/LspCpp.git ) FetchContent_GetProperties(lspcpp) if(NOT lspcpp_POPULATED) FetchContent_Populate(lspcpp) add_subdirectory(${lspcpp_SOURCE_DIR} ${lspcpp_BINARY_DIR}) # add this line endif() 
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! Seems FetchContent_MakeAvailable(lspcpp) automatically calls add_subdirectory, so you only need that after FetchContent_Declare.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.