[CMake] Checking Variables in a tool-chain file

Sergei Nikulov sergey.nikulov at gmail.com
Thu Jan 31 02:42:29 EST 2019


чт, 31 янв. 2019 г. в 10:29, Torsten Robitzki <Torsten at robitzki.de>:
>
> Hi,
> I have a tool-chain file, which requires a variable to be set to the path to the compiler on the local machine:
>
>   set(CMAKE_C_COMPILER ${ARM_GCC_TOOL_PATH}/bin/arm-none-eabi-gcc)
>   set(CMAKE_CXX_COMPILER ${ARM_GCC_TOOL_PATH}/bin/arm-none-eabi-g++)
>
> Now I want to give the user an error message, in case that this variable is not set. The „usual“ check for the existence of the variable doesn’t work, because the tool-chain file is included in different context, without access to the cache.
>
> Any idea?

Just guessing maybe better use $ENV{ARM_GCC_TOOL_PATH} ?
https://cmake.org/cmake/help/latest/variable/ENV.html?highlight=env


-- 
Best Regards,
Sergei Nikulov


More information about the CMake mailing list