diff --git a/CMakeLists.txt b/CMakeLists.txt index c76439e8..b71d7834 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,6 +51,7 @@ install(TARGETS mpgen EXPORT Multiprocess RUNTIME DESTINATION bin) configure_file(include/mp/config.h.in "${CMAKE_CURRENT_BINARY_DIR}/include/mp/config.h") configure_file(pkgconfig/libmultiprocess.pc.in "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/libmultiprocess.pc" @ONLY) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/libmultiprocess.pc" DESTINATION "lib/pkgconfig") +install(FILES "include/mpgen.mk" DESTINATION "include") install(EXPORT Multiprocess DESTINATION lib/cmake/Multiprocess) diff --git a/include/mp/config.h.in b/include/mp/config.h.in index ce8f1f73..c0ec4dd4 100644 --- a/include/mp/config.h.in +++ b/include/mp/config.h.in @@ -5,6 +5,7 @@ #ifndef MP_CONFIG_H #define MP_CONFIG_H +#cmakedefine CMAKE_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@" #cmakedefine capnp_PREFIX "@capnp_PREFIX@" #endif // MP_CONFIG_H diff --git a/include/mpgen.mk b/include/mpgen.mk new file mode 100644 index 00000000..2af7e998 --- /dev/null +++ b/include/mpgen.mk @@ -0,0 +1,4 @@ +%.capnp: + @: +%.capnp.c++ %.capnp.h %.capnp.proxy-client.c++ %.capnp.proxy-types.h %.capnp.proxy-server.c++ %.capnp.proxy-types.c++ %.capnp.proxy.h: %.capnp + $(AM_V_GEN) $(MPGEN_PREFIX)/bin/mpgen '$(srcdir)' '$(srcdir)' $< diff --git a/src/mp/gen.cpp b/src/mp/gen.cpp index 75825348..4873d0a5 100644 --- a/src/mp/gen.cpp +++ b/src/mp/gen.cpp @@ -528,6 +528,11 @@ int main(int argc, char** argv) exit(1); } std::vector import_paths; + auto fs = kj::newDiskFilesystem(); + auto cwd = fs->getCurrentPath(); + for (const char* path : {CMAKE_INSTALL_PREFIX "/include", capnp_PREFIX "/include"}) { + KJ_IF_MAYBE(dir, fs->getRoot().tryOpenSubdir(cwd.evalNative(path))) { import_paths.emplace_back(path); } + } for (size_t i = 4; i < argc; ++i) { import_paths.push_back(argv[i]); }