[CMake] Embedded build using ExternalProject

Torsten Robitzki Torsten at Robitzki.de
Wed Jun 26 09:53:16 EDT 2019


Hello,

I have a project, where binaries are build for an embedded platform and for a PC platform. To build software update packages for the embedded platforms (files that can be used to make in the field firmware updates), tools that have to run during the build have to be build from source first. For example firmware.tfp have to be build by running create_package with firmware.bin. firmware.bin have to build with settings for the embedded platform and create_package have to be build with setting of the build host.

I’ve asked this question already a year or so ago and got the response, that using super builds will help me. Now I try to convert the project to a super build structure. Fortunately, there was very little content inside my main CMakeLists.txt, mainly `add_subdirectory( source )`. Mainly, I want to build different sets of artifacts from the same source tree, but with different

Now I’m stuck with a number of issues. First, I want to build all firmware binaries for the NRF52 embedded platform:

    ExternalProject_Add(firmware_binaries
        SOURCE_DIR  ${CMAKE_CURRENT_LIST_DIR}/source
        INSTALL_DIR ${installDir}
        CMAKE_ARGS
            -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
            -DBOOTLOADER_AES_KEY=${BOOTLOADER_AES_KEY}
            -DBOOTLOADER_VERSION=${BOOTLOADER_VERSION}
            -DBUILD_DEBUG=1
            -DBUILD_NRF52=1
        BUILD_COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR} --target firmware_binaries
    )

I don’t want to build any EOL test firmware, test-tools etc. just the stuff that will be shipped, thus the explicit target. I can build the firmware_binaries, from the source directly, without problems. But when I try to build with the top-level cmake file, that contains the ExternalProject_Add(), I get the usual configure output and then:

-- Configuring done
-- Generating done
-- Build files have been written to: /Users/todi/blueswd_firmware/build/firmware_binaries-prefix/src/firmware_binaries-build
[ 75%] Performing build step for 'firmware_binaries'
[ 12%] Performing build step for 'firmware_binaries'
[ 12%] Performing build step for 'firmware_binaries'
[ 12%] Performing build step for ‚firmware_binaries‘
…

This line repeats until make reports:

make[776]: /usr/local/Cellar/cmake/3.14.3/bin/cmake: Resource temporarily unavailable
make[776]: *** wait: No child processes.  Stop.
make[776]: *** Waiting for unfinished jobs....
make[776]: *** wait: No child processes.  Stop.

Any idea, what might be wrong here? Some kind of recursion?

An other issue: I want to forward targets to the super build, so that I can build them there. For example I have ~30 unit test programs and when I’m working in a certain area, I usually want to build exactly one of this programs. Is it possible to export them as targets of the super build?

A third issue that I have is, that changes to the CMakeLists.txt files in the Project are not reflected by the super build. If I make a change to one of the CMake files under ${CMAKE_CURRENT_LIST_DIR}/source, I usually have to delete the whole build folder and start from scratch with the build. Is there an other way to force the super build to recognize the changes? (Note: ${CMAKE_CURRENT_LIST_DIR}/source is not added as subdirectory to the top level (super build) CMakeLists.txt).

best regards,

Torsten

P.S.:
$ cmake --version
cmake version 3.14.3

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Message signed with OpenPGP
URL: <https://cmake.org/pipermail/cmake/attachments/20190626/ec95342b/attachment.sig>


More information about the CMake mailing list