cannot use CMAKE_SOURCE_DIR in toolchain file
When trying to reference/include something from CMAKE_SOURCE_DIR in a toolchain-file, cmake seems to make a flat copy of the file for compiler-tests, then /CMakeFiles/CMakeTmp/CMakeLists.txt:3 cannot find the include-file in /CMakeFiles/CMakeTmp/
Example: we are using conan and our compiler is provided as a conan-package. Conan will generate a conanbuildinfo.cmake which will provide path-variables for all tools. toolchain-file:
include(${CMAKE_SOURCE_DIR}/conanbuildinfo.cmake)
set(CMAKE_C_COMPILER ${CONAN_BIN_DIRS_CLANG}/clang-cl.exe)
set(CMAKE_CXX_COMPILER ${CONAN_BIN_DIRS_CLANG}/clang-cl.exe)
set(CMAKE_LINKER ${CONAN_BIN_DIRS_CLANG}/lld-link.exe)
output:
-- The C compiler identification is Clang 9.0.0 with MSVC-like command-line
-- The CXX compiler identification is Clang 9.0.0 with MSVC-like command-line
-- Check for working C compiler: user/.conan/data/clang/9.0.0/tools/stable/package/9d74748ca8155c54bee5ded2267de5f3e409cf81/bin/clang-cl.exe
CMake Error at C:/src/Example/tool-clang-windows-x86.cmake:8 (include):
include could not find load file:
C:/src/Example/CMakeFiles/CMakeTmp/conanbuildinfo.cmake
Call Stack (most recent call first):
C:/src/Example/CMakeFiles/3.15.4/CMakeSystem.cmake:6 (include)
C:/src/Example/CMakeFiles/CMakeTmp/CMakeLists.txt:3 (project)