[CMake] SET(ENV{PKG_CONFIG_SYSROOT_DIR} $FOO) doesn't work on the first run

Antoine Villeret antoine.villeret at gmail.com
Mon Jan 9 11:16:15 EST 2017


Hello everyone,

in my toolchain file I have :

    SET(ENV{PKG_CONFIG_SYSROOT_DIR} "${RPI_ROOT_PATH}")

then I run :

cmake -DCMAKE_TOOLCHAIN_FILE=${PWD}/../of/dev/arm-linux-gnueabihf.cmake
-DRPI_ROOT_PATH='/tmp/rpi/root' -DOF_PLATFORM=armv7 -G Ninja ../of

Environnement variable PKG_CONFIG_SYSROOT_DIR should then be filled with '
/tmp/rpi/root'

But that doesn't work.

If I run `cmake` once again (with all of the arguments above), the
environnement variable is correctly set.
I mean :

message(STATUS "PKG_CONFIG_SYSROOT_DIR: " $ENV{PKG_CONFIG_SYSROOT_DIR})

shows :

PKG_CONFIG_SYSROOT_DIR: /tmp/rpi/root

which is correct, but since `pkg-config` has been run without that defined
on the first run, the include and library paths are not updated and build
failed.

Why SET method doesn't set the variable right on the first run ?

If I use :

    SET(ENV{PKG_CONFIG_SYSROOT_DIR} "/tmp/rpi/root")

everything works fine.

Moreover a very minimal CMakeLists.txt and toolchain.cmake works fine (see
: https://gist.github.com/avilleret/58ca1c9ba79cd203e16729ffe760ddc2).

The original files are here :
https://github.com/ofnode/of/blob/feature/rpiCrossCompiling/CMakeLists.txt
and
https://github.com/ofnode/of/blob/feature/rpiCrossCompiling/dev/arm-linux-gnueabihf.cmake

And I'm using CMake 3.5.2.

Where is my mistake ?

Regards

Antoine
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170109/fdb910a0/attachment.html>


More information about the CMake mailing list