Building with CMake

454 views
Skip to first unread message

Jens Alfke

unread,
May 13, 2022, 7:31:15 PM5/13/22
to Cap'n Proto
I want to build Cap’n Proto from source as part of my project; I know it’s preferred to download a release, but I need to support iOS and there are no releases for that AFAIK.

The build instructions at https://capnproto.org/install.html seem out of date; they say to use autoconf, but the current sources have a CMakeFile and I found that the usual CMake build command work fine:
mkdir build_cmake && cd build_cmake
cmake ..
make

However, if I add capnproto as a subdirectory to my project’s CMakeLists.txt:
add_subdirectory(vendor/capnproto)
it doesn’t build. During the initial ‘cmake’ command for my project, I get several errors of the form:

CMake Error at vendor/capnproto/c++/cmake/CapnProtoMacros.cmake:106 (add_custom_command):
  Error evaluating generator expression:

    $<TARGET_FILE:CapnProto::capnp_tool>

  No target "CapnProto::capnp_tool"
Call Stack (most recent call first):
  CMakeLists.txt:113 (capnp_generate_cpp)

I have no idea what this means, or what to do about it…

—Jens

Kenton Varda

unread,
May 13, 2022, 9:08:31 PM5/13/22
to Jens Alfke, Cap'n Proto
On Fri, May 13, 2022 at 6:31 PM Jens Alfke <je...@mooseyard.com> wrote:
I want to build Cap’n Proto from source as part of my project; I know it’s preferred to download a release, but I need to support iOS and there are no releases for that AFAIK.

Do you mean that iOS was broken at the last release, but has been fixed at master since then? (I don't know how to test iOS so I have no idea which versions work or not...)
 
The build instructions at https://capnproto.org/install.html seem out of date; they say to use autoconf, but the current sources have a CMakeFile and I found that the usual CMake build command work fine:

The instructions are not out of date. autotools is still considered to be the preferred build system, but cmake files have been contributed. I don't personally understand cmake so these files are maintained by other contributors.

(Unfortunately that means I don't know the answer to your question...)

-Kenton
 
mkdir build_cmake && cd build_cmake
cmake ..
make

However, if I add capnproto as a subdirectory to my project’s CMakeLists.txt:
add_subdirectory(vendor/capnproto)
it doesn’t build. During the initial ‘cmake’ command for my project, I get several errors of the form:

CMake Error at vendor/capnproto/c++/cmake/CapnProtoMacros.cmake:106 (add_custom_command):
  Error evaluating generator expression:

    $<TARGET_FILE:CapnProto::capnp_tool>

  No target "CapnProto::capnp_tool"
Call Stack (most recent call first):
  CMakeLists.txt:113 (capnp_generate_cpp)

I have no idea what this means, or what to do about it…

—Jens

--
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 capnproto+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/capnproto/8FDA7AA9-F7A2-4FC7-BC86-DD3B569FF210%40mooseyard.com.

Jens Alfke

unread,
May 14, 2022, 3:36:25 PM5/14/22
to Kenton Varda, Cap'n Proto

On May 13, 2022, at 6:07 PM, Kenton Varda <ken...@cloudflare.com> wrote:

Do you mean that iOS was broken at the last release, but has been fixed at master since then? (I don't know how to test iOS so I have no idea which versions work or not…)

I just mean that AFAIK there are no binary libraries for iOS on your website. (Right?)

I did discover that I can run `cmake -G Xcode .` and CMake will generate an Xcode project file. Then I was able to change a few build settings in the project and get Xcode to build iOS static libs. I haven’t actually tested them yet, but this looks like a promising approach, even if it’s not as turn-key as just running CMake in my top-level project directory.

—Jens

Kenton Varda

unread,
May 14, 2022, 5:34:48 PM5/14/22
to Jens Alfke, Cap'n Proto
On Sat, May 14, 2022 at 2:36 PM Jens Alfke <je...@mooseyard.com> wrote:

On May 13, 2022, at 6:07 PM, Kenton Varda <ken...@cloudflare.com> wrote:

Do you mean that iOS was broken at the last release, but has been fixed at master since then? (I don't know how to test iOS so I have no idea which versions work or not…)

I just mean that AFAIK there are no binary libraries for iOS on your website. (Right?)

There are no precompiled libraries for any platform. The release package just contains source code.

-Kenton
Reply all
Reply to author
Forward
0 new messages