0

Why do I have to set

set(CAPNP_LIB_CAPNP-JSON "")

in my CMakeLists.txt in order to not get an error? Error as follows:

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
CAPNP_LIB_CAPNP-JSON (ADVANCED)
    linked by target "client" in directory <...>
    linked by target "server" in directory <...>

The way I'm using capnproto CMake support is by copying the cmake file included in the capnproto source into my project and including it manually. (Is there a better / standard way to do this? Feels hackish.) The rest is just taken from the CMake file's instructions.

CMake snippet:

# so capnp cmake plugin is found
set(CapnProto_DIR "${CMAKE_CURRENT_SOURCE_DIR}/etc/cmake")
# for some reason there is some json lib or something that isn't found?
#set(CAPNP_LIB_CAPNP-JSON "")
find_package(CapnProto REQUIRED)
include_directories(${CAPNP_INCLUDE_DIRS})
add_definitions(${CAPNP_DEFINITIONS})
set(CAPNPC_SRC_PREFIX "src/capnp")
# capnp out of source config
set(CAPNPC_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CAPNPC_OUTPUT_DIR})
# gen cpp
capnp_generate_cpp(CAPNP_SRCS CAPNP_HDRS
        src/capnp/schema.capnp
)

CMake 3.6.2, building using CLion's integrated build commands. capnp is installed via homebrew, latest version.

Why am I getting the error about the JSON bit? What is that about?

Also, is there a better way for including the official Cap'n Proto CMake file? It seemed to not get distributed with the header and library files when installing via homebrew.

seeekr
  • 101
  • 1
  • 9
  • 1
    `The way I'm using capnproto CMake support is by copying the cmake file included in the capnproto source into my project and including it manually.` - Natural way is to adjust search path to find the file at place. E.g., by setting `CapnProto_DIR`. `Why am I getting the error about the JSON bit? What is that about?` - It is depends from content of `.cmake` script you have. BTW, error message give you a hint where linking is performed, why do not check these directories? – Tsyvarev Oct 14 '16 at 20:56
  • Added a link to the cmake script I'm referencing: https://github.com/sandstorm-io/capnproto/blob/master/c%2B%2B/cmake/FindCapnProto.cmake Re linking: The message seems to just tell me basically which targets are using the generated capnp files, which doesn't seem helpful at all. I don't understand what `CAPNP_LIB_CAPNP-JSON` is at all -- am not very comfortable with digging around in CMake script files at this point! – seeekr Oct 14 '16 at 22:13
  • So, it is a script which uses this variable, see line `find_library(CAPNP_LIB_CAPNP-JSON capnp-json`. I don't know why it needs that library, one can google other `FindCapnp.cmake` scripts which doesn't use json. You ask at the beginning `Why do I have to set ...` - you need to define empty variable for overcome usage of json. – Tsyvarev Oct 14 '16 at 22:50
  • OK, I understand those mechanics. The question is: Since I am using Cap'n Protos "official" CMake file, then that should work without me having to apply such a workaround, right? Because if I'm not defining that variable, then I'm getting a warning, which leads me to think that I'm using something wrong. Which makes me ask -- what am I doing wrong here? I understand that to answer this question it requires to dig into the CMake file further or have deeper knowledge of how Cap'n Proto works here, what it does, what it needs here. – seeekr Oct 14 '16 at 23:01
  • And OK, so basically that means the script can't find the "capnp-json" library, i.e. a .dylib (I'm on OS X) is missing on my system? Otherwise the variable would get defined by the script and I wouldn't have to set it myself? – seeekr Oct 14 '16 at 23:02
  • Dug into this further, turns out CMake script from master branch was referencing a library that was not in the latest release yet, thus the conflict, so workaround is fine for now. Thanks for the help! (see: https://github.com/sandstorm-io/capnproto/issues/381#issuecomment-253943937) – seeekr Oct 14 '16 at 23:42

1 Answers1

0

It turns out json encoding/decoding support is an as yet (Oct 2016) unreleased feature of Cap'n Proto and trying to use the .cmake file from the master branch with the last released version produces this conflict.

Possible solutions:

1) Use workaround posted in the question, i.e.

set(CAPNP_LIB_CAPNP-JSON "") # add this before next line
find_package(CapnProto REQUIRED)

2) Use the released version of the .cmake script here: FindCapnProto.cmake

3) Build and install Cap'n Proto from source, use with latest .cmake script.

seeekr
  • 101
  • 1
  • 9