[CMake] INCLUDE_DIRECTORIES and UNIX style separated environment variables

blinkeye gentoo at blinkeye.ch
Tue Sep 18 13:01:25 EDT 2007


On 09/18/2007 06:09 PM,  Alexander Neundorf wrote:
> On Tuesday 18 September 2007 11:35, BlinkEye wrote:
>> Hi guys
>>
>> I'm not able to convince cmake to properly use an environment variable
>> which consists of more than one entry for the INCLUDE_DIRECTORIES
>> directive. It always takes the value as it is:
>>
>> Passing
>>
>> MY_SPECIAL_INCLUDE32=/foo/bar/32bit/include:/foo/bar/include
>>
>> to INCLUDE_DIRECTORIES like
>>
>> INCLUDE_DIRECTORIES( "$ENV{MY_SPECIAL_INCLUDE32}" )
>>
>> results in
>>
>> /usr/bin/c++ -I/foo/bar/32bit/include:/foo/bar/include ...
>>
>> instead of
>>
>> /usr/bin/c++ -I/foo/bar/32bit/include -I/foo/bar/include ...
>>
>> The same applies for LINK_DIRECTORIES but this seems not to matter for the
>> rpath command.
>>
>> I tried to use TO_CMAKE_PATH with no avail.
> 
> This should work. Can you please post the example and the results ?
> 
> Alex

Yeah, sure:

This won't work:

> export DELTA_ROOT=/foo/bar/delta3d_1.5.0_64bit
> export DELTA_DATA=$DELTA_ROOT/data
> export DELTA_INC=$DELTA_ROOT/inc
> export DELTA_INC_EXT=$DELTA_ROOT/ext/inc
> 
> export DELTA_LIB=$DELTA_ROOT/lib:$DELTA_ROOT/ext/lib:$DELTA_ROOT/ext/lib64:$DELTA_ROOT/ext/lib64/osgPlugins
> #export DELTA_LIB=$DELTA_ROOT/lib
> #export DELTA_LIB_EXT=$DELTA_ROOT/ext/lib
> #export DELTA_LIB_EXT64=$DELTA_ROOT/ext/lib64
> #export DELTA_LIB_EXT64_OSG=$DELTA_ROOT/ext/lib64/osgPlugins
> export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$DELTA_LIB:$DELTA_LIB_EXT:$DELTA_LIB_EXT64:$DELTA_LIB_EXT64_OSG
> 
> 
> 
> INCLUDE_DIRECTORIES( "$ENV{DELTA_INC}" "$ENV{DELTA_INC_EXT}" )
> #LINK_DIRECTORIES( "$ENV{DELTA_LIB}" ) 
> LINK_DIRECTORIES( "$ENV{DELTA_LIB}" "$ENV{DELTA_LIB_EXT}" "$ENV{DELTA_LIB_EXT64}" )
> ADD_EXECUTABLE( prototype prototype.cpp )
> TARGET_LINK_LIBRARIES( prototype dtCore dtABC dtUtil dtTerrain dtDAL osgProducer )
> 
> # DON'T remove! This one is necessary or delta3d applications segfault
> ADD_DEFINITIONS( -DSIGSLOT_PURE_ISO )
> ADD_DEFINITIONS( -ggdb )
> 
> 
> /usr/bin/cmake -H/foo/bar/svn/proj/src/prototype5 -B/foo/bar/svn/proj/src/prototype5 --check-build-system CMakeFiles/Makefile.cmake 0
> -- Configuring done
> -- Generating done
> -- Build files have been written to: /foo/bar/svn/proj/src/prototype5
> /usr/bin/cmake -E cmake_progress_start /foo/bar/svn/proj/src/prototype5/CMakeFiles 1
> make -f CMakeFiles/Makefile2 all
> make[1]: Entering directory `/foo/bar/svn/proj/src/prototype5'
> make -f CMakeFiles/prototype.dir/build.make CMakeFiles/prototype.dir/depend
> make[2]: Entering directory `/foo/bar/svn/proj/src/prototype5'
> make[2]: Nothing to be done for `CMakeFiles/prototype.dir/depend'.
> make[2]: Leaving directory `/foo/bar/svn/proj/src/prototype5'
> make -f CMakeFiles/prototype.dir/build.make CMakeFiles/prototype.dir/build
> make[2]: Entering directory `/foo/bar/svn/proj/src/prototype5'
> Linking CXX executable prototype
> /usr/bin/cmake -P CMakeFiles/prototype.dir/cmake_clean_target.cmake
> /usr/bin/c++      -fPIC "CMakeFiles/prototype.dir/prototype.o"   -o prototype -rdynamic -L/foo/bar/svn/proj/src/delta3d_1.5.0_64bit/lib:/foo/bar/svn/proj/src/delta3d_1.5.0_64bit/ext/lib:/foo/bar/svn/proj/src/delta3d_1.5.0_64bit/ext/lib64:/foo/bar/svn/proj/src/delta3d_1.5.0_64bit/ext/lib64/osgPlugins -ldtCore -ldtABC -ldtUtil -ldtTerrain -ldtDAL -losgProducer -Wl,-rpath,/foo/bar/svn/proj/src/delta3d_1.5.0_64bit/lib:/foo/bar/svn/proj/src/delta3d_1.5.0_64bit/ext/lib:/foo/bar/svn/proj/src/delta3d_1.5.0_64bit/ext/lib64:/foo/bar/svn/proj/src/delta3d_1.5.0_64bit/ext/lib64/osgPlugins
> /usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -ldtCore
> collect2: ld returned 1 exit status
> make[2]: *** [prototype] Error 1
> make[2]: Leaving directory `/foo/bar/svn/proj/src/prototype5'
> make[1]: *** [CMakeFiles/prototype.dir/all] Error 2
> make[1]: Leaving directory `/foo/bar/svn/proj/src/prototype5'
> make: *** [all] Error 2

Whereas the following does work:

> export DELTA_ROOT=/foo/bar/delta3d_1.5.0_64bit
> export DELTA_DATA=$DELTA_ROOT/data
> export DELTA_INC=$DELTA_ROOT/inc
> export DELTA_INC_EXT=$DELTA_ROOT/ext/inc
> 
> #export DELTA_LIB=$DELTA_ROOT/lib:$DELTA_ROOT/ext/lib:$DELTA_ROOT/ext/lib64:$DELTA_ROOT/ext/lib64/osgPlugins
> export DELTA_LIB=$DELTA_ROOT/lib
> export DELTA_LIB_EXT=$DELTA_ROOT/ext/lib
> export DELTA_LIB_EXT64=$DELTA_ROOT/ext/lib64
> export DELTA_LIB_EXT64_OSG=$DELTA_ROOT/ext/lib64/osgPlugins
> export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$DELTA_LIB:$DELTA_LIB_EXT:$DELTA_LIB_EXT64:$DELTA_LIB_EXT64_OSG
> 
> 
> INCLUDE_DIRECTORIES( "$ENV{DELTA_INC}" "$ENV{DELTA_INC_EXT}" )
> #LINK_DIRECTORIES( "$ENV{DELTA_LIB}" ) 
> LINK_DIRECTORIES( "$ENV{DELTA_LIB}" "$ENV{DELTA_LIB_EXT}" "$ENV{DELTA_LIB_EXT64}" )
> ADD_EXECUTABLE( prototype prototype.cpp )
> TARGET_LINK_LIBRARIES( prototype dtCore dtABC dtUtil dtTerrain dtDAL osgProducer )
> 
> # DON'T remove! This one is necessary or delta3d applications segfault
> ADD_DEFINITIONS( -DSIGSLOT_PURE_ISO )
> ADD_DEFINITIONS( -ggdb )
> 
> 
> /usr/bin/cmake -H/foo/bar/svn/proj/src/prototype5 -B/foo/bar/svn/proj/src/prototype5 --check-build-system CMakeFiles/Makefile.cmake 0
> -- Configuring done
> -- Generating done
> -- Build files have been written to: /foo/bar/svn/proj/src/prototype5
> /usr/bin/cmake -E cmake_progress_start /foo/bar/svn/proj/src/prototype5/CMakeFiles 1
> make -f CMakeFiles/Makefile2 all
> make[1]: Entering directory `/foo/bar/svn/proj/src/prototype5'
> make -f CMakeFiles/prototype.dir/build.make CMakeFiles/prototype.dir/depend
> make[2]: Entering directory `/foo/bar/svn/proj/src/prototype5'
> make[2]: Nothing to be done for `CMakeFiles/prototype.dir/depend'.
> make[2]: Leaving directory `/foo/bar/svn/proj/src/prototype5'
> make -f CMakeFiles/prototype.dir/build.make CMakeFiles/prototype.dir/build
> make[2]: Entering directory `/foo/bar/svn/proj/src/prototype5'
> Linking CXX executable prototype
> /usr/bin/cmake -P CMakeFiles/prototype.dir/cmake_clean_target.cmake
> /usr/bin/c++      -fPIC "CMakeFiles/prototype.dir/prototype.o"   -o prototype -rdynamic -L/foo/bar/svn/proj/src/delta3d_1.5.0_64bit/lib -L/foo/bar/svn/proj/src/delta3d_1.5.0_64bit/ext/lib -L/foo/bar/svn/proj/src/delta3d_1.5.0_64bit/ext/lib64 -ldtCore -ldtABC -ldtUtil -ldtTerrain -ldtDAL -losgProducer -Wl,-rpath,/foo/bar/svn/proj/src/delta3d_1.5.0_64bit/lib:/foo/bar/svn/proj/src/delta3d_1.5.0_64bit/ext/lib:/foo/bar/svn/proj/src/delta3d_1.5.0_64bit/ext/lib64
> make[2]: Leaving directory `/foo/bar/svn/proj/src/prototype5'
> /usr/bin/cmake -E cmake_progress_report /foo/bar/svn/proj/src/prototype5/CMakeFiles  1
> [100%] Built target prototype
> make[1]: Leaving directory `/foo/bar/svn/proj/src/prototype5'
> /usr/bin/cmake -E cmake_progress_start /foo/bar/svn/proj/src/prototype5/CMakeFiles 0




More information about the CMake mailing list