On 17/10/2011 18.27, Milutin Jovanovic' wrote:

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?
I' m not really sure, but I think it is a CMake limitation that has been discussed before:
When you do

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

I think that you are setting the environment for the current cmake process and all it' s child processes.

The problem is that when you use ExternalProject_Add() you are building a Makefile that will be processed at "build" time whwn you invoke make (or a XCode ide processing)

That process is NOT a child of your cmake, so the env is lost

As far as I know, there is (unfortunately) no ENV clause in ExternalProcess, so the only (ugly) workaround that I have found is to define a wrapper of the two configure and make processes that pass the env you need like:

1) using the included pkgconfig_env.cmake
2) calling the wrapper script as I' ve tried to show subsequently by modifying your second call

There could be a simpler way in your case, but I' ve included this as is what I' m using for packaging external libraries.

I would really like to have an ENV clause in ExternalProcess to force all the called steps to have a defined environment

HTH
              Luigi











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
    )

set(_mymoduledir <---- where you put the included file pkgconfig_env.cmake ------> set(conf_command_body ./configure --prefix=${CMAKE_INSTALL_PREFIX} --with-ogg=${CMAKE_INSTALL_PREFIX}
string(REPLACE ";" "@@" managed_conf_command_body "${conf_command_body}" )
set(conf_command CONFIGURE_COMMAND ${CMAKE_COMMAND} -Dmy_binary_dir:PATH=<BINARY_DIR> -Dmy_source_dir:PATH=<SOURCE_DIR> -Dmy_install_dir:PATH=${CMAKE_INSTALL_PREFIX} -Dmy_configure:STRING=${managed_conf_command_body} -P ${_mymoduledir}/pkgconfig_env.cmake)

set(make_command_body make --jobs 4)
string(REPLACE ";" "@@" managed_make_command_body "${make_command_body}" )
set(make_command BUILD_COMMAND ${CMAKE_COMMAND} -Dmy_binary_dir:PATH=<BINARY_DIR> -Dmy_source_dir:PATH=<SOURCE_DIR> -Dmy_install_dir:PATH=${CMAKE_INSTALL_PREFIX} -Dmy_configure:STRING=${managed_make_command_body} -P ${_mymoduledir}/pkgconfig_env.cmake)
 set(list_separator "LIST_SEPARATOR @@")

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
        ${conf_command}
        ${make_command}
        ${list_separator}

    # INSTALL_COMMAND make install
           BUILD_IN_SOURCE 1
    )



--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


--
Luigi Calori
SuperComputing Applications and Innovation Department
CINECA - via Magnanelli, 6/3, 40033 Casalecchio di Reno (Bologna) - ITALY
Tel: +39 051 6171509  Fax: +39 051 6132198
hpc.cineca.it

set(ENV{PATH} "${my_install_dir}/bin:$ENV{PATH}")
string(REPLACE "@@" ";" my_configure "${my_configure}" )

set(ENV{PKG_CONFIG_PATH} ${my_install_dir}/lib/pkgconfig)
set(ENV{LD_LIBRARY_PATH} ${my_install_dir}/lib:$ENV{LD_LIBRARY_PATH})
set(ENV{LDFLAGS} "-L${my_install_dir}/lib")
set(ENV{CFLAGS} "-I${my_install_dir}/include")
set(ENV{CPPFLAGS} "-I${my_install_dir}/include")
set(ENV{PATH} "${my_install_dir}/bin:$ENV{PATH}")

message("
binary_dir--->${my_binary_dir}<--
source_dir--->${my_source_dir}<--
install_dir--->${my_install_dir}<--
my_configure-->${my_configure}<--
PATH-->$ENV{PATH}<--
")


execute_process(COMMAND ${my_configure} 
	    RESULT_VARIABLE status_code
#	    OUTPUT_VARIABLE log
)
execute_process(COMMAND "echo $PKG_CONFIG_PATH")
if(NOT status_code EQUAL 0)
	message(FATAL_ERROR "configure error in line: ${my_configure}
		    status_code: ${status_code}
	    ")
endif()

--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to