Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions cmake/TargetCapnpSources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ Arguments:

#include <schema.capnp.h>

The specified include_prefix should be ${CMAKE_SOURCE_DIR} or a
subdirectory of it to include files relative to the project root. It can
be ${CMAKE_CURRENT_SOURCE_DIR} to include files relative to the current
source directory.
Pass ${CMAKE_CURRENT_SOURCE_DIR} or a subdirectory of it to include files
relative to the current source directory (the typical usage).

Additional Unnamed Arguments:

Expand All @@ -43,12 +41,19 @@ Optional Keyword Arguments:
IMPORT_PATHS: Specifies additional directories to search for imported
`.capnp` files.

ONLY_CAPNP: If specified, only the Cap'n Proto serialization files
(`.capnp.h`, `.capnp.c++`) are generated and compiled. The mpgen proxy
files (`.capnp.proxy-client.c++`, `.capnp.proxy-server.c++`,
`.capnp.proxy-types.c++`, etc.) are skipped. Useful when you need
Cap'n Proto serialization without the multiprocess RPC proxy
infrastructure.

Example:
# Assuming `my_library` is a target and `lib/` contains `.capnp` schema
# files with imports from `include/`.
target_capnp_sources(my_library "${CMAKE_SOURCE_DIR}"
target_capnp_sources(my_library "${CMAKE_CURRENT_SOURCE_DIR}"
lib/schema1.capnp lib/schema2.capnp
IMPORT_PATHS ${CMAKE_SOURCE_DIR}/include)
IMPORT_PATHS ${CMAKE_CURRENT_SOURCE_DIR}/include)

#]=]

Expand Down Expand Up @@ -98,8 +103,8 @@ function(target_capnp_sources target include_prefix)

# Translate include_prefix from a source path to a binary path and add it as a
# target include directory.
set(build_include_prefix ${CMAKE_BINARY_DIR})
file(RELATIVE_PATH relative_path ${CMAKE_SOURCE_DIR} ${include_prefix})
set(build_include_prefix ${CMAKE_CURRENT_BINARY_DIR})
file(RELATIVE_PATH relative_path ${CMAKE_CURRENT_SOURCE_DIR} ${include_prefix})
if(relative_path)
string(APPEND build_include_prefix "/" "${relative_path}")
endif()
Expand Down
Loading