编辑:接受的答案还没有解决我的问题,但它回答了我提出的问题 - 如果你能帮助我解决下面描述的实际问题,你可能会回答这个问题。
我有一个 CMake 项目,它使用需要设置变量的框架(即https://github.com/queezythegreat/arduino-cmake,需要ARDUINO_SDK_PATH
)
奇怪的是,在我在命令行上设置该变量后,它首先有一个值,但看起来它在一段时间后消失了。
我在跑
cmake -DARDUINO_SDK_PATH=/path/to/sdk ..
.. 并收到一条错误消息,告诉我它没有设置。打印出我的顶部CMakeLists.txt
和内部检查变量的框架的顶部的值给了我这样的东西:
>>> ARDUINO_SDK_PATH (beginning): '/home/me/project/arduino-1.8.2'
>>> ARDUINO_SDK_PATH (before check): '/home/me/project/arduino-1.8.2'
-- The C compiler identification is GNU 6.2.0
-- The CXX compiler identification is GNU 6.2.0
-- Check for working C compiler: /usr/bin/avr-gcc
>>> ARDUINO_SDK_PATH (before check): ''
CMake Error at /home/me/project/arduino-cmake/cmake/ArduinoToolchain.cmake:84 (message):
Could not find Arduino SDK (set ARDUINO_SDK_PATH)!
Call Stack (most recent call first):
/home/me/project/build/CMakeFiles/3.6.2/CMakeSystem.cmake:6 (include)
/home/me/project/build/CMakeFiles/CMakeTmp/CMakeLists.txt:3 (project)
CMake Error: Internal CMake error, TryCompile configure of cmake failed
-- Configuring incomplete, errors occurred!
See also "/home/me/project/build/CMakeFiles/CMakeOutput.log".
所以它看起来好像ARDUINO_SDK_PATH
以某种方式失去了它的价值。我没有找到一个实际的命令,它被分配了任何值,所以我不知道如何继续。我现在当然可以在任何地方向我的 CMake 项目添加代码以打印出值,ARDUINO_SDK_PATH
但我想知道是否有内置跟踪变量值的方法。
我试过了cmake --trace ..
,cmake --trace-expand ..
但输出似乎没有帮助..
系统:Fedora 25 和 CMake 3.6.2
更新
感谢 Florian,我添加variable_watch(ARDUINO_SDK_PATH)
了第一行CMakeLists.txt
,现在我的变量跟踪行 ( message()
) 如下所示:
CMake Debug Log at arduino-cmake/cmake/ArduinoToolchain.cmake:41 (MESSAGE):
Variable "ARDUINO_SDK_PATH" was accessed using READ_ACCESS with value
"/home/me/project/arduino-1.8.2".
Call Stack (most recent call first):
/usr/share/cmake/Modules/CMakeDetermineSystem.cmake:98 (include)
CMakeLists.txt:10 (project)
>>> ARDUINO_SDK_PATH (before check): /home/me/project/arduino-1.8.2
我有大约 30 条这样的消息,但是后面有几行没有值且没有跟踪消息的跟踪行。
所以看起来变量ARDUINO_SDK_PATH
被一个新的替换为空的并且不再被跟踪..
复制
为了使这种行为可重现,我上传了代码:https ://github.com/frans-fuerst/trinket_led
注意:提供的CMakeLists.txt
不包含有用的代码 - 它只是重现错误。
您需要下载Arduino-SDK,将其解压缩并在命令行中提供路径:
tar xvf ~/Downloads/arduino-1.8.2-linux64.tar.xz
git clone https://github.com/frans-fuerst/trinket_led
cd trinket_led
git submodules update --init
mkdir build
cd build
cmake -DARDUINO_SDK_PATH=/path/to/arduino-1.8.2 ..
注意:有一个find_path
命令ArduinoToolchain.cmake
看起来很可疑。但是你可以用同样的结果删除它..
CMakeFiles/CMakeOutput.log
The target system is: Arduino - -
The host system is: Linux - 4.10.12-200.fc25.x86_64+debug - x86_64
Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
Compiler: /usr/bin/avr-gcc
Build flags:
Id flags:
The output was:
0
Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "a.out"
The C compiler identification is GNU, found in "/home/frans/_HOME/1704_trinket_led/build/CMakeFiles/3.6.2/CompilerIdC/a.out"
Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
Compiler: /usr/bin/avr-g++
Build flags:
Id flags:
The output was:
0
Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "a.out"
The CXX compiler identification is GNU, found in "/home/frans/_HOME/1704_trinket_led/build/CMakeFiles/3.6.2/CompilerIdCXX/a.out"