[CMake] Environment variables and ExternalProject

Milutin Jovanović jovanovic.milutin at gmail.com
Mon Oct 17 12:27:14 EDT 2011


Hi all,

Hi all. First time posting. Before I start I'd like to thank all the Kitware
guys for a very nice and useful tool. I did a fair bit of searching to try
to avoid asking duplicate questions, but did not find answer to my problem.

I am trying to make a private build of some dependencies, ogg and vorbis in
this case. The initial problem is that second library make is not finding
first, due to pkg-config not finding output files from the first library.
OK, I said, and did PKG_CONFIG_PATH=... and export PKG_CONFIG_PATH before
executing cmake build. And this fixed the problem.

However then I tried to ease the job of whoever might be using this, and
tried setting the PKG_CONFIG_PATH inside the cmake script. But this does not
work. I did some tests, and indeed, configure executed as part of
ExternalProject does not see environmental variables set by cmake.

So, the question is, am I doing something wrong or is this cmake limitation?

Miki.

P.S. I am doing this on a Mac OSX Lion, but I expect it to work on Linux
without modifications.

=== CMakeLists.txt ===

cmake_minimum_required(VERSION 2.8)

set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR} CACHE PATH "Path where to
install.")

project(dependecies)

include(ExternalProject)

set(ENV{PKG_CONFIG_PATH}
"${CMAKE_INSTALL_PREFIX}/lib/pkgconfig/:$ENV{PKG_CONFIG_PATH}")
message(STATUS "PKG_CONFIG_PATH=$ENV{PKG_CONFIG_PATH}")

ExternalProject_Add(
    libogg
    PREFIX libogg
    URL http://downloads.xiph.org/releases/ogg/libogg-1.3.0.tar.gz
    URL_MD5 0a7eb40b86ac050db3a789ab65fe21c2
    UPDATE_COMMAND set
    CONFIGURE_COMMAND ./configure --prefix=${CMAKE_INSTALL_PREFIX}
           BUILD_COMMAND make
    # INSTALL_COMMAND make install
           BUILD_IN_SOURCE 1
    )

ExternalProject_Add(
    libvorbis
    DEPENDS libogg
    PREFIX libvorbis
    URL http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.2.tar.bz2
    URL_MD5 798a4211221073c1409f26eac4567e8b
    UPDATE_COMMAND set
    CONFIGURE_COMMAND PKG_CONFIG_PATH=${CMAKE_INSTALL_PREFIX}/lib/pkgconfig
&& export PKG_CONFIG_PATH && set && ./configure
--prefix=${CMAKE_INSTALL_PREFIX} --with-ogg=${CMAKE_INSTALL_PREFIX}
    BUILD_COMMAND make
    # INSTALL_COMMAND make install
           BUILD_IN_SOURCE 1
    )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20111017/a486ba1b/attachment.htm>


More information about the CMake mailing list