[CMake] INCLUDE command within a toolchain file is stripping file path if filename is a variable?

Eric Noulard eric.noulard at gmail.com
Wed May 9 16:02:56 EDT 2012


2012/5/9 Terrence Meiczinger <terrence_nh at yahoo.com>:
> 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.
>
> Now, if I change the include as follows, it works... but this seems icky.
>
> include("${${TOOLCHAIN_COMMON}}")
>
> Any insight into why this behavior is occurring?

Woud you be able to reproduce this "include" error outside of a toolchain scope?
Could you try attached example.

put the two files somewhere and run:
cmake -P includeTest.cmake

by the way which version of CMake are you using?


-- 
Erk
Le gouvernement représentatif n'est pas la démocratie --
http://www.le-message.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: include_me.cmake
Type: application/octet-stream
Size: 96 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120509/f78dc793/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: includeTest.cmake
Type: application/octet-stream
Size: 279 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120509/f78dc793/attachment-0001.obj>


More information about the CMake mailing list