philips-software/amp-embedded-infra-lib

Allow use of own toolchain file

danielschenk opened this issue · 3 comments

I'm trying to get the library to build as part of another project, which also uses CMake itself. I'm using the ExternalProject facilities for that:

set(source_dir ${CMAKE_CURRENT_LIST_DIR}/../../../embeddedinfralib)
set(install_dir ${CMAKE_CURRENT_LIST_DIR}/../embeddedinfralib-install)

include(ExternalProject)
ExternalProject_Add(embeddedinfralib
    PREFIX      ${source_dir}
    SOURCE_DIR  ${source_dir}
    BINARY_DIR  ${CMAKE_CURRENT_LIST_DIR}/../embeddedinfralib-build
    CMAKE_ARGS  -DCCOLA_DIR=${source_dir}/ccola -DCCOLA_INSTALL_DIR=${install_dir} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DTOOLCHAIN_PREFIX=${TOOLCHAIN_PREFIX}
)

As can be seen, the toolchain file of the outer project is passed on to the configure command for emil, along with another variable which that specific toolchain file needs. When I do this, the first error is this:

CMake Error at ccola/ccola.inc:47 (include):
[build]   include could not find load file:
[build] 
[build]     C:/workspace/beltpack-firmware/embeddedinfralib/ccola/platforms/platform-ARM.inc

When I temporarily comment out this include, the next thing which fails is:

-- adding pack cpp
[build] CMake Error at ccola/packs/cpp/start_pack.inc:583 (if):
[build]   if given arguments:
[build] 
[build]     "STREQUAL" "lpc17xx"

There are a lot more if-statements which assume things like CCOLA_PROCESSOR, CCOLA_ARCH_FAMILY to be set by the platform file. However, I only want to use some generic stuff from infra, and I want to build it using my own toolchain and compiler settings, which should be okay because those parts are platform-independent. I also believe that the only responsibility of a CMake toolchain file should be setting built-in variables like CMAKE_C_COMPILER for the actual tools and the ones which define compiler flags for the different build configurations.

Because of this I feel a bit forced to add all the sources I need myself, in my own CMake project for now.

We are planning to severely slim-down CCola, using 'modern CMake' as replacement for a lot of the concepts available in CCola. We will take your use-case into account when starting the refactoring. Thanks for your detailed feed-back.

See #43 for progress on the migration.

Closed by #45.