修改:接受的答案尚未解决我的问题,但它回答了我问过的问题 - 如果您可以帮我解决下面描述的实际问题,您可以回答this问题
我有一个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 ..
,但输出似乎没有帮助..
系统:带有CMake 3.6.2的Fedora 25
更新
感谢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"
答案 0 :(得分:3)
只需将variable_watch(ARDUINO_SDK_PATH)
放在CMakeLists.txt
的顶部。
<强>参考强>