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

Terrence Meiczinger terrence_nh at yahoo.com
Wed May 9 15:02:45 EDT 2012


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?

Thanks,

Terrence


More information about the CMake mailing list