skip to Main Content

I’m trying modules using CMake and C++20. But cmake can’t find clang-scan-deps program. But i can use it in my terminal so i don’t know why it can’t find it.
Error message:

~/coding/cpp-modules
> cmake --build ./build/Debug --target all
[1/8] Scanning /usr/include/vulkan/vulkan.cppm for CXX dependencies
FAILED: CMakeFiles/VulkanHppModule.dir/usr/include/vulkan/vulkan.cppm.o.ddi
"CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS-NOTFOUND" -format=p1689 -- /usr/bin/clang++-17   -g -std=gnu++20 -x c++ /usr/include/vulkan/vulkan.cppm -c -o CMakeFiles/VulkanHppModule.dir/usr/include/vulkan/vulkan.cppm.o -MT CMakeFiles/VulkanHppModule.dir/usr/include/vulkan/vulkan.cppm.o.ddi -MD -MF CMakeFiles/VulkanHppModule.dir/usr/include/vulkan/vulkan.cppm.o.ddi.d > CMakeFiles/VulkanHppModule.dir/usr/include/vulkan/vulkan.cppm.o.ddi.tmp && mv CMakeFiles/VulkanHppModule.dir/usr/include/vulkan/vulkan.cppm.o.ddi.tmp CMakeFiles/VulkanHppModule.dir/usr/include/vulkan/vulkan.cppm.o.ddi
/bin/sh: 1: CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS-NOTFOUND: not found
[2/8] Scanning /home/lastlost/coding/cpp-modules/main.cpp for CXX dependencies
FAILED: CMakeFiles/CppModulesTest.dir/main.cpp.o.ddi
"CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS-NOTFOUND" -format=p1689 -- /usr/bin/clang++-17   -g -std=gnu++20 -x c++ /home/lastlost/coding/cpp-modules/main.cpp -c -o CMakeFiles/CppModulesTest.dir/main.cpp.o -MT CMakeFiles/CppModulesTest.dir/main.cpp.o.ddi -MD -MF CMakeFiles/CppModulesTest.dir/main.cpp.o.ddi.d > CMakeFiles/CppModulesTest.dir/main.cpp.o.ddi.tmp && mv CMakeFiles/CppModulesTest.dir/main.cpp.o.ddi.tmp CMakeFiles/CppModulesTest.dir/main.cpp.o.ddi
/bin/sh: 1: CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS-NOTFOUND: not found
ninja: build stopped: subcommand failed.

If i type clang-scan-deps:

~/coding/cpp-modules
> clang-scan-deps --version
clang-scan-deps
Ubuntu LLVM version 17.0.6
  Optimized build.

Tried Setting CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS variable to "/usr/local/bin/clang-scan-deps" or "clang-scan-deps" and it didn’t work.

2

Answers


  1. Chosen as BEST ANSWER

    I've found temporary solution to my problem. If you go to your CMakeCache.txt file and find CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS variable you will find something like this: CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS:FILEPATH=**Something here** instead you need to do something like: CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS:FILEPATH=/usr/local/bin/clang-scan-deps. But as i said it is a temporary solution because in the next project cmake wouldn't be able to find clang-scan-deps file again and you will need to do that again. P.S. Be aware that /usr/local/bin/clang-scan-deps is my path and you need to find path to clang-scan-deps yourself.


  2. If your operating system is Ubuntu, you can install clang-17-tools and create an alias as below:

    ln -s /usr/lib/llvm-17/bin/clang-scan-deps /usr/bin/clang-scan-deps
    

    You can check this project: infinity, which has already made extensive use of C++20 modules. In this document, you will find how to solve the ‘CLANG_SCAN_DEPS-NOTFOUND’ problem.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search