Difference between revisions of "Cmake"

From Wiki at Neela Nurseries
Jump to: navigation, search
m (^ To print variables in cmake)
m (^ To print variables in cmake)
Line 67: Line 67:
 
Note: I'm using cmake > 3.14
 
Note: I'm using cmake > 3.14
  
 +
---------- ---------- --------- --------- --------- --------
  
 +
 +
A modified generic.cmake file, changes address one or more unset variables and solved build error on newest Zephyr work station:
 +
 +
<pre>
 +
# SPDX-License-Identifier: Apache-2.0
 +
 +
set_ifndef(CC gcc)
 +
 +
## 2022-03-03 - Ted moving this cmake function call beyond locally
 +
##  added variable assignements:
 +
##
 +
## find_program(CMAKE_C_COMPILER ${CROSS_COMPILE}${CC}  PATHS ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
 +
 +
#
 +
## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 +
## 2022-02-08 Reference https://cmake.org/cmake/help/latest/command/message.html
 +
## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 +
#
 +
message(NOTICE "*** zztop 1 *** building with user configuration var ZEPHYR_TOOLCHAIN_VARIANT set to '${ZEPHYR_TOOLCHAIN_VARIANT}'")
 +
message(NOTICE "*** zztop 2 *** internal variable CROSS_COMPILE set to '${CROSS_COMPILE}'")
 +
message(NOTICE "*** zztop 3 *** internal variable TOOLCHAIN_HOME set to '${TOOLCHAIN_HOME}'")
 +
 +
## 2022-03-03 THU - Not ***ing sure why we need to set these today:
 +
set(ZEPHYR_TOOLCHAIN_VARIANT gnuarmemb)
 +
set(GNUARMEMB_TOOLCHAIN_PATH /opt/gcc-arm-none-eabi-10.3-2021.10)
 +
set(TOOLCHAIN_HOME /opt/gcc-arm-none-eabi-10.3-2021.10)
 +
## ^^^ These three cmake variable settings not sufficient, trying another based on working but different
 +
##  toolchain on host ind:
 +
set(CROSS_COMPILE /opt/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-)
 +
##
 +
## $ ls /opt/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-*
 +
##
 +
 +
message(NOTICE "*** zztop 4 *** building with user configuration var ZEPHYR_TOOLCHAIN_VARIANT set to '${ZEPHYR_TOOLCHAIN_VARIANT}'")
 +
message(NOTICE "*** zztop 5 *** internal variable CROSS_COMPILE set to '${CROSS_COMPILE}'")
 +
message(NOTICE "*** zztop 6 *** internal variable TOOLCHAIN_HOME set to '${TOOLCHAIN_HOME}'")
 +
 +
 +
find_program(CMAKE_C_COMPILER ${CROSS_COMPILE}${CC}  PATHS ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
 +
 +
if(CMAKE_C_COMPILER STREQUAL CMAKE_C_COMPILER-NOTFOUND)
 +
  message(FATAL_ERROR "Zephyr was unable to find the toolchain. Is the environment misconfigured?
 +
User-configuration:
 +
ZEPHYR_TOOLCHAIN_VARIANT: ${ZEPHYR_TOOLCHAIN_VARIANT}
 +
Internal variables:
 +
CROSS_COMPILE: ${CROSS_COMPILE}
 +
TOOLCHAIN_HOME: ${TOOLCHAIN_HOME}
 +
")
 +
endif()
 +
 +
execute_process(
 +
  COMMAND ${CMAKE_C_COMPILER} --version
 +
  RESULT_VARIABLE ret
 +
  OUTPUT_QUIET
 +
  ERROR_QUIET
 +
  )
 +
if(ret)
 +
  message(FATAL_ERROR "Executing the below command failed. Are permissions set correctly?
 +
'${CMAKE_C_COMPILER} --version'
 +
"
 +
    )
 +
endif()
 +
</pre>
  
  

Revision as of 23:57, 29 June 2022

Zephyr RTOS building blocks   ::   Device Tree Source   ::   Kconfig   ::   cmake   ::   `west` manifest files


2021-08-06

Starting a page for cmake notes here. Links to cmake site:

Longer guides:


A Nordic Semi document on `cmake` and its role in the build process of Zephyr based applications:


2021-08-17 - search for cmake / Zephyr means to add sources to a Zephyr based project:


^ To print variables in cmake

Note that the following post has a cool answer which involves a cmake macro to print all variables known to a given cmake invocation or use, and also a more simple answer to print one specific variable:


^ To Specify Source Dirs and Library Directories to Linker


^ Install latest version of cmake


^ Zephyr Threads Tutorial by Maksim Drachov

 

- - - top of page - - -