cmake: Fix SDK-less builds
This change changes the semantics of the environment variable ZEPHYR_SDK_INSTALL_DIR to allow the use of 3rd party toolchains alongside the Zephyr SDK's host tools. Specifically, setting ZEPHYR_SDK_INSTALL_DIR now indicates that the Zephyr SDK host tools are to be used. But not necessarily that the Zephyr SDK's toolchain is to be used. The documentation is also changed to explain this behaviour. Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
This commit is contained in:
parent
7f95e83361
commit
8d0a80c6a9
|
@ -1 +0,0 @@
|
|||
include($ENV{ZEPHYR_BASE}/cmake/host-tools-zephyr.cmake)
|
|
@ -1 +0,0 @@
|
|||
include($ENV{ZEPHYR_BASE}/cmake/host-tools-zephyr.cmake)
|
|
@ -1 +0,0 @@
|
|||
include($ENV{ZEPHYR_BASE}/cmake/host-tools-zephyr.cmake)
|
|
@ -1 +0,0 @@
|
|||
include($ENV{ZEPHYR_BASE}/cmake/host-tools-zephyr.cmake)
|
|
@ -5,10 +5,17 @@
|
|||
# and currently provided by the Zephyr SDK. Those tools will need to be
|
||||
# provided for different OSes and sepearately from the toolchain.
|
||||
|
||||
if(DEFINED ENV{ZEPHYR_SDK_INSTALL_DIR})
|
||||
set_ifndef(ZEPHYR_SDK_INSTALL_DIR $ENV{ZEPHYR_SDK_INSTALL_DIR})
|
||||
endif()
|
||||
set(ZEPHYR_SDK_INSTALL_DIR ${ZEPHYR_SDK_INSTALL_DIR} CACHE PATH "Zephyr SDK install directory")
|
||||
|
||||
set_ifndef(ZEPHYR_SDK_INSTALL_DIR $ENV{ZEPHYR_SDK_INSTALL_DIR})
|
||||
set( ZEPHYR_SDK_INSTALL_DIR ${ZEPHYR_SDK_INSTALL_DIR} CACHE PATH "Zephyr SDK install directory")
|
||||
assert( ZEPHYR_SDK_INSTALL_DIR "ZEPHYR_SDK_INSTALL_DIR is not set")
|
||||
if(NOT ZEPHYR_SDK_INSTALL_DIR)
|
||||
# Until https://github.com/zephyrproject-rtos/zephyr/issues/4912 is
|
||||
# resolved we use ZEPHYR_SDK_INSTALL_DIR to determine whether the user
|
||||
# wants to use the Zephyr SDK or not.
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(REQUIRED_SDK_VER 0.9.2)
|
||||
set(TOOLCHAIN_VENDOR zephyr)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
include($ENV{ZEPHYR_BASE}/cmake/host-tools-${ZEPHYR_GCC_VARIANT}.cmake OPTIONAL)
|
||||
include($ENV{ZEPHYR_BASE}/cmake/host-tools-zephyr.cmake)
|
||||
|
||||
if(PREBUILT_HOST_TOOLS)
|
||||
list(APPEND CMAKE_PROGRAM_PATH ${PREBUILT_HOST_TOOLS}/kconfig)
|
||||
|
|
|
@ -116,19 +116,27 @@ The ELF binaries generated by the build system are named by default
|
|||
configuration The build system generates different names for different use cases
|
||||
depending on the hardware and boards used.
|
||||
|
||||
.. _third_party_x_compilers:
|
||||
|
||||
Using Custom and 3rd Party Cross Compilers
|
||||
==========================================
|
||||
.. _sdkless_builds:
|
||||
|
||||
Building without the Zephyr SDK
|
||||
===============================
|
||||
|
||||
The Zephyr SDK is provided for convenience and ease of use. It provides
|
||||
cross-compilers for all ports supported by the Zephyr OS and does not require
|
||||
any extra flags when building applications or running tests.
|
||||
|
||||
If you have a custom cross-compiler or if you wish to use a vendor provided SDK,
|
||||
follow the steps below to build with any custom or 3rd party cross-compilers:
|
||||
In addition to cross-compilers, the Zephyr SDK also provides prebuilt
|
||||
host tools. To use the SDK host tools alongside a custom or 3rd party
|
||||
cross-compiler, keep the ZEPHYR_SDK_INSTALL_DIR environment variable
|
||||
set to the Zephyr SDK installation directory.
|
||||
|
||||
#. To avoid any conflicts with the Zephyr SDK, enter the following commands.
|
||||
To build without the Zephyr SDK's prebuilt host tools, the
|
||||
ZEPHYR_SDK_INSTALL_DIR environment variable must be unset, the host
|
||||
tools must be built and added to path, and a 3rd party cross-compiler
|
||||
must be installed.
|
||||
|
||||
#. Follow the steps below to build without the Zephyr SDK:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
|
@ -152,6 +160,20 @@ follow the steps below to build with any custom or 3rd party cross-compilers:
|
|||
|
||||
You only need to do this once after cloning the git repository.
|
||||
|
||||
Now that the host tools are installed, a 3rd party cross compiler must
|
||||
be installed. See :ref:`below <third_party_x_compilers>` for
|
||||
installing a cross compiler.
|
||||
|
||||
.. _third_party_x_compilers:
|
||||
|
||||
Using Custom and 3rd Party Cross Compilers
|
||||
==========================================
|
||||
|
||||
To use a 3rd party cross compiler that is not provided by the Zephyr
|
||||
SDK, follow the steps below. It is possible to use a 3rd party cross
|
||||
compiler and still use the Zephyr SDK's host tools. See :ref:`the
|
||||
section above <sdkless_builds>` for details.
|
||||
|
||||
#. We will use the `GCC ARM Embedded`_ compiler for this example, download the
|
||||
package suitable for your operating system from the `GCC ARM Embedded`_ website
|
||||
and extract it on your file system. This example assumes the compiler was
|
||||
|
|
Loading…
Reference in New Issue