cmake.getLaunchTargetFilename is broken
See original GitHub issueBug
If I use ${command:getLaunchTargetFilename} in my task.json I get the following error:
[main] =======================================================
[main] No executable target was found to launch. Please check:
[main]  - Have you called add_executable() in your CMake project?
[main]  - Have you executed a successful CMake configure?
[main] No program will be executed
More Detail
This task.json
{
	// See https://go.microsoft.com/fwlink/?LinkId=733558
	// for the documentation about the tasks.json format
	"version": "2.0.0",
	"tasks": [
		{
			"label": "echo",
			"type": "shell",
			"command": "echo 'buildTargetName: ${command:cmake.buildTargetName}\nbuildType: ${command:cmake.buildType}\ntasksBuildCommand: ${command:cmake.tasksBuildCommand}\nbuildDirectory: ${command:cmake.buildDirectory}\n'"
		}
	]
}
has the following output
buildTargetName: model_test
buildType: Debug
tasksBuildCommand: /usr/bin/cmake --build /home/fbenning/code/grazer/Debug --config Debug --target model_test -- -j 10
buildDirectory: /home/fbenning/code/grazer/Debug
pressing the build button works without error, and executing ./Debug/.../model_test manually works as well. (i.e. the file exists!)
additionally the CMakeLists.txt includes add_executable(model_test ModelTest.cpp).
(Possibly) Related Issues
- https://github.com/microsoft/vscode-cmake-tools/issues/461
 - https://github.com/microsoft/vscode-cmake-tools/issues/1412 (Debug Button also does not work 
[main] Failed to prepare executable target with name 'undefined') 
Platform and Versions
- Operating System: Ubuntu
 - CMake Version: 3.16.3
 - VSCode Version:1.53.2
 - CMake Tools Extension Version:1.6.0
 - Compiler/Toolchain: GCC 9.3.0
 
Issue Analytics
- State:
 - Created 3 years ago
 - Comments:23 (13 by maintainers)
 
Top Results From Across the Web
Visual Studio Code with CMake Tools: launch.json not ...
I am trying to configure VSCode for debugging my code. My project is configured by CMake. I use the CMake Tools extensions.
Read more >"Fossies" - the Fresh Open Source Software Archive
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) TypeScript source code syntax highlighting...
Read more >vscode-cmake-tools/support - Gitter
The message I'm getting is: [main] No executable target was found to launch. Please check: [main] - Have you called add_executable() in your...
Read more >CMake: IntelliSense not working for newly added .cpp files
1. Open a new CMake project and wait for CMake and Visual Studio to complete. · 2. Add a new source file to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

After a lot of attempt, I finally located the reason: In CMakeLists.txt, I wrote
set(CMAKE_BUILD_TYPE DEBUG)for my project, maybe this command disturbed the parsing of CMakeCache.txt for cmake-tools? after annotating the line and rebuilding, everything worked normally : ) and I realized CMAKE_BUILD_TYPE possible value should beDebuginstead ofDEBUG…but it looks likeDEBUGis acceptable for cmake as I can use gdb with my bin…well @andreeis @FelixBenning thank you for your help@CatsNipYummy I’m going to create a new issue for yours because it does not seem related and this issue is closed.