[CMake] INCLUDE command within a toolchain file is stripping file path if filename is a variable?
Alexander Neundorf
a.neundorf-work at gmx.net
Wed May 9 16:00:35 EDT 2012
On Wednesday 09 May 2012, Terrence Meiczinger wrote:
> I have a top level cmake toolchain file and I want it to include another
> file. If I give the include a string filename it works. However, if I try
> to make the filename a variable, it can no longer find the included file.
> It appears cmake is stripping the path.
>
>
> The following works fine...
>
> linux-gnu-x86_64.cmake:
>
> include("/src/toolchains/linux-common.cmake")
>
> however, if I do the following it does not..
>
> linux-gnu-x86_64.cmake:
> set(TOOLCHAIN_COMMON "/src/toolchains/linux-common.cmake")
> message(STATUS "TOOLCHAIN_COMMON: ${TOOLCHAIN_COMMON}")
> include("${TOOLCHAIN_COMMON}")
>
>
> It fails:
>
> -> cmake -DCMAKE_TOOLCHAIN_FILE=/src/toolchains/linux-gnu-x86_64.cmake
>
> -- TOOLCHAIN_TOP: /src/toolchains/linux-gnu-x86_64.cmake
> -- TOOLCHAIN_COMMON: /src/toolchains/linux-common.cmake
> -- The C compiler identification is GNU
> -- The CXX compiler identification is GNU
> -- Check for working C compiler: /usr/bin/gcc
> CMake Error at /src/toolchains/linux-gnu-x86_64.cmake:18 (INCLUDE):
> include could not find load file:
>
> /linux-common.cmake
>
> As you can see the from the status output, the path is the same as the
> first example. However, it appears cmake is stripping it prior to actually
> including it.
Strange.
I tried to reproduce it here and was not able to.
I added this to the end of a toolchain file, and test.cmake happily issued its
message without problems:
set(myDir "/home/alex/src/CMake/tc/test.cmake")
include("${myDir}")
If you look into CMakefiles/CMakeSystem.cmake, there the toolchain file is
included using include(), nothing special there.
Can you send a simple testcase ?
Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120509/b62ce03f/attachment-0001.htm>
More information about the CMake
mailing list