[CMake] Checking Variables in a tool-chain file

Shoaib Meenai smeenai at fb.com
Thu Jan 31 15:27:41 EST 2019


That’s perfect! It looks like it was introduced in CMake 3.6, whereas LLVM targets a minimum of 3.4.3 right now, but I’ll make a note of it for the next CMake upgrade. Thanks!

From: CMake <cmake-bounces at cmake.org> on behalf of Craig Scott <craig.scott at crascit.com>
Date: Thursday, January 31, 2019 at 12:10 PM
To: "Torsten at Robitzki.de" <Torsten at robitzki.de>
Cc: CMake MailingList <cmake at cmake.org>
Subject: Re: [CMake] Checking Variables in a tool-chain file

This is precisely the scenario that the CMAKE_TRY_COMPILE_PLATFORM_VARIABLES<https://urldefense.proofpoint.com/v2/url?u=https-3A__cmake.org_cmake_help_latest_variable_CMAKE-5FTRY-5FCOMPILE-5FPLATFORM-5FVARIABLES.html&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=DWIp-ETcvhiY2syIyGl15SjKRGmBgOqESLLbtIITkg0&s=dUHD897Pz1vT4JSorC4Kp7QbWhBuxzgq9jS4SQWX5I0&e=> variable is meant for. It allows a toolchain file to specify additional variables that should be passed along to try_compile().


On Fri, Feb 1, 2019 at 6:36 AM Shoaib Meenai <smeenai at fb.com<mailto:smeenai at fb.com>> wrote:
We have a somewhat similar problem with LLVM's toolchain file for cross-compiling to Windows, and we solve it there by saving and restoring cache variables from the environment inside the toolchain file itself. See https://reviews.llvm.org/diffusion/L/browse/llvm/trunk/cmake/platforms/WinMsvc.cmake;352783$88-102?as=source&blame=off<https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_diffusion_L_browse_llvm_trunk_cmake_platforms_WinMsvc.cmake-3B352783-2488-2D102-3Fas-3Dsource-26blame-3Doff&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=DWIp-ETcvhiY2syIyGl15SjKRGmBgOqESLLbtIITkg0&s=lF2TBukE0bj0x1YOkOC6golh5vzIBnpbZLQVXb_1poU&e=> and the subsequent calls to init_user_prop.

On 1/31/19, 12:19 AM, "CMake on behalf of Torsten at Robitzki.de" <cmake-bounces at cmake.org<mailto:cmake-bounces at cmake.org> on behalf of Torsten at Robitzki.de> wrote:

    Hi Sergei,

    > Am 31.01.2019 um 08:42 schrieb Sergei Nikulov <sergey.nikulov at gmail.com<mailto:sergey.nikulov at gmail.com>>:
    >
    > Just guessing maybe better use $ENV{ARM_GCC_TOOL_PATH} ?
    > https://cmake.org/cmake/help/latest/variable/ENV.html?highlight=env<https://urldefense.proofpoint.com/v2/url?u=https-3A__cmake.org_cmake_help_latest_variable_ENV.html-3Fhighlight-3Denv&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=DWIp-ETcvhiY2syIyGl15SjKRGmBgOqESLLbtIITkg0&s=vw42QC6Z-nK-9Ga13koxIghj6vajaXQv1OQa3aSXloU&e=>

    Well, but this would mean, I had to configure CMake not only with Cache variables:

    cmake -DARM_GCC_TOOL_PATH=/usr/local/gcc-arm-none-eabi-7-2018-q2-update -DBINDING=nrf52 -DCMAKE_TOOLCHAIN_FILE=../cmake/gcc-arm-none-eabi.cmake -DNRF5_SDK_ROOT=~/CMSIS/nRF5_SDK_14-2/ ..

    But also with environment variables:
    ARM_GCC_TOOL_PATH=/usr/local/gcc-arm-none-eabi-7-2018-q2-update cmake -DBINDING=nrf52 -DCMAKE_TOOLCHAIN_FILE=../cmake/gcc-arm-none-eabi.cmake -DNRF5_SDK_ROOT=~/CMSIS/nRF5_SDK_14-2/ ..

    Thanks for the pointer, I will think about it.

    kind regards,
    Torsten

--
Craig Scott
Melbourne, Australia
https://crascit.com<https://urldefense.proofpoint.com/v2/url?u=https-3A__crascit.com&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=DWIp-ETcvhiY2syIyGl15SjKRGmBgOqESLLbtIITkg0&s=-gBb_NSht4wIEsgFyHBr8kq1xS721KBwcVTguP18ehA&e=>

Get the hand-book for every CMake user: Professional CMake: A Practical Guide<https://urldefense.proofpoint.com/v2/url?u=https-3A__crascit.com_professional-2Dcmake_&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=DWIp-ETcvhiY2syIyGl15SjKRGmBgOqESLLbtIITkg0&s=roR58RXGVlqqg-JVPQNTOi7OfUznG7eEEHheyPmJEnc&e=>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190131/c406c967/attachment-0001.html>


More information about the CMake mailing list