[CMake] set ranlib/ar in toolchain file

Eric Noulard eric.noulard at gmail.com
Thu Jul 5 04:22:17 EDT 2012


2012/7/5 Yngve Inntjore Levinsen <yngve.levinsen at gmail.com>:
> Hi Eric,
>
> Thanks for your suggestion. If one shouldn't set RANLIB/AR oneself, then I find
> it a bit confusing that the information about those variables are listed here:
> http://www.cmake.org/Wiki/CMake_Useful_Variables
> But perhaps that list is meant for different stuff?

They are listed there because you:
  - may need to USE them after CMake discovered the value
  - may need to set them to alternate values than those discovered by CMake
    because of a specific need.

This does not mean you NEED to set them.
The fact that you need to set them in your case makes me think that
your toolchain
was either misused or incomplete.
I may be wrong though.

> Your suggestion did not set the right ranlib/ar binaries.

Which ranlib/ar was discovered by CMake?

You did not give us the exact command line you use with the output
given by the cmake run.

I can ensure you that on my box the provided toolchain works and
discover a coherent set of mingw compiler and tools (include ar/ranlib)
there must be something specific in your case.


> I did have a look in
> the file CMakeFindBinUtils.cmake, where a suggestion of setting
> _CMAKE_TOOLCHAIN_PREFIX came up. This actually worked.

Right, but this should be automatically set when the C or C++ compiler is
discovered (using your toolchain file).

have a look at:
Modules/CMakeDetermineCCompiler.cmake
which says:

# If not already set before, it also sets
#   _CMAKE_TOOLCHAIN_PREFIX

So if the toolchain properly define CMAKE_C_COMPILER  and
other tools like C++ compiler, ar, ranlib etc... do share the same prefix
then _CMAKE_TOOLCHAIN_PREFIX will be automatically set and the tools
discovered properly.

This works for me.
This doesn't seems to work for you.

> Not sure if it is expected to work though, so I would be happy to hear if
> someone has the "official" solution. If it is expected, perhaps one could add
> the information about how this variable work to the Wiki pages for toolchains?
> Perhaps one could use this variable also when searching for the compilers and
> linkers?

It theoretically works like I just describe it.
So there must be something specific on your side, do the C/C++
compiler share the
same prefix as ar / ranlib tools?



-- 
Erk
Le gouvernement représentatif n'est pas la démocratie --
http://www.le-message.org


More information about the CMake mailing list