1

I am writing CMake for my project. It works fine, but every time when I want to use it, I have to specify some additional parameters:

cmake -G "MinGW Makefiles" -DCMAKE_TOOLCHAIN_FILE="D:/stm32-cmake/cmake/gcc_stm32.cmake" -DSTM32_CHIP=STM32F207ZCT ..

Is it possible to save these parameters in CMakeLists.txt file? In my CMakeLists.txt I tried following options:

set(STM32_CHIP STM32F207ZCT)
set(STM32_CHIP STM32F207ZCT CACHE STRING "")
add_definitions(-DSTM32_CHIP=STM32F207ZCT)

But none of these seems to work. These parameters are used in toolchain file, so probably I have to set these variables globally in some way. And is it possibile to set CMAKE_TOOLCHAIN_FILE in CMakeLists.txt? This code:

set(CMAKE_TOOLCHAIN_FILE "D:/stm32-cmake/cmake/gcc_stm32.cmake")

is not working.

qbranchmaster
  • 119
  • 1
  • 11
  • Solution suggested by @Florian is fine for me. This is what I wanted to achieve. – qbranchmaster Dec 05 '17 at 10:24
  • For more details see also ["CMake: In which Order are Files parsed (Cache, Toolchain, …)?"](https://stackoverflow.com/questions/30503631/cmake-in-which-order-are-files-parsed-cache-toolchain) – Florian Dec 05 '17 at 10:25

0 Answers0