2

I have temp.capnp file where my cmake file has

find_package(CapnProto CONFIG REQUIRED)
include_directories(${CAPNP_INCLUDE_DIRS})
add_definitions(${CAPNP_DEFINITIONS})

set(CAPNPC_SRC_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}" CACHE STRING "" FORCE)
set(CAPNPC_OUTPUT_DIR "." CACHE STRING "" FORCE)
file(MAKE_DIRECTORY "${CAPNPC_OUTPUT_DIR}")

capnp_generate_cpp(CAPNP_SOURCES CAPNP_HEADERS temp.capnp)

with this, it does not generate respective files for capnp, it does not give any error as well. what I am missing here?

metal
  • 6,202
  • 1
  • 34
  • 49
debonair
  • 2,505
  • 4
  • 33
  • 73
  • Add some `MESSAGE()` statements to `CapnProtoMacros.cmake` to print out values in order to see where it is going wrong. – metal Feb 12 '19 at 20:03
  • @metal do I have to write anymore `.cmake` files? where can i find `CapnProtoMacros.cmake`? I just have one `cmake.Lists` file – debonair Feb 12 '19 at 21:23

1 Answers1

2

Macro capnp_generate_cpp generates files in form of the add_custom_command, that is, nothing is performed unless some target depends on these files.

The most simple form of such dependency is produced by add_executable:

# Create rules for generate source and header files.
capnp_generate_cpp(CAPNP_SOURCES CAPNP_HEADERS temp.capnp)
# Consume these files for executable.
add_executable(foo main.cpp ${CAPNP_SOURCES} ${CAPNP_HEADERS})

BTW, such example is provided in the description for CapnProtoConfig.cmake script, which is processed via find_package(CapnProto). (Do not forget about other lines in this example for make the executable built successfully).

Tsyvarev
  • 60,011
  • 17
  • 110
  • 153