[CMake] Avoiding absolute paths in toolchain file?

Johan Holmberg johan556 at gmail.com
Thu Sep 19 07:03:47 EDT 2013


Hi!

I'm trying to use a toolchain file (using -DCMAKE_TOOLCHAIN_FILE=....) to
cross compile with CMake. I specify my C compiler with:

    set(CMAKE_C_COMPILER my_c_compiler)

I have given just the name of the compiler, and rely on CMake to find the
compiler via my PATH (and this seems to work). But later in the toolchain
file I need to refer to files in the same installation tree as
"my_c_compiler". Specifically the linker variable CMAKE_EXE_LINKER_FLAGS needs
to contain the path to a configuration file that is located in a parallel
directory to the compiler:

    <dir_of_compiler>/../lib/

I was hoping that after CMake have found the path to the compiler, it would
be possible to derive the path to the lib-directory from the compiler path.
But I don't understand how to do it in the toolchain file.

Is it possible, without hard-coding the path in the toolchain file?

/Johan Holmberg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130919/08aed050/attachment.htm>


More information about the CMake mailing list