On Wed, Oct 28, 2020 at 2:35 PM Chris Koziarz
<[email protected]> wrote:
>
> Camkes CMakefiles are quite different to the non-camkes ones that I've
> learned recently. For starters, I cannot figure out a simple step of adding
> an include path & a static library to a camkes project.

Hi Chris,

Camkes CMake files use custom CMake functions to define Camkes component types.
The Camkes tooling then internally generates a CMake script that has
the standard CMake functions such as target_link_libraries and
add_executable.
This is so that if you have the following camkes spec with 2 instances
of the same type, 2 executables will be produced (client1 and client2)
that will use the same static source files you provided in
DeclareCAmkESComponent but they will have different generated source
files based on differences between the instances in the camkes ADL
spec:

assembly {
    composition {
        component Adder adder;
        component Client client1;
        component Client client2;

        connection seL4SharedData s(from adder.d, to client1.d);
        connection seL4RPCCall p(from client1.a, to adder.a);
        connection seL4SharedData s(from adder.d, to client2.d);
        connection seL4RPCCall p(from client2.a, to adder.a);
    }
}

Adding a library dependency to the Driver component type just requires
an extra argument:

DeclareCAmkESComponent(Driver
  SOURCES components/Driver/src/driver.c components/Driver/src/sel4vka-caller.c
  LIBS sel4vka)

This should lead to any Driver camkes components to be linked with
libsel4vka.a and inherit any of libsel4vka's include paths.
The main list arguments that DeclareCAmkESComponent takes to configure
the build args for a component are:
SOURCES: Sources (passed to add_executable)
INCLUDES: Include paths (passed to target_include_directories)
C_FLAGS: C flags (passed to target_compile_options)
LD_FLAGS: Linker flags (effectively passed to target_link_options)
LIBS: Libraries to link against (passed to target_link_libraries)

There are a couple of extra options that are less commonly used.

In addition the camkes tooling adds additional items to each of these
options in order to provide the runtime for each component.

If you wanted to look through the implementation, then camkes.cmake
and camkes-gen.cmake are the two files inside camkes-tool that
implement almost all of this functionality.

Kind regards,

Kent.


> For example, I want to expand projects/camkes/apps to include an extra file
> that calls functions from libsel4vka.
> Adding a source file is easy: just expand SOURCES list, e.g.:
>
> DeclareCAmkESComponent(Driver SOURCES components/Driver/src/driver.c
> components/Driver/src/sel4vka-caller.c)
>
> But  sel4vka-caller.c needs the include paths
> to seL4_libs/libsel4vka/include.
> And the  libsel4vka.a needs to be built and linked to the executable. I
> don't know how I can achieve it. The CMakefile original (trivial) content
> is:
>
> project(uart C)
>
> DeclareCAmkESComponent(Client SOURCES components/Client/src/client.c)
> DeclareCAmkESComponent(Driver SOURCES components/Driver/src/driver.c)
>
> DeclareCAmkESRootserver(uart.camkes)
>
> I try to add the libsel4vka.a to the linker via appending to it:
>
> target_link_libraries(
>     uart
>     PUBLIC
>         sel4vka
> )
>
> But I get:
>
> /usr/bin/cmake -S/home/chris/camkes_brkwy/projects/camkes
> -B/home/chris/camkes_brkwy/uart_tqma8xqp-build
> ninja: error: rebuilding 'build.ninja': subcommand failed
> chris@ubuntu:~/camkes_brkwy/uart_tqma8xqp-build$ ninja
>
> CMake Error at apps/uart/CMakeLists.txt:35 (target_link_libraries):
>   Cannot specify link libraries for target "uart" which is not built by this
>   project.
>
> I don't understand why "uart" is not a target, given the statement:
> project(uart C)
>
> So given target_link_libraries() fails me here, what am I doing wrong?
> what's the proper way of including -I paths and *.a files in Camkes-type
> CMakefile?





> Thanks for your help!
> Chris
> _______________________________________________
> Devel mailing list
> [email protected]
> https://sel4.systems/lists/listinfo/devel

_______________________________________________
Devel mailing list
[email protected]
https://sel4.systems/lists/listinfo/devel

Reply via email to