最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Why can't Cmake trace a certain file during configuration? - Stack Overflow

programmeradmin4浏览0评论

I am working on a pico-sdk project in MINGW64 MSYS2 bash shell on Windows 10, and I use:

$ /c/Program\ Files/CMake/bin/cmake.exe --version | head -1
cmake version 3.17.5

I wanted to trace my CMake process, and I have seen Verbose output for cmake command - so I used the following command:

$ /c/Program\ Files/CMake/bin/cmake.exe ../ -DCMAKE_BUILD_TYPE=Debug -G "MSYS Makefiles" --trace --trace-expand --debug-output > cmake.trace 2>&1

And indeed, I get a cmake.trace file - and here is a snippet of what interests me:

...
-- myproj_sources: main.c;...;my_algo.c
Downloading Picotool
-- Configuring done
...

Now, the myproj_sources line is definitely from my own project's CMakeLists.txt, where I have:

message(STATUS "myproj_sources: ${myproj_sources}")

The "Configuring done" line is definitely something CMake outputs on its own after processing, even if I do not use trace.

However, the "Downloading Picotool" line comes from:

  • .0.0/tools/Findpicotool.cmake#L45

... and below is a repost of the snippet around that line:

# ...

        FetchContent_GetProperties(picotool)
        set(picotool_INSTALL_DIR ${FETCHCONTENT_BASE_DIR} CACHE PATH "Directory where picotool has been installed" FORCE)
        if (NOT picotool_POPULATED)
            message("Downloading Picotool")
            FetchContent_Populate(picotool)
        endif ()
        set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE})

# ...

So, CMake ran through the entirety of this Findpicotool.cmake, and did not trace a single line!

(Btw, I also tried adding --trace-source=Findpicotool.cmake at the end of the cmake command line options - absolutely no change in above snippet)

So, can anyone explain why does CMake refuse to trace this Findpicotool.cmake - and if possible, how could I persuade to trace it anyways?

I am working on a pico-sdk project in MINGW64 MSYS2 bash shell on Windows 10, and I use:

$ /c/Program\ Files/CMake/bin/cmake.exe --version | head -1
cmake version 3.17.5

I wanted to trace my CMake process, and I have seen Verbose output for cmake command - so I used the following command:

$ /c/Program\ Files/CMake/bin/cmake.exe ../ -DCMAKE_BUILD_TYPE=Debug -G "MSYS Makefiles" --trace --trace-expand --debug-output > cmake.trace 2>&1

And indeed, I get a cmake.trace file - and here is a snippet of what interests me:

...
-- myproj_sources: main.c;...;my_algo.c
Downloading Picotool
-- Configuring done
...

Now, the myproj_sources line is definitely from my own project's CMakeLists.txt, where I have:

message(STATUS "myproj_sources: ${myproj_sources}")

The "Configuring done" line is definitely something CMake outputs on its own after processing, even if I do not use trace.

However, the "Downloading Picotool" line comes from:

  • https://github/raspberrypi/pico-sdk/blob/2.0.0/tools/Findpicotool.cmake#L45

... and below is a repost of the snippet around that line:

# ...

        FetchContent_GetProperties(picotool)
        set(picotool_INSTALL_DIR ${FETCHCONTENT_BASE_DIR} CACHE PATH "Directory where picotool has been installed" FORCE)
        if (NOT picotool_POPULATED)
            message("Downloading Picotool")
            FetchContent_Populate(picotool)
        endif ()
        set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE})

# ...

So, CMake ran through the entirety of this Findpicotool.cmake, and did not trace a single line!

(Btw, I also tried adding --trace-source=Findpicotool.cmake at the end of the cmake command line options - absolutely no change in above snippet)

So, can anyone explain why does CMake refuse to trace this Findpicotool.cmake - and if possible, how could I persuade to trace it anyways?

Share Improve this question asked yesterday sdbbssdbbs 5,4467 gold badges57 silver badges118 bronze badges 1
  • 1 BTW, you don't need --trace when --trace-expand is here... The latter is enough. – zaufi Commented 16 hours ago
Add a comment  | 

1 Answer 1

Reset to default 0

Well, this is not an answer to the question as posed (and therefore, I still hope some more knowledgeable can post a proper answer) - however, it is somewhat of a workaround for my problem; so I'm posting it as an answer for legibility.

Ultimately, I arrived to the following command line:

VERBOSE=1 /c/Program\ Files/CMake/bin/cmake.exe --trace --trace-expand --debug-output --debug-find --loglevel=TRACE --debug-output ../ -DCMAKE_BUILD_TYPE=Debug -G "MSYS Makefiles" > cmake.trace 2>&1

... without ever getting more information in my snippet of interest.

Then I found How can I debug CMakeLists.txt files? #57671941 :

I like to use variable_watch to "debug" my CMakeLists.txt files. Just set in top of my script:

variable_watch(SOME_MY_VAR)

... and then I re-read https://github/raspberrypi/pico-sdk/blob/2.0.0/tools/Findpicotool.cmake#L45 to find variables of interest - ended up with this in my main CMakeLists.txt:

# ...
variable_watch(picotool_INSTALL_DIR)
variable_watch(picotool_DIR)
variable_watch(picotool_POPULATED)
variable_watch(picotool_BUILD_TARGET)
variable_watch(picotool_TARGET)
# ...

... and finally I can see in my cmake.trace file stuff like:

...

CMake Debug Log at C:/src/pico-sdk/tools/CMakeLists.txt:119 (if):
  Variable "picotool_INSTALL_DIR" was accessed using READ_ACCESS with value
  "C:/src/myproject/picotool".
Call Stack (most recent call first):
  C:/src/pico-sdk/tools/CMakeLists.txt:485 (pico_init_picotool)
  C:/src/pico-sdk/src/cmake/on_device.cmake:57 (picotool_postprocess_binary)
  CMakeLists.txt:602 (pico_add_extra_outputs)

...

... which is basically the kind of data I need from a trace anyways.

发布评论

评论列表(0)

  1. 暂无评论