Search code examples
c++clinuxgcccmake

CMake does not use toolchain file


I am creating an entirely new CMake build with the ARM toolchain. I ran the following command:

cmake -DCMAKETOOLCHAINFILE=../arm-none-eabi-gcc.cmake -DCMAKE_BUILD_TYPE=Debug  ../

Even though there are no cache files in the build directory, this is the output:

cmake -DCMAKETOOLCHAINFILE=../arm-none-eabi-gcc.cmake -DCMAKE_BUILD_TYPE=Debug  ../ 
-- The C compiler identification is GNU 11.3.0
-- The CXX compiler identification is GNU 11.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKETOOLCHAINFILE


-- Build files have been written to: /home/alejandro/projects/ST-LIB/build ```

Why is CMake not using my toolchain file?

I run the cmake command in the build directory inside my library, so ../ is correct for the relative path.


Solution

  • You had a typo. It should be CMAKE_TOOLCHAIN_FILE.