Bug 465640

Summary: KDevelop ignores build target paths
Product: [Applications] kdevelop Reporter: Zamundaaa <xaver.hugl>
Component: Build tools: NinjaAssignee: kdevelop-bugs-null
Status: REPORTED ---    
Severity: normal CC: igorkuo, mvolden2
Priority: NOR    
Version First Reported In: git master   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: example project

Description Zamundaaa 2023-02-12 20:45:04 UTC
Created attachment 156175 [details]
example project

When building a build target that's in a subfolder, KDevelop calls ninja with the target name but ignores the folder, which ninja doesn't recognize as a valid build target, so the build fails.
Comment 1 Igor Kushnir 2023-02-15 04:48:29 UTC
Does this bug affect only Meson projects? Not CMake? If so, the component should be changed to "Build tools: Meson".
Comment 2 Morten Danielsen Volden 2024-10-20 19:35:22 UTC
The bug only affects Meson. It seems there is a difference between how meson and cmake generates output for ninja.
So if I for example generate two projects with a similar structure, say something like below for cmake:
.
├── CMakeLists.txt
├── main.cpp
└── subfolder
    ├── CMakeLists.txt
    └── test_stuff_cmake.cpp

And for meson something like this:
.
├── main.cpp
├── meson.build
└── subfolder
    ├── meson.build
    └── test_stuff.cpp

After building the respective projects, if I issue the command 'ninja -t targets all' I can see that the the CMake project will have in the output:

subfolder/CMakeFiles/test_stuff_cmake.dir/test_stuff_cmake.cpp.o: CXX_COMPILER__test_stuff_cmake_unscanned_Debug
subfolder/test_stuff_cmake: CXX_EXECUTABLE_LINKER__test_stuff_cmake_Debug
test_stuff_cmake: phony

Whereas the meson generated project does not have the last entry:

subfolder/test_stuff.p/test_stuff.cpp.o: cpp_COMPILER
subfolder/test_stuff: cpp_LINKER


That means kdevelop will succeed on building the dependent cmake target

> /usr/bin/ninja test_stuff_cmake

but fail on a similar meson target:

> /usr/bin/ninja test_stuff
ninja: error: unknown target 'test_stuff'
*** Failure: Exit code 1 ***

Will result in the error that is reported here.