Hi Jagdish,

I assume you're hitting this error:
https://github.com/sandstorm-io/capnproto/blob/HEAD/c%2B%2B/cmake/CapnProtoMacros.cmake#L89

The capnp_generate_cpp function is expecting your schema files to be
descendants of CAPNPC_SRC_PREFIX so that it can create a parallel
output path in CAPNPC_OUTPUT_DIR. Given your example, it doesn't know
where it should place "schema.capnp.[c++/h]".

Good CMake practice is to work within the CMAKE_CURRENT_SOURCE_DIR and
generate outputs in CMAKE_CURRENT_BINARY_DIR. In your case:
  ~jack/project would have your top-level CMakeLists.txt for the project,
  ~jack/project/a/CMakeLists.txt would compile schema.capnp and create
a target for its output, and
  ~jack/project/b/CMakeLists.txt would have a target that depends on it.
Can you tell us a little bit more about your project structure if this
doesn't work for you?

Philip


On 27 February 2017 at 13:02, Kenton Varda <[email protected]> wrote:
> Hi Jagdish,
>
> FWIW, the underlying `capnp` tool definitely supports this, so if cmake
> doesn't, it's a problem in the cmake files. Unfortunately I personally don't
> know anything about cmake so I can't help answer the question. Maybe Phil
> (cc'd) knows more?
>
> -Kenton
>
> On Fri, Feb 24, 2017 at 1:26 PM, Jack <[email protected]> wrote:
>>
>> Hello,
>>
>> In my project, I have a 'schema.capnp' in '/home/jack/project/a/'
>> directory.
>> Now, I've a 'CMakeLists.txt' file in '/home/jack/project/b/' directory and
>> I want to generate
>> 'schema.capnp.c++' and 'schema.capnp.h' file from 'schema.capnp' placed in
>> '/home/jack/project/a/' directory.
>> The output/generated files, i.e., .c++ and .h files, should also be placed
>> in '/home/jack/project/a/' directory.
>>
>> What I try to do in file in '/home/jack/project/b/CMakeLists.txt'
>> directory is the following:
>> set(CAPNPC_OUTPUT_DIR ${PROJECT_SOURCE_DIR}/a/)
>> capnp_generate_cpp(CAPNP_SRCS CAPNP_HDRS ../a/schema.capnp)
>> However, this fails.
>>
>> Is it possible to do so and if yes, how?
>>
>> Thanks,
>> Jagdish
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Cap'n Proto" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> Visit this group at https://groups.google.com/group/capnproto.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/capnproto.

Reply via email to