[CMake] CMAKE_TOOLCHAIN_FILE support, empty CMAKE_AR && CMAKE_RANLIB

Alexander Neundorf a.neundorf-work at gmx.net
Tue Mar 2 16:22:58 EST 2010


On Monday 01 March 2010, Oleg Kravchenko wrote:
> понеділок 01 березень 2010 23:59:24 Alexander Neundorf ви написали:
> > On Monday 01 March 2010, Oleg Kravchenko wrote:
> > > неділя 28 лютий 2010 17:24:48 Alexander Neundorf ви написали:
> > > > On Saturday 27 February 2010, Oleg Kravchenko wrote:
> > > > > Hello i am try build tinyxml library by mingw32 on gentoo linux
> > > > > with cmake: =dev-util/cmake-2.6.4-r3
> > > > > =dev-util/cmake-2.8.0-r2
> > > > >
> > > > > But have this errors:
> > > > > $ cmake -DCMAKE_TOOLCHAIN_FILE=~/i686-pc-mingw32.cmake -
> > > > > DDOKAN_INCLUDE_DIR=~/projects/dokan/ -DCMAKE_BUILD_TYPE=Debug .
> > > > > -- The C compiler identification is GNU
> > > > > -- The CXX compiler identification is GNU
> > > > > -- Check for working C compiler: /usr/bin/i686-pc-mingw32-gcc
> > > > > -- Check for working C compiler: /usr/bin/i686-pc-mingw32-gcc --
> > > > > works -- Detecting C compiler ABI info
> > > > > -- Detecting C compiler ABI info - done
> > > > > -- Check for working CXX compiler: /usr/bin/i686-pc-mingw32-g++
> > > > > -- Check for working CXX compiler: /usr/bin/i686-pc-mingw32-g++ --
> > > > > works -- Detecting CXX compiler ABI info
> > > > > -- Detecting CXX compiler ABI info - done
> > > > > -- Configuring done
> > > > > -- Generating done
> > > > > -- Build files have been written to: /home/kaa/projects/tinyxml
> > > > > $ make
> > > > > Linking CXX static library
> > > > > /home/kaa/projects/sqlfs/target/Debug/libtinyxml.a Error running
> > > > > link command: No such file or directory
> > > > > make[2]: *** [/home/kaa/projects/win32/target/Debug/libtinyxml.a]
> > > > > Error 2 make[1]: *** [tinyxml_build/CMakeFiles/tinyxml.dir/all]
> > > > > Error 2 make: *** [all] Error 2
> > > > >
> > > > > I "fix" problem by patching CMakeFindBinUtils.cmake
> > > > >
> > > > > Please fix and release 2.6.x and 2.8.x version
> > > >
> > > > Strange.
> > > > Please apply the attached patch to CMakeDetermineCCompiler.cmake and
> > > > run cmake again on a fresh build dir, and post the output.
> > > >
> > > > Alex
> > >
> > > Hello! In attachment output log.
> >
> > Thanks.
> > Attached is another small patch for CMakeFindBinutils.cmake. Please apply
> >  and post again the output.
> > I think what happens is the following:
> > cmake determines the toolchain prefix and the location correctly
> > ("i686-pc-mingw32-" and "/usr/bin" respectively).
> > Then it goes into CMakeFindBinutils.cmake to search for ar. But since you
> >  have already set this in your toolchain file, the find_program() call
> >  doesn't search for it (since it is already set).
> > Since it doesn't search for it, the CMAKE_AR variable doesn't get stored
> > in the cache, so it is empty later on.
> >
> > Let's see if we can verify this with the attached patch.
> >
> > Alex
>
> Thanks :)
> In attachment output logs

Ok, short answer: just don't set the AR, RANLIB etc. variables in the 
toolchain file. CMakeFindBinutils.cmake should find them correctly.

Longer answer see my other mail, this is a weird behaviour of set(), 
mark_as_advanced() and find_program() used in a specific order, actually 
independent from whether this is from a toolchain file or not.

Alex



More information about the CMake mailing list